← Back to Pull requests

Delete stale AutoscalingListeners left behind by a naming change #4657

Closed
unknown closed this pull request without merging on Sep 20, 2026 01:19 UTC
View on GitHub
unknown unknown commented on Sep 14, 2026 07:26 UTC
Author

Problem

Fixes https://github.com/actions/actions-runner-controller/issues/4629

Upgrading the controller in place across 0.13.x -> 0.14.x leaves two AutoscalingListener objects per AutoscalingRunnerSet: the new one, and the pre-upgrade one whose pod crash-loops forever with RunnerScaleSetNotFoundException because it still carries the old runnerScaleSetId. Nothing ever deletes it.

Root cause

scaleSetListenerName (controllers/actions.github.com/resourcebuilder.go:990) embeds a hash whose inputs changed in 0.14.0 (https://github.com/actions/actions-runner-controller/pull/4299): hash(namespace) became hash(namespace, runnerGroup, gitHubConfigUrl). The AutoscalingRunnerSet reconciler finds its listener only by a single Get on that derived name (autoscalingrunnerset_controller.go, the listener lookup before createAutoScalingListenerForRunnerSet). After the upgrade the Get misses the existing listener, so a new one is created and the old one is orphaned. It lives in the controller namespace, so it has no owner reference and is not garbage collected, and the listener reconciler only deletes a listener when its AutoscalingRunnerSet is gone.

Fix

Before the by-name lookup, list the listeners in the controller namespace that carry the scale set identity labels (actions.github.com/scale-set-name and actions.github.com/scale-set-namespace, stamped on every listener since at least 0.12) and delete any whose name is not the derived one. A reconcile then converges back to exactly one listener per AutoscalingRunnerSet. The list verb is already granted to the manager role, and the reconciler already watches AutoscalingListener events.

How tested

New envtest case in autoscalingrunnerset_controller_test.go: a listener named test-asrs-deadbeef-listener with the identity labels and a spec pointing at the scale set exists before the AutoscalingRunnerSet is created; the test asserts exactly one listener remains and it is the derived one.

Before:

[FAIL] Test AutoscalingRunnerSet with a listener left behind by a previous controller version
  [It] deletes the stale listener and keeps only the one it derives for the scale set
  Expected [ ... "test-asrs-deadbeef-listener" ... ] to have length 1
Ran 1 of 92 Specs in 27.041 seconds -- 0 Passed | 1 Failed

After:

ok  	github.com/actions/actions-runner-controller/controllers/actions.github.com	7.239s   (focused)
ok  	github.com/actions/actions-runner-controller/controllers/actions.github.com	235.482s (full package, 92 specs)

gofmt, go vet and golangci-lint run (v2.11.2) are clean.

Links

  • https://github.com/actions/actions-runner-controller/issues/4629

  • Naming change: https://github.com/actions/actions-runner-controller/pull/4299
  • This change was prepared with an AI agent operated by KR-Ravindra, who reviewed and tested it.

    Diff: 360 lines (+270 / -90) across 4 files Reviewer: KR-Ravindra Review duration: 8273m
    All Vouch review confidence checks passed
    Residual risk 0.17 = Change Risk (0.43) × (1 − Review Confidence (0.60)). Review depth and reviewer attention state are adequate.
    Model 1 · Change Risk (XGBoost)
    Score: 0.43 · 360 lines diff across 4 files
    0.43
    Model 2 · Review Depth (DistilBERT)
    Depth Score: 0.17 · 1 substantive comment(s)
    0.17
    Model 3 · Review Timing & Attention
    Session adequacy: 100% · Reviewer familiarity: 35%
    60%
    Bedrock Claude 3 · Risk Narration
    (disconnected)
    Groq
    Groq Risk Narration
    AWS Bedrock is currently disconnected. Generate high-confidence PR triage narration on-demand using Groq.
    Model 1 · Change Risk Attribution
    SHAP Weights
    Diff Size diff_size
    0.352
    Shallow Review Depth shallow_review_depth
    0.289
    Real PR Conversation Timeline
    1 comments
    "Review active on #4657"
    general weight: 0.35
    Reviewers
    Assignees
    Unassigned
    Labels
    risk: low confidence: 60.5% reviewed
    Vouch Risk Breakdown
    AI-powered review risk analysis
    Change Risk
    Change Risk · Model 1 (XGBoost)
    Predicted defect probability (0.00–1.00) based on diff churn, modified sensitive files, and author risk history.
    Score: 42.6% (MEDIUM) · Higher = larger blast radius
    42.6%
    Review Confidence
    Review Confidence · Models 2 & 3
    Scrutiny score (0.00–1.00) combining DistilBERT semantic review depth with reviewer familiarity and session dwell time.
    Score: 60.5% · Lower = rushed or shallow review
    60.5%
    Residual Risk
    Residual Risk · Core Equation
    Residual = Change × (1 − Confidence)
    Unmitigated risk surviving review. ≥ 0.65 triggers an automated re-queue to protect production.
    Score: 16.8% · Safe to merge
    16.8%