diff --git a/internal/controller/clientprofile_controller.go b/internal/controller/clientprofile_controller.go index e47c3950..196778cc 100644 --- a/internal/controller/clientprofile_controller.go +++ b/internal/controller/clientprofile_controller.go @@ -130,6 +130,10 @@ func (r *ClientProfileReconciler) Reconcile(ctx context.Context, req ctrl.Reques func (r *ClientProfileReconcile) reconcile() error { if err := r.loadAndValidate(); err != nil { + if client.IgnoreNotFound(err) == nil { + r.log.Info("Resources for reconciling clientprofile is not found. Object(s) might have been deleted.") + return nil + } return err } diff --git a/internal/controller/driver_controller.go b/internal/controller/driver_controller.go index ba0616a9..f341f7f2 100644 --- a/internal/controller/driver_controller.go +++ b/internal/controller/driver_controller.go @@ -226,6 +226,10 @@ func (r *DriverReconciler) Reconcile(ctx context.Context, req ctrl.Request) (ctr func (r *driverReconcile) reconcile() error { // Load the driver desired state based on driver resource, operator config resource and default values. if err := r.LoadAndValidateDesiredState(); err != nil { + if client.IgnoreNotFound(err) == nil { + r.log.Info("Resources for reconciling driver is not found. Object(s) might have been deleted.") + return nil + } return err } @@ -255,7 +259,7 @@ func (r *driverReconcile) LoadAndValidateDesiredState() error { // (Can happen if a driver with an identical name was created in a different namespace) csiDriver := storagev1.CSIDriver{} csiDriver.Name = r.driver.Name - if err := r.Get(r.ctx, client.ObjectKeyFromObject(&csiDriver), &csiDriver); client.IgnoreNotFound(err) != nil { + if err := r.Get(r.ctx, client.ObjectKeyFromObject(&csiDriver), &csiDriver); err != nil { r.log.Error(err, "Failed to query the existence of a CSI Driver") return err } @@ -296,7 +300,7 @@ func (r *driverReconcile) LoadAndValidateDesiredState() error { opConfig := csiv1a1.OperatorConfig{} opConfig.Name = operatorConfigName opConfig.Namespace = operatorNamespace - if err := r.Get(r.ctx, client.ObjectKeyFromObject(&opConfig), &opConfig); client.IgnoreNotFound(err) != nil { + if err := r.Get(r.ctx, client.ObjectKeyFromObject(&opConfig), &opConfig); err != nil { r.log.Error(err, "Unable to load operatorconfig.csi.ceph.io", "name", client.ObjectKeyFromObject(&opConfig)) return err }