Fix ensureNamespace behavior failing on missing ns 31/98831/4
authorKonrad Bańka <k.banka@samsung.com>
Tue, 26 Nov 2019 06:01:30 +0000 (07:01 +0100)
committerKonrad Bańka <k.banka@samsung.com>
Wed, 11 Dec 2019 05:39:57 +0000 (06:39 +0100)
The behavior is now amended to ignore namespace not found
errors.

Signed-off-by: Konrad Bańka <k.banka@samsung.com>
Issue-ID: MULTICLOUD-955
Change-Id: Ifc180eca9e8195c38f0b0f268dd142a329405d3d
Signed-off-by: Kiran Kamineni <kiran.k.kamineni@intel.com>
src/k8splugin/internal/app/client.go

index 78477a8..d3e5081 100644 (file)
@@ -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,