Mirror exit status from command instead of displaying a traceback
From https://gitlab.developers.cam.ac.uk/uis/devops/raven/deploy-raven-core/-/issues/32#note_204528
If the command run by logan exits with a non-zero exit status a traceback like this is displayed:
Traceback (most recent call last):
File "/Library/Frameworks/Python.framework/Versions/3.7/bin/logan", line 8, in <module>
sys.exit(main())
File "/Library/Frameworks/Python.framework/Versions/3.7/lib/python3.7/site-packages/logan/tool.py", line 134, in main
main_temp_dir(tmp_dir, args, conf, version)
File "/Library/Frameworks/Python.framework/Versions/3.7/lib/python3.7/site-packages/logan/tool.py", line 246, in main_temp_dir
run_docker(*docker_run_args)
File "/Library/Frameworks/Python.framework/Versions/3.7/lib/python3.7/site-packages/logan/tool.py", line 382, in run_docker
subprocess.run(list(itertools.chain([DOCKER], args)), check=True)
File "/Library/Frameworks/Python.framework/Versions/3.7/lib/python3.7/subprocess.py", line 468, in run
output=stdout, stderr=stderr)
subprocess.CalledProcessError: Command '['/usr/local/bin/docker', 'run', '--rm', '-i', '-t', '-v', '/<censor>/deploy-raven-core:/workdir:ro', '-v', 'raven-core-terraform-data:/terraform_data/', '-v', '/tmp/<censor>/secret-<censor>:/config/service-account-credentials.json:ro', '-v', '/tmp/<censor>/environment:/terraform_data/environment:ro', '-v', 'ssh-agent:/ssh-agent', '-e', 'SSH_AUTH_SOCK=/ssh-agent/ssh-agent.sock', '-e', 'GOOGLE_APPLICATION_CREDENTIALS=/config/service-account-credentials.json', 'registry.gitlab.developers.cam.ac.uk/uis/devops/infra/dockerimages/logan-terraform:0.13', 'terraform', 'plan']' returned non-zero exit status 1.
This is not terribly friendly. Instead, make logan not care what the exit status is but mirror it back to the caller via sys.exit(...)
.