Skip to content

Commit 2587c60

Browse files
iPraveenPariharnb-ohad
authored andcommitted
csi: add snapshotmetadataservice crd existence check
This commit adds a check for snapshotmetadataservice crd existence before checking if the CR exists. This is done to avoid unwanted error logs when the CRD is not present in the cluster. Signed-off-by: Praveen M <m.praveen@ibm.com>
1 parent 7eedadc commit 2587c60

File tree

1 file changed

+2
-1
lines changed

1 file changed

+2
-1
lines changed

internal/controller/driver_controller.go

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -34,6 +34,7 @@ import (
3434
corev1 "k8s.io/api/core/v1"
3535
storagev1 "k8s.io/api/storage/v1"
3636
k8serrors "k8s.io/apimachinery/pkg/api/errors"
37+
"k8s.io/apimachinery/pkg/api/meta"
3738
metav1 "k8s.io/apimachinery/pkg/apis/meta/v1"
3839
"k8s.io/apimachinery/pkg/runtime"
3940
"k8s.io/apimachinery/pkg/util/intstr"
@@ -232,7 +233,7 @@ func (r *DriverReconciler) Reconcile(ctx context.Context, req ctrl.Request) (ctr
232233
func (r *driverReconcile) hasSnapshotMetadataServiceCr() (bool, error) {
233234
sms := &sm.SnapshotMetadataService{}
234235
sms.Name = r.driver.Name
235-
if err := r.Get(r.ctx, client.ObjectKeyFromObject(sms), sms); client.IgnoreNotFound(err) != nil {
236+
if err := r.Get(r.ctx, client.ObjectKeyFromObject(sms), sms); !meta.IsNoMatchError(err) && client.IgnoreNotFound(err) != nil {
236237
return false, fmt.Errorf("failed to get SnapshotMetadataService resource: %w", err)
237238
}
238239

0 commit comments

Comments
 (0)