summary |
shortlog |
log |
commit | commitdiff |
tree
raw |
patch |
inline | side by side (from parent 1:
b8ba1af)
bug 1142: When helm is not going to be uninstalled, do not check for kdu releases
bug 1117: When helm is going to be unistalled with kdu releases, just warn and
skip uninstall helm. This happens because kdu release has been installed
outside the scope of OSM. NBI already checks that there is not OSM kdu
deployments upon k8scluster deletion, denying the operation if any.
Change-Id: Icee2125b790c562130e13dd8c619d1c94c64c0fe
Signed-off-by: tierno <alfonso.tiernosepulveda@telefonica.com>
) -> bool:
namespace, cluster_id = self._get_namespace_cluster_id(cluster_uuid)
) -> bool:
namespace, cluster_id = self._get_namespace_cluster_id(cluster_uuid)
- self.log.debug(
- "Resetting K8s environment. cluster uuid: {}".format(cluster_id)
- )
+ self.log.debug("Resetting K8s environment. cluster uuid: {} uninstall={}"
+ .format(cluster_id, uninstall_sw))
# get kube and helm directories
_kube_dir, helm_dir, config_filename, _cluster_dir = self._get_paths(
cluster_name=cluster_id, create_if_not_exist=False
)
# get kube and helm directories
_kube_dir, helm_dir, config_filename, _cluster_dir = self._get_paths(
cluster_name=cluster_id, create_if_not_exist=False
)
- # uninstall releases if needed
- releases = await self.instances_list(cluster_uuid=cluster_uuid)
- if len(releases) > 0:
- if force:
- for r in releases:
- try:
- kdu_instance = r.get("Name")
- chart = r.get("Chart")
- self.log.debug(
- "Uninstalling {} -> {}".format(chart, kdu_instance)
- )
- await self.uninstall(
- cluster_uuid=cluster_uuid, kdu_instance=kdu_instance
- )
- except Exception as e:
- self.log.error(
- "Error uninstalling release {}: {}".format(kdu_instance, e)
- )
- else:
- msg = (
- "Cluster has releases and not force. Cannot reset K8s "
- "environment. Cluster uuid: {}"
- ).format(cluster_id)
- self.log.error(msg)
- raise K8sException(msg)
+ # uninstall releases if needed.
+ if uninstall_sw:
+ releases = await self.instances_list(cluster_uuid=cluster_uuid)
+ if len(releases) > 0:
+ if force:
+ for r in releases:
+ try:
+ kdu_instance = r.get("Name")
+ chart = r.get("Chart")
+ self.log.debug(
+ "Uninstalling {} -> {}".format(chart, kdu_instance)
+ )
+ await self.uninstall(
+ cluster_uuid=cluster_uuid, kdu_instance=kdu_instance
+ )
+ except Exception as e:
+ self.log.error(
+ "Error uninstalling release {}: {}".format(kdu_instance, e)
+ )
+ else:
+ msg = (
+ "Cluster uuid: {} has releases and not force. Leaving K8s helm environment"
+ ).format(cluster_id)
+ self.log.warn(msg)
+ uninstall_sw = False # Allow to remove k8s cluster without removing Tiller