Skip to content

aws-batch: Handle connection errors gracefully - #542

Merged
victorlin merged 1 commit into
masterfrom
victorlin/handle-connection-error
Aug 10, 2026
Merged

aws-batch: Handle connection errors gracefully#542
victorlin merged 1 commit into
masterfrom
victorlin/handle-connection-error

Conversation

@victorlin

Copy link
Copy Markdown
Member

Description of proposed changes

Instead of crashing with an unhandled traceback when network connectivity to AWS Batch is lost, raise a UserError instructing the user how to re-attach to the job once connection is restored.

Add a new helper function reattach_cmd() for use in both detach() and connection error handlers.

Related issue(s)

Error mentioned on Slack

Checklist

  • Checks pass
  • Update changelog

Instead of crashing with an unhandled traceback when network
connectivity to AWS Batch is lost, raise a UserError instructing the
user how to re-attach to the job once connection is restored.

Add a new helper function reattach_cmd() for use in both detach() and
connection error handlers.
@victorlin victorlin self-assigned this Aug 7, 2026
Comment on lines +197 to +204
except botocore.exceptions.ConnectionError as error:
raise UserError(f"""
Lost connection with AWS Batch.

Re-attach with:

{reattach_cmd(opts.attach, local_workdir)}
""") from error

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

non-blocking nit

Should this just be raised within JobState.update?

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think it's useful to have the reattach command in the error message, and that's only available in run().

@victorlin
victorlin merged commit 1e3e0af into master Aug 10, 2026
97 of 99 checks passed
@victorlin
victorlin deleted the victorlin/handle-connection-error branch August 10, 2026 21:04
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.

2 participants