Skip to content

Delay recreation of a listener pod that exited with a failure - #4703

Open
CloudNinjaDev wants to merge 1 commit into
actions:masterfrom
CloudNinjaDev:fix/listener-restart-delay
Open

CloudNinjaDev wants to merge 1 commit into
actions:masterfrom
CloudNinjaDev:fix/listener-restart-delay

Conversation

@CloudNinjaDev

Copy link
Copy Markdown

Summary

Fixes #4656.

The listener pod is built with restartPolicy: Never, so the controller is the only thing pacing restarts. A listener that fails deterministically on startup (revoked token, exhausted API rate limit) was deleted and recreated immediately, repeating the auth handshake against GitHub every few seconds and burning API quota.

This keeps a dead listener pod whose container exited with a non-zero code for 15s after it finished before deleting it, by returning RequeueAfter with the remaining time. The terminated pod stays visible meanwhile. Clean exits (code 0), evictions, and pods with no finish time are recreated immediately as before.

This is the minimal, CRD-free variant suggested in the issue: a fixed delay without escalation or status changes. A growing backoff could be layered on later if maintainers want it.

Testing

Local run (go1.27.1, envtest k8s 1.37.0):

$ go test ./controllers/actions.github.com/ -run TestListenerRestartDelay -v
--- PASS: TestListenerRestartDelay (0.00s)
    --- PASS: TestListenerRestartDelay/no_container_status
    --- PASS: TestListenerRestartDelay/container_is_running
    --- PASS: TestListenerRestartDelay/clean_exit_is_recreated_immediately
    --- PASS: TestListenerRestartDelay/failure_without_a_finish_time_is_recreated_immediately
    --- PASS: TestListenerRestartDelay/fresh_failure_waits_out_the_delay
    --- PASS: TestListenerRestartDelay/failure_older_than_the_delay_is_recreated_immediately
PASS

$ go test ./controllers/actions.github.com/ -ginkgo.focus 'AutoscalingListener|AutoscalingRunnerSet'
ok  	github.com/actions/actions-runner-controller/controllers/actions.github.com	69.814s

The existing envtest listener suite (including the test that a terminated listener container gets its pod re-created) still passes. Those tests use pods without a finish time, so they are not delayed.

The listener pod uses restartPolicy Never, so the controller is the only
thing pacing restarts. A listener that fails deterministically on startup
(revoked token, exhausted API rate limit) was deleted and recreated
immediately, repeating the auth handshake against GitHub every few
seconds and burning API quota.

Keep a pod whose listener container exited non-zero for 15s after it
finished before deleting it. Clean exits and pods without a finish time
are still recreated immediately.

Fixes actions#4656

This branch has not been deployed

No deployments
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.

AutoscalingListener recreates crashed listener pod immediately with no backoff

1 participant