+ self.logger.error(logging_text + "Failing init juju-bundle: {}".format(e), exc_info=True)
+
+ step = "Getting the list of repos"
+ if k8s_hc_id:
+ self.logger.debug(logging_text + step)
+ task_list = []
+ db_k8srepo_list = self.db.get_list("k8srepos", {"type": "helm-chart"})
+ for repo in db_k8srepo_list:
+ step = "Adding repo {} to cluster: {}".format(repo["name"], k8s_hc_id)
+ self.logger.debug(logging_text + step)
+ task = asyncio.ensure_future(self.helm_k8scluster.repo_add(cluster_uuid=k8s_hc_id,
+ name=repo["name"], url=repo["url"],
+ repo_type="chart"))
+ task_list.append(task)
+ repo_k8scluster_list = deep_get(repo, ("_admin", "cluster-inserted")) or []
+ repo_k8scluster_list.append(k8s_hc_id)
+ self.update_db_2("k8srepos", repo["_id"], {"_admin.cluster-inserted": repo_k8scluster_list})
+
+ if task_list:
+ self.logger.debug(logging_text + 'Waiting for terminate tasks of repo_add')
+ done, pending = await asyncio.wait(task_list, timeout=3600)
+ if pending:
+ self.logger.error(logging_text + 'There are pending tasks: {}'.format(pending))
+
+ # mark as an error if both helm-chart and juju-bundle have been failed
+ if k8s_hc_id or k8s_jb_id:
+ db_k8scluster_update["_admin.operationalState"] = "ENABLED"
+ else:
+ db_k8scluster_update["_admin.operationalState"] = "ERROR"
+ db_k8scluster_update["_admin.detailed-status"] = ";".join(error_text_list)