Skip to content

Commit

Permalink
Fix running reconcileDelete on new instance
Browse files Browse the repository at this point in the history
dda3b1e
refactored code and introduce the situation that on the just created
new instance the reconcileDelete method runs which we can see from
the operator log:

~~~
2024-10-08T21:45:28Z    INFO    ceilometer-resource     default {"name": "ceilometer"}
2024-10-08T21:45:28Z    INFO    ceilometer-resource     validate create {"name": "ceilometer"}
2024-10-08T21:45:28Z    INFO    Controllers.Ceilometer  Reconciling Service delete      {"controller": "ceilometer", "controllerGroup": "telemetry.openstack.org", "controllerKind": "Ceilometer", "Ceilometer": {"name":"ceilometer","namespace":"openstack-kuttl-tests"}, "namespace": "openstack-kuttl-tests", "name": "ceilometer", "reconcileID": "c205bb0b-1c34-4350-969a-06c0925e0cdf"}
~~~

This change moves reconcileDelete in its own condition.

Signed-off-by: Martin Schuppert <mschuppert@redhat.com>
  • Loading branch information
stuggi committed Oct 9, 2024
1 parent a9bf21a commit fa9c222
Showing 1 changed file with 6 additions and 1 deletion.
7 changes: 6 additions & 1 deletion controllers/ceilometer_controller.go
Original file line number Diff line number Diff line change
Expand Up @@ -203,7 +203,12 @@ func (r *CeilometerReconciler) Reconcile(ctx context.Context, req ctrl.Request)
}

// If we're not deleting this and the service object doesn't have our finalizer, add it.
if !instance.DeletionTimestamp.IsZero() && controllerutil.AddFinalizer(instance, helper.GetFinalizer()) || isNewInstance {
if instance.DeletionTimestamp.IsZero() && controllerutil.AddFinalizer(instance, helper.GetFinalizer()) || isNewInstance {
return ctrl.Result{}, nil
}

// Handle service delete
if !instance.DeletionTimestamp.IsZero() {
return r.reconcileDelete(ctx, instance, helper)
}

Expand Down

0 comments on commit fa9c222

Please sign in to comment.