remove secret if corrupted

This commit is contained in:
Nikola Jokic 2025-07-30 19:49:17 +02:00
parent 6ba546a0af
commit 07845ad770
No known key found for this signature in database
GPG Key ID: E4104494F9B8DDF6
1 changed files with 7 additions and 2 deletions

View File

@ -217,8 +217,13 @@ func (r *EphemeralRunnerReconciler) Reconcile(ctx context.Context, req ctrl.Requ
log.Info("Updating ephemeral runner status with runnerId and runnerName") log.Info("Updating ephemeral runner status with runnerId and runnerName")
runnerID, err := strconv.Atoi(string(secret.Data["runnerId"])) runnerID, err := strconv.Atoi(string(secret.Data["runnerId"]))
if err != nil { if err != nil {
// TODO: Delete secret log.Error(err, "Runner config secret is corrupted: missing runnerId")
return ctrl.Result{}, fmt.Errorf("runner id is not present in the secret") log.Info("Deleting corrupted runner config secret")
if err := r.Delete(ctx, secret); err != nil {
return ctrl.Result{}, fmt.Errorf("failed to delete the corrupted runner config secret")
}
log.Info("Corrupted runner config secret has been deleted")
return ctrl.Result{Requeue: true}, nil
} }
if err := patchSubResource(ctx, r.Status(), ephemeralRunner, func(obj *v1alpha1.EphemeralRunner) { if err := patchSubResource(ctx, r.Status(), ephemeralRunner, func(obj *v1alpha1.EphemeralRunner) {