From 07845ad770d34ecc4a9b9acec542426b1070eb92 Mon Sep 17 00:00:00 2001 From: Nikola Jokic Date: Wed, 30 Jul 2025 19:49:17 +0200 Subject: [PATCH] remove secret if corrupted --- .../actions.github.com/ephemeralrunner_controller.go | 9 +++++++-- 1 file changed, 7 insertions(+), 2 deletions(-) diff --git a/controllers/actions.github.com/ephemeralrunner_controller.go b/controllers/actions.github.com/ephemeralrunner_controller.go index 549c367a..0590627f 100644 --- a/controllers/actions.github.com/ephemeralrunner_controller.go +++ b/controllers/actions.github.com/ephemeralrunner_controller.go @@ -217,8 +217,13 @@ func (r *EphemeralRunnerReconciler) Reconcile(ctx context.Context, req ctrl.Requ log.Info("Updating ephemeral runner status with runnerId and runnerName") runnerID, err := strconv.Atoi(string(secret.Data["runnerId"])) if err != nil { - // TODO: Delete secret - return ctrl.Result{}, fmt.Errorf("runner id is not present in the secret") + log.Error(err, "Runner config secret is corrupted: missing runnerId") + 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) {