Repository navigation
Clean up ECS task definitions even when the error-check lookup fails - #78
Merged
Merged
Conversation
checkForAWSErroredJobs() only garbage-collected orphan task definitions on its success paths, so a rejection from getAllTasksWithJobId or describeECSTasks skipped cleanup for that poll cycle. The lookup and per-task reporting now live in a reportErroredTasks() helper, and cleanup runs on both the success and failure paths. On failure we catch, run cleanup best-effort (logging any cleanup error with console.error), and rethrow the original error. A plain `finally` would let a cleanup error replace the lookup error, hiding the real cause from createResilientCycle. On the success path a cleanup failure still propagates, as before. The env-var checks stay outside the try/catch, since cleanup needs the management app tag. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
chrisbendel
approved these changes
Oct 14, 2026
chrisbendel
left a comment
Contributor
There was a problem hiding this comment.
Looks good - checked that running cleanup on the failure path can't delete anything extra, since orphan status only depends on the BMA ready list and not on the report step.
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 subscribe to this conversation on GitHub.
Already have an account?
Sign in.
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.
Jira: SHRMP-340. Follow-up to #76 (SHRMP-339).
What and why
checkForAWSErroredJobs()only garbage-collected orphan ECS task definitions on its success paths. IfgetAllTasksWithJobIdordescribeECSTasksrejected, the function threw before cleanup ran, and orphan task definitions were left behind for that poll cycle.The lookup and per-task reporting now live in a private
reportErroredTasks()helper.checkForAWSErroredJobs()runs cleanup on both paths:console.error, and the original error is rethrown socreateResilientCyclelogs the real cause.Missing env vars (
ECS_CLUSTER,MANAGEMENT_APP_*) still fail before any AWS calls, and no cleanup runs. Cleanup needs the management app tag, so it can't run without them.Reviewer focus
finally. A plainfinally { await cleanupTaskDefs(...) }would let a cleanup error replace the lookup error, which would hide the root cause. The.catchkeeps cleanup best-effort on the failure path only.Testing
pnpm run checkspasses (typecheck, Prettier, ESLint).pnpm testpasses: 162 tests, 100% coverage, includingsrc/lib/aws-check-jobs.ts.aws-check-jobs.test.ts:getAllTasksWithJobIdrejects: same error rethrown, cleanup runs,describeECSTasksnot calleddescribeECSTasksrejects: same error rethrown, cleanup runsNo merge preconditions or manual steps.
🤖 Generated with Claude Code