Fix cluster-deregistration: update workflowtemplate and functions
Change-Id: Ibd4c2195d6b56a002daaf81f3ce9f93e69af446b
Signed-off-by: garciadeblas <gerardo.garciadeblas@telefonica.com>
diff --git a/docker/osm-krm-functions/scripts/library/krm-functions.rc b/docker/osm-krm-functions/scripts/library/krm-functions.rc
index 07a47f8..61f6b69 100644
--- a/docker/osm-krm-functions/scripts/library/krm-functions.rc
+++ b/docker/osm-krm-functions/scripts/library/krm-functions.rc
@@ -577,12 +577,12 @@
# Calculates key folders
## Base folder with Kustomizations for the new cluster
- local CLUSTER_FOLDER="${FLEET_REPO_DIR}/clusters/${CLUSTER_KUSTOMIZATION_NAME}"
+ # local CLUSTER_FOLDER="${FLEET_REPO_DIR}/clusters/${CLUSTER_KUSTOMIZATION_NAME}"
## Folder where managed resources are defined in the management cluster
local MGMT_RESOURCES_CLUSTER_DIR="${FLEET_REPO_DIR}/${MGMT_PROJECT_NAME}/managed-resources/_management/${CLUSTER_KUSTOMIZATION_NAME}"
- # Delete Flux resources syncronized directly from remote cluster
- rm -rf "${CLUSTER_FOLDER}/flux-system"
+ # Delete Flux resources synchronized directly from remote cluster
+ # rm -rf "${CLUSTER_FOLDER}/flux-system"
# Delete Flux resources bootstraped remotely
rm -rf "${MGMT_RESOURCES_CLUSTER_DIR}/cluster-bootstrap-${CLUSTER_KUSTOMIZATION_NAME}.yaml"
@@ -719,6 +719,18 @@
local APPS_DIR="${8:-"${FLEET_REPO_DIR}/${PROJECT_NAME}/app-profiles/${CLUSTER_KUSTOMIZATION_NAME}"}"
local CLUSTER_DIR="${9:-"${FLEET_REPO_DIR}/clusters/${CLUSTER_KUSTOMIZATION_NAME}"}"
+ # Optional input: Do I need a purge operation first?
+ local PURGE="${10:-"false"}"
+
+
+ # Perform the purge if needed
+ if [[ "${PURGE,,}" == "true" ]]; then
+ echo "Purging the remote Flux instalation..."
+ flux uninstall -s --namespace=flux-system
+ fi
+
+ echo "Deleting cluster profiles and (when applicable) its cloud resources..."
+
# Delete profile folders
rm -rf "${INFRA_CONTROLLERS_DIR}"
rm -rf "${INFRA_CONFIGS_DIR}"
@@ -728,7 +740,7 @@
# Delete base cluster Kustomizations
rm -rf "${CLUSTER_DIR}"
- # Delete cluster resources
+ # Delete cluster resources if managed by OSM (otherwise, this will be ignored)
rm -rf "${MGMT_RESOURCES_DIR}/${CLUSTER_KUSTOMIZATION_NAME}"
}