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

Properly surface errors from build commands #1168

Merged
merged 1 commit into from
Mar 19, 2025

Conversation

charliemirabile
Copy link
Contributor

@charliemirabile charliemirabile commented Mar 17, 2025

fixes #476

@charliemirabile
Copy link
Contributor Author

Not sure if this needs unit tests / how to test if the maintainers think it does.

@charliemirabile charliemirabile marked this pull request as ready for review March 17, 2025 23:54
@p12tic
Copy link
Collaborator

p12tic commented Mar 18, 2025

I think an integration test could be handy.

Surprisingly, we test build command already. Probably https://github.com/containers/podman-compose/blob/main/tests/integration/build_fail/test_podman_compose_build_fail.py test could be enhanced to test this situation as well in separate test.

@p12tic
Copy link
Collaborator

p12tic commented Mar 18, 2025

Other than this, this is great find, thanks for submitting a PR.

@charliemirabile charliemirabile force-pushed the build_exit branch 2 times, most recently from 3ed32dc to e041d82 Compare March 19, 2025 01:32
@charliemirabile
Copy link
Contributor Author

Ok, I have added an integration test. I fear that it isn't perfect, because while it will definitely pass 100% with the changes in this PR, it is possible that it could pass erroneously on the current main branch because it is basically relying on a race condition to surface the original bug (the image that fails needs to finish first and then the successful one finishes second so that the failing status is erased by the new status code of 0). I can't really think of any better way to test this - you could make the sleep command in the successful image arbitrarily long in order to increase the chances of it winning the race, but you can't ever get it 100% because the scheduler could just choose not to run the failing build, and the longer you make it, the longer the test takes. the 0.5s sleep is plenty on my maching to have a 100% failure rate on the main branch, but I have a reasonably fast computer.

@charliemirabile charliemirabile force-pushed the build_exit branch 2 times, most recently from 04196dd to 6ad344e Compare March 19, 2025 01:43
@charliemirabile
Copy link
Contributor Author

charliemirabile commented Mar 19, 2025

I just reread you message more carefully

I think an integration test could be handy.

Surprisingly, we test build command already. Probably https://github.com/containers/podman-compose/blob/main/tests/integration/build_fail/test_podman_compose_build_fail.py test could be enhanced to test this situation as well in separate test.

If you would prefer that I merge the new test I created in a folder build_fail_multi into the existing build_fail one, I can, though I am not sure if it would actually be cleaner.

the commit 38b13a3 ("Use asyncio for subprocess calls") broke the way
exit codes are reported from the podman compose build command.

The tasks are awaited as they finish which means that if a later build
finishes sucessfully after a failing build, it overwrites status.

Previously the `parse_return_code` function would skip updating the status
if the new return code was zero, but in removing it, this logic was not
carried forward.

Fixes: 38b13a3 ("Use asyncio for subprocess calls")
Signed-off-by: charliemirabile <[email protected]>
@p12tic
Copy link
Collaborator

p12tic commented Mar 19, 2025

Thanks for writing a test, looks great. Having test in separate directory or not is something not worth arguing, especially since the rest of tests don't have consistency in this regard. Regarding sleep, in this case it's the best way to solve the issue even if we have a race condition in the test. The integration test suite is slow anyway, so a second here or there does not matter much. If we start to care about integration test performance, better avenue would be to parallelize it.

@p12tic p12tic merged commit 8b1bd01 into containers:main Mar 19, 2025
8 checks passed
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

Successfully merging this pull request may close these issues.

podman-compose build exits 0 when build fails
2 participants