diff --git a/cmd/sriov-network-operator-config-cleanup/cleanup.go b/cmd/sriov-network-operator-config-cleanup/cleanup.go index c2a5e0c05..ae13f93d6 100644 --- a/cmd/sriov-network-operator-config-cleanup/cleanup.go +++ b/cmd/sriov-network-operator-config-cleanup/cleanup.go @@ -54,6 +54,9 @@ func runCleanupCmd(cmd *cobra.Command, args []string) error { watcher, err := sriovcs.SriovOperatorConfigs(namespace).Watch(ctx, metav1.ListOptions{Watch: true}) defer watcher.Stop() if err != nil { + if errors.IsNotFound(err) { + return nil + } setupLog.Error(err, "failed creating 'default' SriovOperatorConfig object watcher") return err } diff --git a/cmd/sriov-network-operator-config-cleanup/cleanup_test.go b/cmd/sriov-network-operator-config-cleanup/cleanup_test.go index 95c87fda2..7be1e4a5b 100644 --- a/cmd/sriov-network-operator-config-cleanup/cleanup_test.go +++ b/cmd/sriov-network-operator-config-cleanup/cleanup_test.go @@ -40,7 +40,6 @@ var ( ) var _ = Describe("cleanup", Ordered, func() { - BeforeAll(func() { By("Create SriovOperatorConfig controller k8s objs") config := getDefaultSriovOperatorConfig() @@ -161,7 +160,6 @@ func newConfigController() *configController { } func (c *configController) start() { - c.wg.Add(1) go func() { defer c.wg.Done() diff --git a/controllers/sriovoperatorconfig_controller.go b/controllers/sriovoperatorconfig_controller.go index 2c8663911..437d7b9d9 100644 --- a/controllers/sriovoperatorconfig_controller.go +++ b/controllers/sriovoperatorconfig_controller.go @@ -459,12 +459,9 @@ func (r *SriovOperatorConfigReconciler) handleSriovOperatorConfigDeletion(ctx co return reconcile.Result{}, err } // remove our finalizer from the list and update it. - var found bool - defaultConfig.ObjectMeta.Finalizers, found = sriovnetworkv1.RemoveString(sriovnetworkv1.OPERATORCONFIGFINALIZERNAME, defaultConfig.ObjectMeta.Finalizers) - if found { - if err := r.Update(ctx, defaultConfig); err != nil { - return reconcile.Result{}, err - } + defaultConfig.ObjectMeta.Finalizers, _ = sriovnetworkv1.RemoveString(sriovnetworkv1.OPERATORCONFIGFINALIZERNAME, defaultConfig.ObjectMeta.Finalizers) + if err := r.Update(ctx, defaultConfig); err != nil { + return reconcile.Result{}, err } }