Skip to content

fix(engine): replace outdated agents one at a time (RIG-10331) - #25

Merged
rigel-nemo[bot] merged 10 commits into
rigel-releasefrom
ci-pipelines/rig-10331-replace-outdated-agents-one-at-a-time
Nov 16, 2026
Merged

rigel-nemo[bot] merged 10 commits into
rigel-releasefrom
ci-pipelines/rig-10331-replace-outdated-agents-one-at-a-time

Conversation

@rigel-mintaka

@rigel-mintaka rigel-mintaka commented Nov 16, 2026 •

Copy link
Copy Markdown

What does this do

The autoscaler now replaces outdated agents one at a time and keeps the pool's capacity. A pool with MaxAgents=1 gets its replacement in the same reconcile cycle. The next outdated agent drains only after a replacement connects.

Why do we need it

With MaxAgents=1, the rollout drained the only agent and created its replacement a cycle later, so image builds hit pending-unmatched-timeout (main run #28568).

Summary

  • An idle outdated agent is removed before capacity planning, so the replacement is created in the same cycle, within MaxAgents. A replacement is identified by agent ID, so a reused name does not count as new.
  • A replacement that does not connect within AgentCreationTimeout (falling back to AgentInactivityTimeout) is reaped and retried. The gate stays closed and each failure logs a warning with a counter. When both timeouts are zero, the gate has no bound and logs one warning.
  • The gate opens without a replacement only when the pool is quiet: no pending work routes to it and it has at least MinAgents. A deploy error therefore cannot retire the pool one agent per cycle. Busy-pool surge or deferral is not changed here; it waits on RIG-10357.

Verification

This repo has no devenv, so rbuild cannot gate it. On macpro2013 at 505ac0c6, with CGO_ENABLED=0 and Go 1.27.3:

  • gofmt -l . reports no files.
  • go vet ./... passes.
  • go test -count=1 ./... passes in every package, including the eight new rollout tests.
  • With the pending-work check inverted, Test_reconcile_deployFailureKeepsDrainGate fails.
  • Review took five rounds. The last, at 505ac0c6, found 0 high, 0 medium, 1 low.

Risks

Accepted: waiting on a busy drained agent has no time limit and only warns. The rollout also pauses while other pools take this pool's pending work; that fails safe. Rollback: revert this PR and keep the 1.5.0-rigel.4 image.

Spec impact

Spec-impact: none — fork engine behaviour; Orion's topology spec does not describe rollout internals

Refs RIG-10331

Co-authored-by: Matt Wilkinson matt@rigel.build

rigel-mintaka and others added 10 commits November 16, 2026 05:30
Co-authored-by: Matt Wilkinson <matt@rigel.build>
Co-authored-by: Matt Wilkinson <matt@rigel.build>
Co-authored-by: Matt Wilkinson <matt@rigel.build>
Co-authored-by: Matt Wilkinson <matt@rigel.build>
Co-authored-by: Matt Wilkinson <matt@rigel.build>
Co-authored-by: Matt Wilkinson <matt@rigel.build>
Co-authored-by: Matt Wilkinson <matt@rigel.build>
Co-authored-by: Matt Wilkinson <matt@rigel.build>
Co-authored-by: Matt Wilkinson <matt@rigel.build>
Co-authored-by: Matt Wilkinson <matt@rigel.build>
@linear-code

linear-code Bot commented Nov 16, 2026

Copy link
Copy Markdown

RIG-10331

@rigel-mintaka

Copy link
Copy Markdown
Author

Review all-clear: dba580937e0695c9558e3cc0179165e2be301c8f

Round Head High Medium Low
1 7ac6d973 2 3 4
2 dd5d5ed5 1 1 5
3 81b51ff8 1 0 4
4 40e5bb0c 0 1 2
5 505ac0c6 0 0 1
  • Round 1: a timed-out replacement released the gate and cascaded through the pool; a long busy drain reaped fresh boots. Fixed by re-arming the gate and reaping each agent by its own age.
  • Round 2: a quiet pool stalled the rollout; the zero-timeout semantics had drifted. Fixed: a quiet pool advances, and main's cleanup behaviour is restored.
  • Round 3: a deploy error released the gate while work was pending. Fixed: the gate releases with no replacement attempt only when the pool is quiet (no routed pending work, at least MinAgents).
  • Round 4: the deploy-failure test only covered MinAgents. Fixed with MinAgents=1; the test fails when the pending check is inverted.
  • Accepted lows: the wait on a busy drained agent only warns and has no time limit; the rollout pauses while work routes to the pool.

Verification at 505ac0c6 on macpro2013: gofmt -l . reports nothing, go vet ./... passes, and go test -count=1 ./... passes. rjc rebased it to dba58093; the interdiff is empty.

@rigel-nemo

rigel-nemo Bot commented Nov 16, 2026

Copy link
Copy Markdown

Checks read:

@rigel-nemo
rigel-nemo Bot merged commit 6c2dda8 into rigel-release Nov 16, 2026
2 of 4 checks passed
rigel-nemo Bot pushed a commit that referenced this pull request Nov 16, 2026
chore(release): 1.5.0-rigel.5 (RIG-10331)

Ships same-cycle outdated-agent replacement (#25).

Refs RIG-10331

Co-authored-by: Matt Wilkinson <matt@rigel.build>
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.

1 participant