Skip to content

Commit

Permalink
fix: when delete resource if no CRD in the cluster
Browse files Browse the repository at this point in the history
Signed-off-by: Wen Zhou <[email protected]>
  • Loading branch information
zdtsw committed Jun 7, 2024
1 parent bd9b83c commit 0377ac6
Showing 1 changed file with 4 additions and 1 deletion.
5 changes: 4 additions & 1 deletion pkg/deploy/deploy.go
Original file line number Diff line number Diff line change
Expand Up @@ -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"
Expand Down Expand Up @@ -212,7 +213,6 @@ func manageResource(ctx context.Context, cli client.Client, obj *unstructured.Un
if client.IgnoreNotFound(err) != nil {
return err
}

if !enabled {
return handleDisabledComponent(ctx, cli, found, componentName)
}
Expand Down Expand Up @@ -359,6 +359,9 @@ func getResource(ctx context.Context, cli client.Client, obj *unstructured.Unstr
found.SetGroupVersionKind(obj.GroupVersionKind())
err := cli.Get(ctx, types.NamespacedName{Name: obj.GetName(), Namespace: obj.GetNamespace()}, found)
if err != nil {
if errors.Is(err, &meta.NoKindMatchError{}) {
return nil, nil // ignore mising CRD error
}
return nil, err
}
return found, nil
Expand Down

0 comments on commit 0377ac6

Please sign in to comment.