From 5839289be6a6f3a1441d73bd9e8a8ee4bf1dc1a3 Mon Sep 17 00:00:00 2001 From: Kiran Kamineni Date: Fri, 1 Nov 2019 13:15:47 -0700 Subject: Check for err when namespace plugin returns Check for err when a namespace GET is called. This will catch any errors related to the cluster GET operations before the subsequent call is made. Issue-ID: MULTICLOUD-666 Change-Id: I47de130f7ae9e6fea627f3a881ea84b2880db886 Signed-off-by: Kiran Kamineni --- src/k8splugin/internal/app/client.go | 9 ++++++++- 1 file changed, 8 insertions(+), 1 deletion(-) diff --git a/src/k8splugin/internal/app/client.go b/src/k8splugin/internal/app/client.go index e52225d4..b75c7dfd 100644 --- a/src/k8splugin/internal/app/client.go +++ b/src/k8splugin/internal/app/client.go @@ -20,6 +20,7 @@ import ( "github.com/onap/multicloud-k8s/src/k8splugin/internal/connection" "github.com/onap/multicloud-k8s/src/k8splugin/internal/helm" + logutils "github.com/onap/multicloud-k8s/src/k8splugin/internal/logutils" "github.com/onap/multicloud-k8s/src/k8splugin/internal/plugin" pkgerrors "github.com/pkg/errors" @@ -116,11 +117,17 @@ func (k *KubernetesClient) ensureNamespace(namespace string) error { }, }, namespace, k) + if err != nil { + logutils.WithFields(err.Error(), "namespace", namespace) + return pkgerrors.Wrap(err, "Error checking for namespace: "+namespace) + } + if ns == "" { - log.Println("Creating " + namespace + " namespace") + logutils.WithFields("Creating namespace", "namespace", namespace) _, err = pluginImpl.Create("", namespace, k) if err != nil { + logutils.WithFields(err.Error(), "namespace", namespace) return pkgerrors.Wrap(err, "Error creating "+namespace+" namespace") } } -- cgit 1.2.3-korg