Improve logs for K8sJujuConnector init_env 20/10920/5
authorgarciadeblas <gerardo.garciadeblas@telefonica.com>
Mon, 31 May 2021 13:49:15 +0000 (15:49 +0200)
committergarciadav <david.garcia@canonical.com>
Fri, 22 Apr 2022 10:38:49 +0000 (12:38 +0200)
Change-Id: I013b6c062cf29d9a69e39ab8fdc363e9bd052873
Signed-off-by: garciadeblas <gerardo.garciadeblas@telefonica.com>
n2vc/k8s_juju_conn.py

index d9dc607..1704ec0 100644 (file)
@@ -122,10 +122,12 @@ class K8sJujuConnector(K8sConnector):
         # if it fails in the middle of the process
         cleanup_data = []
         try:
+            self.log.debug("Initializing K8s cluster for juju")
             kubectl.create_cluster_role(
                 name=metadata_name,
                 labels=labels,
             )
+            self.log.debug("Cluster role created")
             cleanup_data.append(
                 {
                     "delete": kubectl.delete_cluster_role,
@@ -137,6 +139,7 @@ class K8sJujuConnector(K8sConnector):
                 name=metadata_name,
                 labels=labels,
             )
+            self.log.debug("Service account created")
             cleanup_data.append(
                 {
                     "delete": kubectl.delete_service_account,
@@ -148,6 +151,7 @@ class K8sJujuConnector(K8sConnector):
                 name=metadata_name,
                 labels=labels,
             )
+            self.log.debug("Role binding created")
             cleanup_data.append(
                 {
                     "delete": kubectl.delete_service_account,
@@ -159,6 +163,7 @@ class K8sJujuConnector(K8sConnector):
             )
 
             default_storage_class = kubectl.get_default_storage_class()
+            self.log.debug("Default storage class: {}".format(default_storage_class))
             await libjuju.add_k8s(
                 name=cluster_uuid,
                 rbac_id=rbac_id,
@@ -168,9 +173,10 @@ class K8sJujuConnector(K8sConnector):
                 storage_class=default_storage_class,
                 credential_name=self._get_credential_name(cluster_uuid),
             )
+            self.log.debug("K8s cluster added to juju controller")
             return cluster_uuid, True
         except Exception as e:
-            self.log.error("Error initializing k8scluster: {}".format(e))
+            self.log.error("Error initializing k8scluster: {}".format(e), exc_info=True)
             if len(cleanup_data) > 0:
                 self.log.debug("Cleaning up created resources in k8s cluster...")
                 for item in cleanup_data: