From e4903ac6df793e3a2c1f349c3f35402ceee55d14 Mon Sep 17 00:00:00 2001 From: Petr Balogh Date: Thu, 2 Jan 2025 16:11:31 +0100 Subject: [PATCH] Consider destroy of cluster to be completed if resource group not found Signed-off-by: Petr Balogh --- ocs_ci/utility/utils.py | 21 ++++++++++++++------- 1 file changed, 14 insertions(+), 7 deletions(-) diff --git a/ocs_ci/utility/utils.py b/ocs_ci/utility/utils.py index a8e5faf6836..34d7bd5b57d 100644 --- a/ocs_ci/utility/utils.py +++ b/ocs_ci/utility/utils.py @@ -1986,11 +1986,11 @@ def get_ocs_build_number(): operator_name = defaults.HCI_CLIENT_ODF_OPERATOR_NAME else: operator_name = defaults.OCS_OPERATOR_NAME - ocs_csvs = get_csvs_start_with_prefix( - operator_name, - config.ENV_DATA["cluster_namespace"], - ) try: + ocs_csvs = get_csvs_start_with_prefix( + operator_name, + config.ENV_DATA["cluster_namespace"], + ) ocs_csv = ocs_csvs[0] csv_labels = ocs_csv["metadata"]["labels"] if "full_version" in csv_labels: @@ -3435,9 +3435,16 @@ def destroy_cluster(installer, cluster_path, log_level="DEBUG"): # Execute destroy cluster using OpenShift installer log.info(f"Destroying cluster defined in {cluster_path}") run_cmd(destroy_cmd, timeout=1200) - except CommandFailed: - log.error(traceback.format_exc()) - raise + except CommandFailed as ex: + error_message = str(ex) + # Check for the specific "ResourceGroup not found" error + if re.search(r"ResourceGroup .* not found", error_message): + log.warning( + f"Resource group not found. Assuming cluster is already destroyed. Exception {error_message}" + ) + else: + log.error(traceback.format_exc()) + raise except Exception: log.error(traceback.format_exc())