mirror of
https://github.com/actions-runner-controller/actions-runner-controller.git
synced 2026-10-04 22:26:04 +02:00
Release AutoscalingRunnerSet deletion when the GitHub config secret is gone (#4688)
Signed-off-by: Ankit Jha <ankit.jha@tradomate.one>
This commit is contained in:
@@ -27,6 +27,7 @@ import (
|
||||
|
||||
"github.com/actions/actions-runner-controller/apis/actions.github.com/v1alpha1"
|
||||
"github.com/actions/actions-runner-controller/build"
|
||||
"github.com/actions/actions-runner-controller/controllers/actions.github.com/secretresolver"
|
||||
"github.com/actions/scaleset"
|
||||
"github.com/go-logr/logr"
|
||||
corev1 "k8s.io/api/core/v1"
|
||||
@@ -1220,7 +1221,17 @@ func (r *AutoscalingRunnerSetReconciler) deleteRunnerScaleSet(ctx context.Contex
|
||||
}
|
||||
|
||||
actionsClient, err := r.GetActionsService(ctx, autoscalingRunnerSet)
|
||||
if err != nil {
|
||||
switch {
|
||||
case errors.Is(err, secretresolver.ErrNotFound):
|
||||
// A secret or config map the client is built from is gone, from Kubernetes or the vault. Retrying cannot bring it back,
|
||||
// so release the autoscaling runner set instead of leaving it stuck in Terminating.
|
||||
logger.Error(
|
||||
err,
|
||||
"A secret or config map required to reach the Actions service no longer exists in Kubernetes or the configured vault. The runner scale set cannot be deregistered and must be deleted manually from the Actions service",
|
||||
"runnerScaleSetId", runnerScaleSetID,
|
||||
)
|
||||
return r.removeRunnerScaleSetIDAnnotation(ctx, autoscalingRunnerSet, runnerScaleSetID, logger)
|
||||
case err != nil:
|
||||
logger.Error(err, "Failed to initialize Actions service client for updating a existing runner scale set")
|
||||
return err
|
||||
}
|
||||
@@ -1235,11 +1246,7 @@ func (r *AutoscalingRunnerSetReconciler) deleteRunnerScaleSet(ctx context.Contex
|
||||
return err
|
||||
}
|
||||
|
||||
original := autoscalingRunnerSet.DeepCopy()
|
||||
delete(autoscalingRunnerSet.Annotations, runnerScaleSetIDAnnotationKey)
|
||||
|
||||
if err := r.Patch(ctx, autoscalingRunnerSet, client.MergeFrom(original)); err != nil {
|
||||
logger.Error(err, "Failed to remove runner scale set ID annotation after deleting the runner scale set", "runnerScaleSetId", runnerScaleSetID)
|
||||
if err := r.removeRunnerScaleSetIDAnnotation(ctx, autoscalingRunnerSet, runnerScaleSetID, logger); err != nil {
|
||||
return err
|
||||
}
|
||||
|
||||
@@ -1247,6 +1254,18 @@ func (r *AutoscalingRunnerSetReconciler) deleteRunnerScaleSet(ctx context.Contex
|
||||
return nil
|
||||
}
|
||||
|
||||
func (r *AutoscalingRunnerSetReconciler) removeRunnerScaleSetIDAnnotation(ctx context.Context, autoscalingRunnerSet *v1alpha1.AutoscalingRunnerSet, runnerScaleSetID int, logger logr.Logger) error {
|
||||
original := autoscalingRunnerSet.DeepCopy()
|
||||
delete(autoscalingRunnerSet.Annotations, runnerScaleSetIDAnnotationKey)
|
||||
|
||||
if err := r.Patch(ctx, autoscalingRunnerSet, client.MergeFrom(original)); err != nil {
|
||||
logger.Error(err, "Failed to remove runner scale set ID annotation", "runnerScaleSetId", runnerScaleSetID)
|
||||
return err
|
||||
}
|
||||
|
||||
return nil
|
||||
}
|
||||
|
||||
func (r *AutoscalingRunnerSetReconciler) createEphemeralRunnerSet(ctx context.Context, autoscalingRunnerSet *v1alpha1.AutoscalingRunnerSet, log logr.Logger) (ctrl.Result, error) {
|
||||
r.ResourceCache.ephemeralRunnerSet.Delete(autoscalingRunnerSet)
|
||||
desiredRunnerSet, err := r.newEphemeralRunnerSet(autoscalingRunnerSet)
|
||||
|
||||
Reference in New Issue
Block a user