brightsparklabs / appcli

A library for adding CLI interfaces to applications in the brightSPARK Labs style
MIT License
2 stars 4 forks source link

Attached Tasks do not show stdout/stderr #257

Open david-homley opened 2 years ago

david-homley commented 2 years ago

When running a Task that is 'attached' (eg not run in detach mode), no output from stdout/stderr is shown.

This can be shown via the following snippet, which is attempting to run a task that executes a static SQL script in a mcr.microsoft.com/mssql-tools docker image:

$ ./<app> task run executeOptusPreIngestScript
# Standard appcli logs omitted for brevity 
2022-03-08T02:50:42+0000 INFO: Running task [executeOptusPreIngestScript] with args [()] ...
2022-03-08T02:50:52+0000 INFO: Task service finished with code [1]

Running the same task on an older release of the same app gives:

$ ./<app> task run executeOptusPreIngestScript
# Standard appcli logs omitted for brevity 
2022-03-08T02:50:23+0000 INFO: Running task [executeOptusPreIngestScript] with args [()] ...
Sqlcmd: Error: Microsoft ODBC Driver 13 for SQL Server : Login timeout expired.
Sqlcmd: Error: Microsoft ODBC Driver 13 for SQL Server : TCP Provider: Error code 0x2749.
Sqlcmd: Error: Microsoft ODBC Driver 13 for SQL Server : A network-related or instance-specific error has occurred while establishing a connection to SQL Server. Server is not found or not accessible. Check if instance name is correct and if SQL Server is configured to allow remote connections. For more information see SQL Server Books Online..
2022-03-08T02:50:32+0000 INFO: Task service finished with code [1]

Hence the expected behaviour is for the Sqlcmd error logs to be included.

thomas-anderson-bsl commented 2 years ago

This is because of the change we made here: https://github.com/brightsparklabs/appcli/blob/develop/appcli/orchestrators.py#L701

By setting capture_output=True, we capture the stdout from the docker-compose command, and it isn't shown.

We needed to set capture_output=True to be able to capture and use the output of the docker-compose command with the orchestrator in custom_commands.

We need to think about how we can support both use-cases.

thomas-anderson-bsl commented 2 years ago

We run docker-compose for a few commands, most of which we need to see the output: