From: Kiran Kamineni Date: Fri, 1 Nov 2019 20:15:47 +0000 (-0700) Subject: Check for err when namespace plugin returns X-Git-Tag: 0.6.0~106 X-Git-Url: https://gerrit.onap.org/r/gitweb?a=commitdiff_plain;h=refs%2Fchanges%2F69%2F97869%2F1;p=multicloud%2Fk8s.git 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 --- 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") } }