Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Incorrect quiet logic on Compose CLI Component #395

Open
Sid-Sun opened this issue Dec 22, 2022 · 3 comments
Open

Incorrect quiet logic on Compose CLI Component #395

Sid-Sun opened this issue Dec 22, 2022 · 3 comments

Comments

@Sid-Sun
Copy link

Sid-Sun commented Dec 22, 2022

Hey,

I have noticed some weird behavior in the Compose component:

  • The quiet flag (default false) accepted in docker compose functions is passed as is to the run function as capture_stdout (default true), however, the run function is configured to capture output when capture_stdout is true and so:
    • sending quiet as false to compose functions leads to output not being captured (as capture_stdout gets set as false)
    • sending quiet as true to compose functions leads to output being captured (as capture_stdout gets set as true)
  • The docker compose functions do not return the run function's output which leads to output not being returned in cases of successful operation (in case of failure, the exception can be caught, which will have the logs (if quiet was set to true)

run(full_cmd, capture_stdout=quiet, capture_stderr=quiet)

This seems like very odd behavior to me, if it is expected behavior, am I missing something?

Thanks :D

@gabrieldemarmiesse
Copy link
Owner

Hello! This is a bit tricky indeed to always have the same behavior for exceptions and the error message, it's true that the behaviour should be improved if possible.

One difficulty we also have is TTY. There is no way we can store interactive output in a string and at the same time, display it in the terminal (maybe I'm wrong, this is the best of my knowledge on the matter).

I'll take a look at it when I come back from my holidays. In the meantime, if you want to propose something in a pull request, I'd be glad to review it!

@ITJamie
Copy link

ITJamie commented Jan 9, 2023

I have been working on migrating salt from the docker-compose python library and to python on whales. (https://github.com/saltstack/salt/pull/63051/files)

I have i similarly want all the compose functions to return their output rather than printing it to screen, along with being able to check the exit code / status from the command run.

For use in automation tooling (eg salt or ansible) it is 100% needed to be able to access those outputs to be able to make decisions in other parts of automation scripting.

My PR above will be the first PR to move docker compose commands over to the python on whales library. I imagine the same will be used in future for general docker commands from python

@gabrieldemarmiesse
Copy link
Owner

Thank you for the feedback! As always I'm totally open for a pull request in this direction. I'll work on it when I have the time if there is no activity on the subject for a while :)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants