Skip to content

Commit

Permalink
Fixing cleanup watcher 'NotFound' object and some more minor fixes
Browse files Browse the repository at this point in the history
Signed-off-by: Ido Heyvi <[email protected]>
  • Loading branch information
heyvister1 committed Oct 27, 2024
1 parent 797755e commit 4a612a7
Show file tree
Hide file tree
Showing 3 changed files with 6 additions and 8 deletions.
3 changes: 3 additions & 0 deletions cmd/sriov-network-operator-config-cleanup/cleanup.go
Original file line number Diff line number Diff line change
Expand Up @@ -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
}
Expand Down
2 changes: 0 additions & 2 deletions cmd/sriov-network-operator-config-cleanup/cleanup_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,6 @@ var (
)

var _ = Describe("cleanup", Ordered, func() {

BeforeAll(func() {
By("Create SriovOperatorConfig controller k8s objs")
config := getDefaultSriovOperatorConfig()
Expand Down Expand Up @@ -161,7 +160,6 @@ func newConfigController() *configController {
}

func (c *configController) start() {

c.wg.Add(1)
go func() {
defer c.wg.Done()
Expand Down
9 changes: 3 additions & 6 deletions controllers/sriovoperatorconfig_controller.go
Original file line number Diff line number Diff line change
Expand Up @@ -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
}
}

Expand Down

0 comments on commit 4a612a7

Please sign in to comment.