Delete config secret when listener pod gets deleted

This should fix https://github.com/actions/actions-runner-controller/issues/4029.
When the github token gets updated, and the old one expires, the listener pod dies. Only to be recreated with the existing listener config that holds the now expired token.
This PR fixes that by deleting the config secret as well, so the reconciler recreates it with the updated token.
This commit is contained in:
Wim Fournier 2025-04-11 13:02:33 +02:00 committed by GitHub
parent 15990d492d
commit 7ee7634283
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
1 changed files with 13 additions and 0 deletions

View File

@ -260,6 +260,19 @@ func (r *AutoscalingListenerReconciler) Reconcile(ctx context.Context, req ctrl.
log.Error(err, "Unable to delete the listener pod", "namespace", listenerPod.Namespace, "name", listenerPod.Name)
return ctrl.Result{}, err
}
// delete the listener config secret as well, so it gets recreated when the listener pod is recreated, with any new data if it exists
var configSecret corev1.Secret
err := r.Get(ctx, types.NamespacedName{Namespace: autoscalingListener.Namespace, Name: scaleSetListenerConfigName(autoscalingListener)}, &configSecret)
switch {
case err == nil:
if configSecret.ObjectMeta.DeletionTimestamp.IsZero() {
log.Info("Deleting the listener config secret")
if err := r.Delete(ctx, &configSecret); err != nil {
return ctrl.Result{}, fmt.Errorf("failed to delete listener config secret: %w", err)
}
}
}
}
return ctrl.Result{}, nil
case cs.State.Running != nil: