From d35491b7dc4a85b546179f8d7f00a389bfbded49 Mon Sep 17 00:00:00 2001 From: Konrad Bańka Date: Tue, 26 Nov 2019 07:01:30 +0100 Subject: Fix ensureNamespace behavior failing on missing ns MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit The behavior is now amended to ignore namespace not found errors. Signed-off-by: Konrad Bańka Issue-ID: MULTICLOUD-955 Change-Id: Ifc180eca9e8195c38f0b0f268dd142a329405d3d Signed-off-by: Kiran Kamineni --- src/k8splugin/internal/app/client.go | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) (limited to 'src/k8splugin/internal/app/client.go') diff --git a/src/k8splugin/internal/app/client.go b/src/k8splugin/internal/app/client.go index 78477a82..d3e5081a 100644 --- a/src/k8splugin/internal/app/client.go +++ b/src/k8splugin/internal/app/client.go @@ -15,6 +15,7 @@ package app import ( "os" + "strings" "time" "github.com/onap/multicloud-k8s/src/k8splugin/internal/connection" @@ -116,7 +117,9 @@ func (k *KubernetesClient) ensureNamespace(namespace string) error { }, }, namespace, k) - if err != nil { + // Check for errors getting the namespace while ignoring errors where the namespace does not exist + // Error message when namespace does not exist: "namespaces "namespace-name" not found" + if err != nil && strings.Contains(err.Error(), "not found") == false { log.Error("Error checking for namespace", log.Fields{ "error": err, "namespace": namespace, -- cgit 1.2.3-korg