Skip to content

Commit

Permalink
Exit with a non-zero exit code if we have unrecoverable errors
Browse files Browse the repository at this point in the history
This commit propagates non-zero exit codes upwards so the runner of this
code knows that the container did not exit successfully.
  • Loading branch information
pawalt committed Feb 24, 2025
1 parent 3f7c4f6 commit 08a7300
Showing 1 changed file with 8 additions and 0 deletions.
8 changes: 8 additions & 0 deletions modal/_container_entrypoint.py
Original file line number Diff line number Diff line change
Expand Up @@ -593,12 +593,14 @@ def breakpoint_wrapper():
# The only caveat is a bunch of calls will now cross threads, which adds a bit of overhead?
client = Client.from_env()

exited_successfully = True
try:
with proxy_tunnel(container_args.proxy_info):
try:
main(container_args, client)
except UserException:
logger.info("User exception caught, exiting")
exited_successfully = False
except KeyboardInterrupt:
logger.debug("Container: interrupted")

Expand All @@ -619,3 +621,9 @@ def breakpoint_wrapper():
)

logger.debug("Container: done")

# At this point, we've already logged that the container hit an error,
# but we need to exit with a non-zero exit code so the worker knows about
# the failure.
if not exited_successfully:
exit(1)

0 comments on commit 08a7300

Please sign in to comment.