Repository navigation
Conversation
spot-watch marked a worker Unhealthy on every EC2 rebalance recommendation so the ASG would swap it out. Over the six weeks to 2026-10-16 that replaced a median 18-28 workers per weekday in each of QA OCW and the three Production pools, 1.6-1.8x the real spot interruption count, losing in-flight builds and the baggageclaim cache each time. A recommendation only signals elevated interruption risk, so log it and keep draining on the 2-minute interruption notice. This also removes the local-drain fallback that retired the worker on fresh instances whose SetInstanceHealth call was rejected inside the ASG's 300s health-check grace period. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Contributor
There was a problem hiding this comment.
🟢 Approval recommended
The focused change preserves interruption draining, and mocked execution confirmed continued polling after rebalance recommendations.
0 open findings
What changed in this PR
Reduces Concourse spot-worker churn by treating EC2 rebalance recommendations as advisory rather than triggering replacement.
Changes:
- Logs the first rebalance recommendation without replacing or draining the worker.
- Continues polling for interruption notices, preserving the existing drain behavior.
- Documents the operational rationale.
| File | Description |
|---|---|
src/bilder/images/concourse/files/concourse-worker-spot-watch |
Removes rebalance-triggered replacement and adds one-time logging while preserving interruption handling. |
🧠 Review effort: Balanced
💡 Add a code-review agent skill or configure MCP servers for context-aware, tailored reviews. Learn more in the docs.
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.
What are the relevant tickets?
N/A
Description (What does it do?)
Concourse spot workers were marking themselves Unhealthy on every EC2 rebalance recommendation, so the ASG replaced them. That was the largest cause of worker churn. Over the six weeks to 2026-10-16, QA OCW and the three Production pools each lost a median of 18–28 workers per weekday this way (peaks of 40–57), 1.6–1.8× their real spot interruption count. Each replacement threw away running builds and the baggageclaim cache.
concourse-worker-spot-watchnow logs the first rebalance recommendation and does nothing else. Draining on the 2-minute spot interruption notice is unchanged.Implementation details
SetInstanceHealthcall coming from the worker's own instance role, about itself. All of the instances were spot, across every QA and Production pool.The age of the instance (N seconds) is less than the configured grace period of 300 seconds. On that path the script fell back toconcourse-worker-drain, retiring the Concourse worker process on a fresh instance the ASG still considered healthy. That path is gone too.handle_rebalanceended insleep infinity, so after a rebalance recommendation the script stopped polling for the interruption notice. The loop now keeps watching for it.concourse-worker-preflightstill callsset-instance-healthwhen its network checks fail, so the IAM permission stays.enable_rerun_when_worker_disappears.How can this be tested?
Only
bash -n, shellcheck and prek have been run; this can't be checked before merge. After the Concourse worker AMI is rebuilt and rolled out:aws autoscaling describe-scaling-activities --auto-scaling-group-name <worker asg>: "user health-check" terminations should drop to near zero, leaving mostly "maximum instance lifetime" and "EC2 health check indicating it has been terminated" (spot reclaims).aws cloudtrail lookup-events --lookup-attributes AttributeKey=EventName,AttributeValue=SetInstanceHealth: calls fromconcourse-instance-role-worker-*should only appear for preflight failures.Additional context
Worker-side journald units (spot-watch, preflight, lifecycle-hook) never reach Loki, which is why this was diagnosed from CloudTrail. That's tracked separately.
🤖 Generated with Claude Code