Merge pull request #111 from Sea-Haven-Industries/fix/ab/deploy-verify-health-convergence
Some checks are pending
Validate and deploy / Validate deployable source bundle (push) Waiting to run
Validate and deploy / Deploy shoc-backend-dev through Terraform (push) Blocked by required conditions
Validate and deploy / Deploy shoc-backend-staging to Elastic Beanstalk (push) Blocked by required conditions

fix(deploy): let EB health converge before failing the version gate
This commit is contained in:
Alexandre Brandizzi 2026-09-10 14:37:57 -03:00 • committed by GitHub
commit 6d58865253
No known key found for this signature in database
GPG key ID: B5690EEEBB952194

View file

@ -330,17 +330,25 @@ jobs:
echo "environment status: $status; version: $current; health: $health" echo "environment status: $status; version: $current; health: $health"
if [ "$status" = "Ready" ]; then if [ "$status" = "Ready" ]; then
if [ "$current" = "$expected" ] && { [ "$health" = "Green" ] || [ "$health" = "Yellow" ]; }; then if [ "$current" != "$expected" ]; then
echo "Environment became Ready on version $current, not the expected $expected." >&2
exit 1
fi
if [ "$health" = "Green" ] || [ "$health" = "Yellow" ]; then
echo "Expected application version is Ready and healthy." echo "Expected application version is Ready and healthy."
exit 0 exit 0
fi fi
echo "Environment became Ready without activating expected version $expected." >&2 # The expected version IS active. Elastic Beanstalk reports Ready as
exit 1 # soon as the rollout finishes, before enhanced health has converged,
# so deciding on the first Ready poll fails a good release on a health
# value that was always going to change. Keep polling; an environment
# that is genuinely unhealthy still fails when the window runs out.
echo "Expected version is active; waiting for health to leave $health."
fi fi
sleep 15 sleep 15
done done
echo "Expected application version did not become Ready within the deployment window." >&2 echo "Expected application version did not become Ready and healthy within the deployment window (last seen: status=$status version=$current health=$health)." >&2
exit 1 exit 1
- name: Post-deploy smoke - name: Post-deploy smoke
@ -612,16 +620,22 @@ jobs:
) )
echo "environment status: $status; version: $current; health: $health" echo "environment status: $status; version: $current; health: $health"
if [ "$status" = "Ready" ]; then if [ "$status" = "Ready" ]; then
if [ "$current" = "$prev" ] && { [ "$health" = "Green" ] || [ "$health" = "Yellow" ]; }; then if [ "$current" != "$prev" ]; then
echo "Rollback reached Ready on version $current, not the previous $prev." >&2
exit 1
fi
if [ "$health" = "Green" ] || [ "$health" = "Yellow" ]; then
echo "Application version restore complete; previous code is Ready and healthy." echo "Application version restore complete; previous code is Ready and healthy."
exit 0 exit 0
fi fi
echo "Rollback reached Ready in an unexpected version/health state." >&2 # Same convergence gap as the release check above: the previous version
exit 1 # is back, health has not settled yet, and reporting a failed rollback
# here hides the fact that the restore itself worked.
echo "Previous version is active; waiting for health to leave $health."
fi fi
sleep 15 sleep 15
done done
echo "Environment did not return to Ready within rollback window." >&2 echo "Environment did not return to Ready and healthy within the rollback window (last seen: status=$status version=$current health=$health)." >&2
exit 1 exit 1
deploy-staging: deploy-staging:
@ -724,17 +738,25 @@ jobs:
echo "environment status: $status; version: $current; health: $health" echo "environment status: $status; version: $current; health: $health"
if [ "$status" = "Ready" ]; then if [ "$status" = "Ready" ]; then
if [ "$current" = "$expected" ] && { [ "$health" = "Green" ] || [ "$health" = "Yellow" ]; }; then if [ "$current" != "$expected" ]; then
echo "Environment became Ready on version $current, not the expected $expected." >&2
exit 1
fi
if [ "$health" = "Green" ] || [ "$health" = "Yellow" ]; then
echo "Expected application version is Ready and healthy." echo "Expected application version is Ready and healthy."
exit 0 exit 0
fi fi
echo "Environment became Ready without activating expected version $expected." >&2 # The expected version IS active. Elastic Beanstalk reports Ready as
exit 1 # soon as the rollout finishes, before enhanced health has converged,
# so deciding on the first Ready poll fails a good release on a health
# value that was always going to change. Keep polling; an environment
# that is genuinely unhealthy still fails when the window runs out.
echo "Expected version is active; waiting for health to leave $health."
fi fi
sleep 15 sleep 15
done done
echo "Expected application version did not become Ready within the deployment window." >&2 echo "Expected application version did not become Ready and healthy within the deployment window (last seen: status=$status version=$current health=$health)." >&2
exit 1 exit 1
- name: Post-deploy smoke - name: Post-deploy smoke
@ -822,15 +844,21 @@ jobs:
) )
echo "environment status: $status; version: $current; health: $health" echo "environment status: $status; version: $current; health: $health"
if [ "$status" = "Ready" ]; then if [ "$status" = "Ready" ]; then
if [ "$current" = "$prev" ] && { [ "$health" = "Green" ] || [ "$health" = "Yellow" ]; }; then if [ "$current" != "$prev" ]; then
echo "Rollback reached Ready on version $current, not the previous $prev." >&2
exit 1
fi
if [ "$health" = "Green" ] || [ "$health" = "Yellow" ]; then
echo "Application version restore complete; previous code is Ready and healthy." echo "Application version restore complete; previous code is Ready and healthy."
exit 0 exit 0
fi fi
echo "Rollback reached Ready in an unexpected version/health state." >&2 # Same convergence gap as the release check above: the previous version
exit 1 # is back, health has not settled yet, and reporting a failed rollback
# here hides the fact that the restore itself worked.
echo "Previous version is active; waiting for health to leave $health."
fi fi
sleep 15 sleep 15
done done
echo "Environment did not return to Ready within rollback window." >&2 echo "Environment did not return to Ready and healthy within the rollback window (last seen: status=$status version=$current health=$health)." >&2
exit 1 exit 1