Skip to content

Commit

Permalink
Merge pull request #879 from bryanv/bryanv/use-ignore-not-found-helper
Browse files Browse the repository at this point in the history
🌱 Simplify with controller-runtime IgnoreNotFound() helper
  • Loading branch information
bryanv authored Feb 5, 2025
2 parents 7105531 + 6f87a47 commit 066eb82
Show file tree
Hide file tree
Showing 2 changed files with 2 additions and 9 deletions.
6 changes: 1 addition & 5 deletions controllers/infra/configmap/infra_configmap_controller.go
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,6 @@ import (

"github.com/go-logr/logr"
corev1 "k8s.io/api/core/v1"
apierrors "k8s.io/apimachinery/pkg/api/errors"
"sigs.k8s.io/controller-runtime/pkg/client"
"sigs.k8s.io/controller-runtime/pkg/controller"
"sigs.k8s.io/controller-runtime/pkg/event"
Expand Down Expand Up @@ -130,10 +129,7 @@ func (r *Reconciler) reconcileWcpClusterConfig(ctx context.Context, req ctrl.Req

cm := &corev1.ConfigMap{}
if err := r.Get(ctx, req.NamespacedName, cm); err != nil {
if !apierrors.IsNotFound(err) {
return err
}
return nil
return client.IgnoreNotFound(err)
}

clusterConfig, err := ParseWcpClusterConfig(cm.Data)
Expand Down
5 changes: 1 addition & 4 deletions controllers/virtualmachine/volume/volume_controller.go
Original file line number Diff line number Diff line change
Expand Up @@ -218,10 +218,7 @@ func (r *Reconciler) Reconcile(ctx context.Context, request ctrl.Request) (_ ctr

vm := &vmopv1.VirtualMachine{}
if err := r.Get(ctx, request.NamespacedName, vm); err != nil {
if apierrors.IsNotFound(err) {
return reconcile.Result{}, nil
}
return reconcile.Result{}, err
return ctrl.Result{}, client.IgnoreNotFound(err)
}

volCtx := &pkgctx.VolumeContext{
Expand Down

0 comments on commit 066eb82

Please sign in to comment.