diff options
author | 2021-10-01 09:35:35 +0200 | |
---|---|---|
committer | 2021-10-04 12:06:25 +0200 | |
commit | bbeac9a596074d0af6e5be60448567517978a388 (patch) | |
tree | a3e0203797e00e6db9e31001e316e238a77d775a /src/k8splugin/plugins/namespace | |
parent | dc62323aa7f6782d69c7ac6509eb270e86ef31bd (diff) |
Further fixes for config delete operation
The issue was related with insufficient handlijg of
different versions of config vs their delete operation
handled by the plugin.
Issue-ID: MULTICLOUD-1332
Signed-off-by: Lukasz Rajewski <lukasz.rajewski@orange.com>
Change-Id: I90d896720fa89ebd66cb3290cdd9401272f5e3fd
Diffstat (limited to 'src/k8splugin/plugins/namespace')
-rw-r--r-- | src/k8splugin/plugins/namespace/plugin.go | 13 |
1 files changed, 9 insertions, 4 deletions
diff --git a/src/k8splugin/plugins/namespace/plugin.go b/src/k8splugin/plugins/namespace/plugin.go index 8732442e..6c6d1f6c 100644 --- a/src/k8splugin/plugins/namespace/plugin.go +++ b/src/k8splugin/plugins/namespace/plugin.go @@ -21,10 +21,10 @@ import ( pkgerrors "github.com/pkg/errors" coreV1 "k8s.io/api/core/v1" - metaV1 "k8s.io/apimachinery/pkg/apis/meta/v1" - "k8s.io/apimachinery/pkg/runtime/schema" "k8s.io/apimachinery/pkg/api/meta" + metaV1 "k8s.io/apimachinery/pkg/apis/meta/v1" "k8s.io/apimachinery/pkg/runtime" + "k8s.io/apimachinery/pkg/runtime/schema" "k8s.io/client-go/kubernetes" "k8s.io/client-go/rest" @@ -60,7 +60,12 @@ func (p namespacePlugin) Create(yamlFilePath string, namespace string, client pl Name: namespace, }, } - _, err := client.GetStandardClient().CoreV1().Namespaces().Create(context.TODO(), namespaceObj, metaV1.CreateOptions{}) + existingNs, err := client.GetStandardClient().CoreV1().Namespaces().Get(context.TODO(), namespace, metaV1.GetOptions{}) + if err == nil && len(existingNs.ManagedFields) > 0 && existingNs.ManagedFields[0].Manager == "k8plugin" { + log.Printf("Namespace (%s) already ensured by plugin. Skip", namespace) + return namespace, nil + } + _, err = client.GetStandardClient().CoreV1().Namespaces().Create(context.TODO(), namespaceObj, metaV1.CreateOptions{}) if err != nil { return "", pkgerrors.Wrap(err, "Create Namespace error") } @@ -128,5 +133,5 @@ func (p namespacePlugin) List(gvk schema.GroupVersionKind, namespace string, cli func (p namespacePlugin) Update(yamlFilePath string, namespace string, client plugin.KubernetesConnector) (string, error) { - return "", nil + return namespace, nil } |