From 5ec41c37b6a8c6235596c345fbfc6598142e35cc Mon Sep 17 00:00:00 2001 From: Oliver Walsh Date: Wed, 27 Nov 2024 22:52:09 +0000 Subject: [PATCH] OpenStackClient: wait for pod deletion to complete when recreating pod --- controllers/client/openstackclient_controller.go | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/controllers/client/openstackclient_controller.go b/controllers/client/openstackclient_controller.go index d8d2eafc1..dabcfb8f5 100644 --- a/controllers/client/openstackclient_controller.go +++ b/controllers/client/openstackclient_controller.go @@ -308,6 +308,10 @@ func (r *OpenStackClientReconciler) Reconcile(ctx context.Context, req ctrl.Requ spec := openstackclient.ClientPodSpec(ctx, instance, helper, configVarsHash) op, err := controllerutil.CreateOrPatch(ctx, r.Client, osclient, func() error { + if !osclient.ObjectMeta.DeletionTimestamp.IsZero() { + // Still deleting from a previous reconcile + return nil + } isPodUpdate := !osclient.ObjectMeta.CreationTimestamp.IsZero() if !isPodUpdate { osclient.Spec = spec @@ -349,6 +353,10 @@ func (r *OpenStackClientReconciler) Reconcile(ctx context.Context, req ctrl.Requ return ctrl.Result{}, fmt.Errorf("Failed to create or update pod %s: %w", osclient.Name, err) } + if !osclient.ObjectMeta.DeletionTimestamp.IsZero() { + Log.Info("OpenStackClient pod deletion pending") + return ctrl.Result{Requeue: true}, nil + } if err != nil { instance.Status.Conditions.Set(condition.FalseCondition(