From ddc2918a4804ba49bf7190545f2cd7756f5bbda7 Mon Sep 17 00:00:00 2001 From: Nikola Jokic Date: Thu, 14 Aug 2025 17:00:48 +0200 Subject: [PATCH] Requeue if create pod returns already exists error (#4201) --- .../actions.github.com/ephemeralrunner_controller.go | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/controllers/actions.github.com/ephemeralrunner_controller.go b/controllers/actions.github.com/ephemeralrunner_controller.go index 0590627f..39f3a16e 100644 --- a/controllers/actions.github.com/ephemeralrunner_controller.go +++ b/controllers/actions.github.com/ephemeralrunner_controller.go @@ -268,13 +268,15 @@ func (r *EphemeralRunnerReconciler) Reconcile(ctx context.Context, req ctrl.Requ log.Error(err, "Failed to fetch the pod") return ctrl.Result{}, err } + log.Info("Ephemeral runner pod does not exist. Creating new ephemeral runner") - // Pod was not found. Create if the pod has never been created - log.Info("Creating new EphemeralRunner pod.") result, err := r.createPod(ctx, ephemeralRunner, secret, log) switch { case err == nil: return result, nil + case kerrors.IsAlreadyExists(err): + log.Info("Runner pod already exists. Waiting for the pod event to be received") + return ctrl.Result{Requeue: true, RequeueAfter: 5 * time.Second}, nil case kerrors.IsInvalid(err) || kerrors.IsForbidden(err): log.Error(err, "Failed to create a pod due to unrecoverable failure") errMessage := fmt.Sprintf("Failed to create the pod: %v", err)