Skip to content

Commit

Permalink
OpenStackClient: wait for pod deletion to complete when recreating pod
Browse files Browse the repository at this point in the history
  • Loading branch information
olliewalsh committed Nov 27, 2024
1 parent 4c23add commit 5ec41c3
Showing 1 changed file with 8 additions and 0 deletions.
8 changes: 8 additions & 0 deletions controllers/client/openstackclient_controller.go
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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(
Expand Down

0 comments on commit 5ec41c3

Please sign in to comment.