Repository navigation
Release AutoscalingRunnerSet deletion when the GitHub config secret is gone - #4688
Conversation
…s gone deleteRunnerScaleSet returned the GetActionsService error when the githubConfigSecret no longer existed, so the finalizer was never removed and the AutoscalingRunnerSet stayed in Terminating forever. The secret resolver now wraps errors with %w so a NotFound survives the chain. On NotFound during deletion the controller logs that the scale set must be removed manually, drops the runner-scale-set-id annotation and lets the finalizer go. Other errors still requeue. Fixes actions#4655
There was a problem hiding this comment.
Copilot review overview
🟡 Changes recommended
Missing Vault proxy credentials still lose their NotFound error and can leave deletion stuck.
Review effort: Balanced
Findings: 1
What changed in this PR
Fixes stuck AutoscalingRunnerSet deletion when required Kubernetes credentials disappear.
Changes:
- Preserves Kubernetes errors through resolver wrapping.
- Releases finalizers on dependency
NotFound. - Adds deletion and retry coverage.
| File | Description |
|---|---|
secretresolver/secret_resolver.go |
Preserves underlying resolution errors. |
autoscalingrunnerset_controller.go |
Handles missing client dependencies during deletion. |
autoscalingrunnerset_controller_test.go |
Tests terminal and retryable failures. |
💡 Add a code-review agent skill or configure MCP servers for context-aware, tailored reviews. Learn more in the docs.
resolverForObject wrapped the ToHTTPProxyConfig error with %v, so a deleted vault proxy credential secret still left the AutoscalingRunnerSet stuck in Terminating. Wrap it with %w and cover the path with an envtest.
A Kubernetes NotFound only survived for the k8s driver, so an AutoscalingRunnerSet using Azure Key Vault stayed stuck in Terminating when its secret was deleted. secretresolver now exports ErrNotFound. The k8s paths (GitHub config secret, proxy credential secret, vault proxy secret, TLS config map) wrap a Kubernetes NotFound with it, and the vault resolver wraps an Azure Key Vault 404 (azcore.ResponseError). Other vault errors keep their previous message only, as before. Deletion checks errors.Is(err, secretresolver.ErrNotFound) instead of kerrors.IsNotFound. Signed-off-by: Ankit Jha <[email protected]>
…t secrets Signed-off-by: Ankit Jha <[email protected]>
| // wrapVaultNotFound tags an Azure Key Vault 404; other vault errors keep their previous message only. | ||
| func wrapVaultNotFound(err error) error { | ||
| var responseErr *azcore.ResponseError | ||
| if errors.As(err, &responseErr) && responseErr.StatusCode == http.StatusNotFound { |
There was a problem hiding this comment.
| if errors.As(err, &responseErr) && responseErr.StatusCode == http.StatusNotFound { | |
| if errors.As(err, &responseErr) && responseErr.StatusCode == http.StatusNotFound && responseErr.ErrorCode == "SecretNotFound" { |
There was a problem hiding this comment.
Applied in 0918b6f, thanks. A 404 without SecretNotFound (for example a missing vault) now requeues too, and there is a test case for it.
| const ErrNotFound = secretResolverError("not found") | ||
|
|
||
| // wrapK8sNotFound tags a Kubernetes NotFound so callers need no knowledge of the driver. | ||
| func wrapK8sNotFound(err error) error { |
There was a problem hiding this comment.
I'd rename this to wrapKubernetesError(err error)
| } | ||
|
|
||
| // wrapVaultNotFound tags an Azure Key Vault 404; other vault errors keep their previous message only. | ||
| func wrapVaultNotFound(err error) error { |
There was a problem hiding this comment.
I'd rename this to: wrapAzureKeyVaultError
If in the future another vault provider is configured, this implementation would not be valid, but the name is generic
There was a problem hiding this comment.
Renamed in 0918b6f. Agreed, the name should say it only understands Azure Key Vault errors.
… vault errors unchanged GetActionsService is tested against a fake client for a missing GitHub config secret, proxy credential secret, TLS config map and vault proxy credential secret, and a Forbidden read must not count as not found. wrapVaultNotFound now returns non-404 errors as they are instead of re-formatting them. Signed-off-by: Ankit Jha <[email protected]>
…er their driver Signed-off-by: Ankit Jha <[email protected]>
| Expect(k8sClient.Delete(ctx, autoscalingRunnerSet)).To(Succeed(), "failed to delete AutoScalingRunnerSet") | ||
|
|
||
| Eventually( | ||
| arsGone, |


Fixes #4655
Problem
When the
githubConfigSecretis deleted before its AutoscalingRunnerSet,deleteRunnerScaleSetcan't build an Actions client, so it returns that error.cleanUpResourcesandReconcilepass it up and the finalizer is never removed. The AutoscalingRunnerSet then stays inTerminatingforever, and so does anyhelm uninstallor namespace deletion waiting on it.Today that error can't be told apart from a transient failure, because
secretresolverformats the underlying error away:failed to get kubernetes secret: %qdropserr, andGetActionsServicewraps with%v. With Azure Key Vault, a missing secret comes back as anazcore.ResponseError, which is not a Kubernetes error at all.Fix
secretresolver.ErrNotFound: a new exported sentinel of typesecretResolverError, as suggested in review. Each driver wraps its own "missing" error with it:NotFoundfor the GitHub config secret, the proxy credential secret, the vault proxy secret or the TLS config map.azcore.ResponseErrorwithStatusCode == 404andErrorCode == "SecretNotFound". Both are checked, so a missing vault, a 403 or a throttled read still requeues.The resolver's
%vwraps become%w, so the sentinel and the original error both survive the chain.deleteRunnerScaleSet: onerrors.Is(err, secretresolver.ErrNotFound)it does three things:runnerScaleSetId, saying the scale set must be deleted manually from the Actions service;runner-scale-set-idannotation;This matches the existing contract for a manually removed annotation. The annotation patch moved into a small helper that both paths share.
Every other error (invalid secret contents,
Forbidden, API server errors, vault throttling, Actions 5xx) is still returned and requeued.Notes for review:
%vto%wexposes Kubernetes errors to every caller ofGetActionsServiceandGetAppConfig. I checked all of them in the four controllers and the unregistration queue: none branches onIsNotFoundorIgnoreNotFoundfor a resolver error. TheIgnoreNotFoundcalls apply only to each controller's ownGetof the reconciled object.actions.github.comcontrollers have no event recorder today, and the controller chart only grantseventsin the leader-election role. Adding one would needmain.gowiring and RBAC changes in both charts, which seemed out of scope. Happy to add it if you want it here.Tests
secretresolverunit tests:GetActionsServiceagainst a fake client, for a missing GitHub config secret, proxy credential secret, TLS config map and vault proxy credential secret. Each must satisfyerrors.Is(err, ErrNotFound), and aForbiddenmust not.removes the finalizer instead of retrying forever(fails on master)keeps the finalizer when the Actions client fails for any other reasonvaultConfig.proxyafter its credential secret is goneLocal runs:
go test ./controllers/actions.github.com/...with envtest 1.37: passgo vet: cleangolangci-lintv2.13.2 with the repo config: 0 new issues