Repository navigation
Poll the ECS service deployment status in the app rollout step - #552
Open
CarsonDavis wants to merge 4 commits into
Open
CarsonDavis wants to merge 4 commits into
CarsonDavis wants to merge 4 commits into
Conversation
The rollout step waited for the old Express configuration to drain (about a minute past ECS reporting SUCCESSFUL) and could not see a rollback, so a failed rollout only surfaced at the 20-minute timeout. Poll the deployment named by currentDeployment with describe-service-deployments instead: exit 0 on SUCCESSFUL, exit 1 with the status and reason on STOPPED or any ROLLBACK_* status. Grant the deploy role ecs:DescribeServiceDeployments on its own admin service's deployments; the new poll needs it.
Terraform plan preview —
|
Terraform plan preview —
|
currentDeployment is null in the update response and the deployment is created a few seconds later, so find it with list-service-deployments filtered to deployments created after the update was sent. If none appears (an unchanged image starts no deployment), pass only when the service already runs just the new image. Fail immediately on AccessDenied instead of retrying for 20 minutes, and on a describe that returns no deployment. Grant the deploy role ecs:ListServiceDeployments and list the service ARN as a resource too; note both permissions in the deploy role facts.
An invalid deployment ARN never clears on retry. Taking T0 30 s in the past tolerates runner clock skew; the per-environment concurrency group keeps other deployments out of that window.
This branch has not been deployed
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Line breakdown
The deploy job now waits on the ECS service deployment's own status, so a rollback fails the job on the next poll instead of after the 20-minute timeout.
What this does
ROLLBACK_*status, such as a circuit-breaker rollback), the job fails on the next 15-second poll.Deployment failed: <STATUS> (<reason>).SUCCESSFUL(new tasks healthy), which finished about a minute sooner on the last dev deploy.list-service-deployments --created-at after=...), waiting up to about 60 seconds for one to appear.ACTIVEand its only active image is the new one, logging "already servingAccessDenied,UnauthorizedOperationorInvalidParameterExceptionerror fromdescribe-service-deploymentsis printed and exits 1 instead of retrying for 20 minutes, as does a describe that returns no deployment ("Deployment not found"), while other describe errors are still retried.ecs:ListServiceDeploymentsandecs:DescribeServiceDeployments: the grant covers only that environment's admin service ARN and its deployments (service-deployment/mmgis-<env>/mmgis-<env>-admin/*).Decisions to review
SUCCESSFUL, not that only the new image is left running. A green step no longer guarantees the old-image tasks have stopped; nothing after this step depends on that today.ROLLBACK_REQUESTED/ROLLBACK_IN_PROGRESS) fails the job immediately. The alternative was to wait forROLLBACK_SUCCESSFULorROLLBACK_FAILEDand report which one; failing early is faster, but you have to check the console to see whether the service ended up healthy on the old image.cluster/service/idARN format was checked against live dev ARNs, and IAM policy simulation shows the new statement allows both calls while the current live role denies them.Before merging / follow-ups
infrastructure/terraform/bootstrap) for each environment. The live dev deploy role does not haveecs:ListServiceDeploymentsorecs:DescribeServiceDeploymentstoday.deploy-production.ymlcalls the same reusableapp-deploy.yml.bash -non the extracted step; mocked runs of the success, rollback, stopped, no-deployment-already-on-new-image (exit 0), no-deployment-not-on-new-image (exit 1), AccessDenied (immediate exit 1), missing-deployment (exit 1), and timeout paths; and read-only live checks on dev thatlist-service-deploymentswith the--created-atfilter returns the latest deployment ARN (and nothing when no deployment is newer), and thatdescribe-service-deploymentsreturnsSUCCESSFUL. The workflow itself has not run yet.