Preserve exit code when docker-compose exists with an error #800
Comments
we run the docker-compose in detached mode, so this is the expected behavior the process is launched in background, when we saw this abrupt fail? https://github.com/elastic/apm-integration-testing/blob/master/scripts/modules/cli.py#L629-L634 |
I have remembered how we manage this on the test, we use docker-compose-wait to wait for all the containers up and ready if docker-compose-wait failed the make target fails. https://github.com/elastic/apm-integration-testing/blob/master/Makefile#L116 |
Is this a question for me? |
@sqren I meant, this is the expected behavior of docker-compose when you launch What it is the use case where you would run |
@sqren
if the do not launch a subprocess this terminal blocks for the docker-compose process, so you can not continue with the execution of the script. see the following script.
On the other screen capture, you post in this case You should use the same approach we use for the ITs call @victor is working on the CI part of the execution of your script, we see that the script has a bunch of logic to orchestrate the execution of the containers, that logic is easy to manage on the docker-compose side. When we have the final solution for the CI we will review the script to see if you are interested in removing some parts and relay on the compose.py |
In the example you give you are not running in detached mode. If you run in detached mode
That's clear and I think it's fine to run as a subprocess.
And this is what I'm arguing to improve. I'm by no means an experienced python dev so take the following with a grain of salt. From the python docs it looks like it's possible to get the return code from the subprocess like so: def run_docker_compose_process(self, docker_compose_cmd):
try:
return subprocess.call(docker_compose_cmd)
except OSError as err:
print('ERROR: Docker Compose might be missing. See below for further details.\n')
raise OSError(err)
def start_handler(self):
returncode = run_docker_compose_process(...)
sys.exit(returncode) WDYT? |
I know this is an example of what happens when you launch compose in a regular way, or you are waiting for the exit code of a process in background, the terminal is blocked waiting for the process.
@sqren it was possible if
|
Hmmm.. I might be misunderstanding you, but I made a proof of concept here: #804 |
see #803 this use check_call to wrap all |
That's great! 👍 |
Invoking apm-integration testing doesn't preserve the exit code from docker-compose.
Demonstration
While running the above command, I kill
docker
which results in the following error:However, the exit code is 0 indicating that everything went fine.
The text was updated successfully, but these errors were encountered: