Repository navigation
feat(kubernetes): replace agents built from an outdated pod template (RIG-7278) - #22
Merged
mattwilkinsonn merged 7 commits intoNov 2, 2026
Merged
Conversation
…(RIG-7278) The provider reads its agent pod template once at start. After a template change, agents that already exist keep the old env until they happen to be scaled down. With MIN_AGENTS above zero that can be hours. The provider now stamps a template hash on each agent pod and reports pods whose hash differs. Each reconcile drains those agents. They are removed once idle, and scale-up deploys fresh agents rather than reactivating them. Refs RIG-7278 Co-authored-by: Matt Wilkinson <matt@rigel.build>
…RIG-7278) An empty template image falls back to config.Image, and config also adds env. Hashing only the template missed those changes, so agents built from an old config were never marked outdated. Refs RIG-7278 Co-authored-by: Matt Wilkinson <matt@rigel.build>
…IG-7278) Refs RIG-7278 Co-authored-by: Matt Wilkinson <matt@rigel.build>
Draining after calcAgents counted outdated agents as capacity. With MinAgents=1 no replacement was deployed before the old agent was removed, and scale-down could drain a current agent too. Never-contacted outdated agents are drained as well, since they hold no work. Refs RIG-7278 Co-authored-by: Matt Wilkinson <matt@rigel.build>
Drained outdated agents may still run work, and their pods stay until removed. createAgents now caps new agents at MaxAgents minus every pool agent, so a rollout replaces busy agents as they finish rather than doubling the pool. The reconcile test also pins deploy-before-remove. Refs RIG-7278 Co-authored-by: Matt Wilkinson <matt@rigel.build>
A drained outdated agent is never reused, so the warm-idle timeout only kept its MaxAgents slot from its replacement. removeDrainedAgents now removes an outdated agent as soon as it has no tasks. createAgents logs the capped count it actually starts. A multi-reconcile test covers a rollout at MaxAgents. Refs RIG-7278 Co-authored-by: Matt Wilkinson <matt@rigel.build>
Refs RIG-7278 Co-authored-by: Matt Wilkinson <matt@rigel.build>
Author
Review note: head 9b37bbe
|
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.
Summary
MIN_AGENTS > 0that can be hours, which is how the CD pool ran stale agents during the RIG-7278 outage.wp.autoscaler/template-hash, and reports pool pods whose hash is missing or different through a new optionaltypes.OutdatedAgentLister. Other providers and the mocks are untouched.Reconciledrains outdated agents before capacity planning, so they count as unavailable: replacements deploy in the same pass and scale-down only picks current agents.createAgentsnever reactivates an outdated agent, and caps new agents atMaxAgentsminus every pool agent row, so a rollout replaces busy agents as they finish instead of doubling the pool.removeDrainedAgentsretires an outdated agent once it has no tasks; the warm-idleLastWorktimeout does not apply, because it is never reused.Rollout behavior
MaxAgents, an outdated agent's slot is refilled on the reconcile after its removal (default interval 1m).replicas: 1, so two scaler versions do not drain each other's agents.Tests
go test ./...,go vet ./...,gofmt -l,golangci-lint runonengine+providers/kubernetesare clean.providers/kubernetes);Test_drainOutdatedAgents(drain, no-op provider, update error, lister error stops reconcile, MinAgents=1 replace-before-retire with event order, multi-reconcile rollout at MaxAgents);Test_createAgents(no reactivation, MaxAgents cap);Test_isAgentIdle(outdated bypass).Spec-impact: none
Refs RIG-7278