Check for err when namespace plugin returns 69/97869/1
authorKiran Kamineni <kiran.k.kamineni@intel.com>
Fri, 1 Nov 2019 20:15:47 +0000 (13:15 -0700)
committerKiran Kamineni <kiran.k.kamineni@intel.com>
Fri, 1 Nov 2019 20:15:55 +0000 (13:15 -0700)
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 <kiran.k.kamineni@intel.com>
src/k8splugin/internal/app/client.go

index e52225d..b75c7df 100644 (file)
@@ -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")
                }
        }