Skip to content

fix: Detect deployment rollback after service stabilization#860

Merged
omkhegde merged 1 commit into
aws-actions:masterfrom
NahutabDevelop:fix/deployment-rollback-detection
Apr 28, 2026
Merged

fix: Detect deployment rollback after service stabilization#860
omkhegde merged 1 commit into
aws-actions:masterfrom
NahutabDevelop:fix/deployment-rollback-detection

Conversation

@NahutabDevelop

Copy link
Copy Markdown
Contributor

Issue #, if available:

Fixes #191.

Description of changes:

Problem

When a service has the deployment circuit breaker with rollback enabled, a failed deployment triggers a rollback. The service becomes stable again on the previous task definition, and the action reports success — even though the deployment actually failed.

Fix

After waitUntilServicesStable, verify the deployment actually succeeded:

  1. Before updateService, capture the current PRIMARY deployment ID
  2. From the updateService response, capture the new PRIMARY deployment ID
  3. If the IDs differ (a new deployment was created), call describeServices after stability and check:
    • Deployment not found → rolled back by circuit breaker → fail
    • rolloutState: FAILEDfail
    • Otherwise → success

This uses deployment ID comparison instead of task definition ARN comparison, which correctly handles force-new-deployment , EBS volume changes where the task definition doesn't change across deployments, and anything that would create a deployment that is added to ECS logic in the future.

No new API permissions required — uses the existing ecs:DescribeServices permission.

Testing

  • Updated existing unit tests to include deployment data in mocks
  • Added unit tests for: rollback detection, FAILED rolloutState, and no-new-deployment skip
  • Used my own AWS account for E2E validation with a Fargate service with circuit breaker + rollback enabled, deploying a broken image and confirming the action correctly fails

By submitting this pull request, I confirm that you can use, modify, copy, and redistribute this contribution, under the terms of your choice.

@omkhegde omkhegde merged commit d46c585 into aws-actions:master Apr 28, 2026
7 of 8 checks passed
@NahutabDevelop NahutabDevelop deleted the fix/deployment-rollback-detection branch April 29, 2026 14:18
@wanis-fahmy

Copy link
Copy Markdown

Hey @omkhegde @amazreech, can someone please release this in GitHub so we can make use of it?
many thanks 🙏

@NahutabDevelop

Copy link
Copy Markdown
Contributor Author

It's been released now! @wanis-fahmy 😃

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.

GitHub action should fail if deployment circuit breaker / rollback is triggered

4 participants