Skip to content

Commit

Permalink
Merge pull request #2013 from replicatedhq/divolgin/crds
Browse files Browse the repository at this point in the history
Use the correct namespace when deleting app components
  • Loading branch information
divolgin committed Jul 28, 2021
2 parents 9d1af3c + 35d6251 commit 71e37dd
Showing 1 changed file with 13 additions and 5 deletions.
18 changes: 13 additions & 5 deletions kotsadm/operator/pkg/client/deploy.go
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,7 @@ import (
"k8s.io/apimachinery/pkg/api/meta"
metav1 "k8s.io/apimachinery/pkg/apis/meta/v1"
k8slabels "k8s.io/apimachinery/pkg/labels"
"k8s.io/apimachinery/pkg/runtime"
k8sruntime "k8s.io/apimachinery/pkg/runtime"
k8sschema "k8s.io/apimachinery/pkg/runtime/schema"
"k8s.io/apimachinery/pkg/util/sets"
Expand Down Expand Up @@ -135,16 +136,23 @@ func (c *Client) diffAndRemovePreviousManifests(applicationManifests Application
continue
}

obj, gvk, err := parseK8sYaml([]byte(previous.spec))
if err != nil {
log.Printf("deleting unidentified manifest. unable to parse error: %s", err.Error())
}

group := ""
kind := ""
namespace := targetNamespace
name := ""

obj, gvk, err := parseK8sYaml([]byte(previous.spec))
if err != nil {
log.Printf("deleting unidentified manifest. unable to parse error: %s", err.Error())
if runtime.IsNotRegisteredError(errors.Cause(err)) {
_, o := GetGVKWithNameAndNs([]byte(previous.spec), targetNamespace)
if o.Metadata.Namespace != "" {
namespace = o.Metadata.Namespace
}
name = o.Metadata.Name
}
}

if obj != nil {
if n, _ := metadataAccessor.Namespace(obj); n != "" {
namespace = n
Expand Down

0 comments on commit 71e37dd

Please sign in to comment.