Skip to content

Fix dev deploy reporting failure after a healthy deploy - #26

Open
WesP10 wants to merge 1 commit into
mainfrom
fix/dev-deploy-exit-code
Open

WesP10 wants to merge 1 commit into
mainfrom
fix/dev-deploy-exit-code

Conversation

@WesP10

@WesP10 WesP10 commented Oct 28, 2026

Copy link
Copy Markdown
Collaborator

The first dev-slot deploy (Oct 28) worked, but the job still failed. backend-dev passed its health check, the log printed "✅ Dev deployment completed", and then the step exited with code 1.

Cause

The deploy script was sent to ssh ec2-deploy without a command, so the server ran it in a login shell. When a login shell exits, it runs ~/.bash_logout. On Ubuntu that file calls clear_console, which fails when there's no terminal. Because the script uses set -e, that failure turned the script's exit 0 into exit code 1.

The prod deploy doesn't hit this because its script never calls exit; it just runs to the end. I reproduced both cases locally with Ubuntu's .bash_logout:

How the script ends Login shell bash -s
set -e + exit 0 (dev) 1 0
runs to the end (prod) 0 0
a command fails 1 1

Fix

  • ssh ec2-deploy bash -s << 'DEPLOY_EOF': the script now runs in a plain shell, so ~/.bash_logout never runs, and a real failure still gives exit code 1. As a side effect, the Ubuntu welcome banner no longer appears in the log.
  • The health check uses curl -fs, so the expected "connection refused" while uvicorn starts no longer shows up in the log.

Testing

To check before merging: go to Actions → Deploy dev slot to EC2 → Run workflow, choose fix/dev-deploy-exit-code in "Use workflow from", and enter fix/dev-deploy-exit-code as the branch. That branch pins the same web-client and cloud-services commits as main. The run should finish green.

Merging this into main also redeploys prod, as every merge does. Prod deploys the same commits it's already running.

🤖 Generated with Claude Code

The dev deploy fed its script to `ssh ec2-deploy` with no command, so it ran
in a login shell. On exit a login shell runs ~/.bash_logout, whose
clear_console fails without a tty, and under `set -e` that turned the
script's `exit 0` into exit 1 even though backend-dev was healthy. Run the
script with `bash -s` instead (this also drops the MOTD from the log), and
stop printing the expected connection-refused while uvicorn starts.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Copilot AI balanced review requested due to automatic review settings October 28, 2026 17:41

Copilot AI left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

Copilot was unable to review this pull request because the user who requested the review has insufficient remaining quota.

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