mirror of
https://github.com/containers/podman-compose.git
synced 2025-05-09 16:54:48 +02:00
Properly surface errors from build commands
the commit38b13a3
("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 <46761267+charliemirabile@users.noreply.github.com>
This commit is contained in:
parent
52e2912e0b
commit
2e7d83f7f0
@ -2613,7 +2613,7 @@ async def compose_build(compose, args):
|
||||
status = 0
|
||||
for t in asyncio.as_completed(tasks):
|
||||
s = await t
|
||||
if s is not None:
|
||||
if s is not None and s != 0:
|
||||
status = s
|
||||
|
||||
return status
|
||||
|
0
tests/integration/build_fail_multi/__init__.py
Normal file
0
tests/integration/build_fail_multi/__init__.py
Normal file
3
tests/integration/build_fail_multi/bad/Dockerfile
Normal file
3
tests/integration/build_fail_multi/bad/Dockerfile
Normal file
@ -0,0 +1,3 @@
|
||||
FROM busybox
|
||||
|
||||
RUN false
|
8
tests/integration/build_fail_multi/docker-compose.yml
Normal file
8
tests/integration/build_fail_multi/docker-compose.yml
Normal file
@ -0,0 +1,8 @@
|
||||
version: "3"
|
||||
services:
|
||||
bad:
|
||||
build:
|
||||
context: bad
|
||||
good:
|
||||
build:
|
||||
context: good
|
3
tests/integration/build_fail_multi/good/Dockerfile
Normal file
3
tests/integration/build_fail_multi/good/Dockerfile
Normal file
@ -0,0 +1,3 @@
|
||||
FROM busybox
|
||||
#ensure that this build finishes second so that it has a chance to overwrite the return code
|
||||
RUN sleep 0.5
|
@ -0,0 +1,31 @@
|
||||
# SPDX-License-Identifier: GPL-2.0
|
||||
|
||||
import os
|
||||
import unittest
|
||||
|
||||
from tests.integration.test_utils import RunSubprocessMixin
|
||||
from tests.integration.test_utils import podman_compose_path
|
||||
from tests.integration.test_utils import test_path
|
||||
|
||||
|
||||
def compose_yaml_path():
|
||||
""" "Returns the path to the compose file used for this test module"""
|
||||
base_path = os.path.join(test_path(), "build_fail_multi")
|
||||
return os.path.join(base_path, "docker-compose.yml")
|
||||
|
||||
|
||||
class TestComposeBuildFailMulti(unittest.TestCase, RunSubprocessMixin):
|
||||
def test_build_fail_multi(self):
|
||||
output, error = self.run_subprocess_assert_returncode(
|
||||
[
|
||||
podman_compose_path(),
|
||||
"-f",
|
||||
compose_yaml_path(),
|
||||
"build",
|
||||
# prevent the successful build from being cached to ensure it runs long enough
|
||||
"--no-cache",
|
||||
],
|
||||
expected_returncode=1,
|
||||
)
|
||||
self.assertIn("RUN false", str(output))
|
||||
self.assertIn("while running runtime: exit status 1", str(error))
|
Loading…
Reference in New Issue
Block a user