diff --git a/pkg/deploy/deploy.go b/pkg/deploy/deploy.go index c2b08e1e90f..4279f11e20d 100644 --- a/pkg/deploy/deploy.go +++ b/pkg/deploy/deploy.go @@ -32,6 +32,7 @@ import ( "strings" "golang.org/x/exp/maps" + "k8s.io/apimachinery/pkg/api/meta" metav1 "k8s.io/apimachinery/pkg/apis/meta/v1" "k8s.io/apimachinery/pkg/apis/meta/v1/unstructured" "k8s.io/apimachinery/pkg/types" @@ -209,7 +210,7 @@ func manageResource(ctx context.Context, cli client.Client, obj *unstructured.Un // Return if error getting resource in cluster found, err := getResource(ctx, cli, obj) - if client.IgnoreNotFound(err) != nil { + if err != nil { return err } @@ -357,8 +358,13 @@ func getResource(ctx context.Context, cli client.Client, obj *unstructured.Unstr found := &unstructured.Unstructured{} // Setting gvk is required to do Get request found.SetGroupVersionKind(obj.GroupVersionKind()) - err := cli.Get(ctx, types.NamespacedName{Name: obj.GetName(), Namespace: obj.GetNamespace()}, found) - if err != nil { + if err := cli.Get(ctx, types.NamespacedName{Name: obj.GetName(), Namespace: obj.GetNamespace()}, found); err != nil { + if errors.Is(err, &meta.NoKindMatchError{}) { + return nil, nil // ignore mising CRD error + } + if client.IgnoreNotFound(err) == nil { + return nil, nil // not found resource + } return nil, err } return found, nil