From c4028e9f64b9ed511c301fc55640215efbb37638 Mon Sep 17 00:00:00 2001 From: Shylesh Kumar Mohan Date: Sun, 24 Sep 2023 21:56:22 +0100 Subject: [PATCH 1/6] Rename restic pods selector to 'node-agent' Signed-off-by: Shylesh Kumar Mohan --- ocs_ci/deployment/deployment.py | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/ocs_ci/deployment/deployment.py b/ocs_ci/deployment/deployment.py index 192939b51fb..fe093dbf68d 100644 --- a/ocs_ci/deployment/deployment.py +++ b/ocs_ci/deployment/deployment.py @@ -2832,9 +2832,10 @@ def validate_dpa(self): 3. backupstoragelocation resource in "Available" phase """ - # Check restic pods + # Check restic pods. + # Restic pods have been renamed to node-agent restic_list = get_pods_having_label( - "name=restic", constants.ACM_HUB_BACKUP_NAMESPACE + "name=node-agent", constants.ACM_HUB_BACKUP_NAMESPACE ) if len(restic_list) != constants.MDR_RESTIC_POD_COUNT: raise MDRDeploymentException("restic pod count mismatch") From 0601564d6453b94f39bdc7b0cfc486999ea6efeb Mon Sep 17 00:00:00 2001 From: Shylesh Kumar Mohan Date: Fri, 29 Sep 2023 10:59:28 +0100 Subject: [PATCH 2/6] Handle OADP versions specific pod names Signed-off-by: Shylesh Kumar Mohan --- ocs_ci/deployment/deployment.py | 11 +++++++++-- ocs_ci/utility/utils.py | 21 +++++++++++++++++++++ 2 files changed, 30 insertions(+), 2 deletions(-) diff --git a/ocs_ci/deployment/deployment.py b/ocs_ci/deployment/deployment.py index fe093dbf68d..9c4943b7c27 100644 --- a/ocs_ci/deployment/deployment.py +++ b/ocs_ci/deployment/deployment.py @@ -130,6 +130,7 @@ load_auth_config, TimeoutSampler, get_latest_acm_tag_unreleased, + get_oadp_version, ) from ocs_ci.utility.vsphere_nodes import update_ntp_compute_nodes from ocs_ci.helpers import helpers @@ -2833,9 +2834,15 @@ def validate_dpa(self): """ # Check restic pods. - # Restic pods have been renamed to node-agent + # Restic pods have been renamed to node-agent after oadp 1.2 + oadp_version = get_oadp_version() + + if version.compare_versions(f"{oadp_version} >= 1.2"): + restic_pod_prefix = "node-agent" + else: + restic_pod_prefix = "restic" restic_list = get_pods_having_label( - "name=node-agent", constants.ACM_HUB_BACKUP_NAMESPACE + f"name={restic_pod_prefix}", constants.ACM_HUB_BACKUP_NAMESPACE ) if len(restic_list) != constants.MDR_RESTIC_POD_COUNT: raise MDRDeploymentException("restic pod count mismatch") diff --git a/ocs_ci/utility/utils.py b/ocs_ci/utility/utils.py index 5570651f662..c75de85be93 100644 --- a/ocs_ci/utility/utils.py +++ b/ocs_ci/utility/utils.py @@ -4488,6 +4488,7 @@ def archive_ceph_crashes(toolbox_pod): toolbox_pod.exec_ceph_cmd("ceph crash archive-all") +<<<<<<< HEAD def add_time_report_to_email(session, soup): """ Takes the time report dictionary and converts it into HTML table @@ -4507,3 +4508,23 @@ def add_time_report_to_email(session, soup): table = BeautifulSoup(table_html, "html.parser") time_div.append(table) summary_tag.insert_after(time_div) +======= +def get_oadp_version(): + """ + Returns: + str: returns version string + """ + # Importing here to avoid circular dependency + from ocs_ci.ocs.resources.csv import get_csvs_start_with_prefix + + csv_list = get_csvs_start_with_prefix( + "oadp-operator", namespace=constants.ACM_HUB_BACKUP_NAMESPACE + ) + for csv in csv_list: + if "oadp-operator" in csv: + # extract version string + cmd = f"oc get csv/{csv} -n {constants.ACM_HUB_BACKUP_NAMESPACE} -o wide | awk {{'print $4'}}" + p = subprocess.Popen(cmd, stdout=subprocess.PIPE, shell=True) + out = p.communicate() + return out[0].splitlines[1].decode() +>>>>>>> 4c498d43 (Handle OADP versions specific pod names) From 9af2cdb67d5939db3de3629ef3e499bbd81a8b48 Mon Sep 17 00:00:00 2001 From: Shylesh Kumar Mohan Date: Tue, 3 Oct 2023 11:04:43 +0100 Subject: [PATCH 3/6] Fix output redirection issues Signed-off-by: Shylesh Kumar Mohan --- ocs_ci/utility/utils.py | 11 +++++++++++ 1 file changed, 11 insertions(+) diff --git a/ocs_ci/utility/utils.py b/ocs_ci/utility/utils.py index c75de85be93..713e4fae96e 100644 --- a/ocs_ci/utility/utils.py +++ b/ocs_ci/utility/utils.py @@ -4523,8 +4523,19 @@ def get_oadp_version(): for csv in csv_list: if "oadp-operator" in csv: # extract version string +<<<<<<< HEAD cmd = f"oc get csv/{csv} -n {constants.ACM_HUB_BACKUP_NAMESPACE} -o wide | awk {{'print $4'}}" p = subprocess.Popen(cmd, stdout=subprocess.PIPE, shell=True) out = p.communicate() return out[0].splitlines[1].decode() >>>>>>> 4c498d43 (Handle OADP versions specific pod names) +======= + cmd = f"oc get csv/{csv} -n {constants.ACM_HUB_BACKUP_NAMESPACE} -o wide " + awk_cmd = "awk {{'print $4'}}" + p = subprocess.Popen(shlex.split(cmd), stdout=subprocess.PIPE) + outbuf = subprocess.Popen( + shlex.split(awk_cmd), stdin=p.stdout, stdout=subprocess.PIPE + ) + out = outbuf.communicate() + return out[0].splitlines()[1].decode() +>>>>>>> b6c07332 (Fix output redirection issues) From 9d4e487d0b8b314f1184104012840199b86ce365 Mon Sep 17 00:00:00 2001 From: Shylesh Kumar Mohan Date: Wed, 11 Oct 2023 20:35:57 +0100 Subject: [PATCH 4/6] Fix oadp-operator version fetch issue Signed-off-by: Shylesh Kumar Mohan --- ocs_ci/utility/utils.py | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/ocs_ci/utility/utils.py b/ocs_ci/utility/utils.py index 713e4fae96e..00adb00a73f 100644 --- a/ocs_ci/utility/utils.py +++ b/ocs_ci/utility/utils.py @@ -4521,8 +4521,9 @@ def get_oadp_version(): "oadp-operator", namespace=constants.ACM_HUB_BACKUP_NAMESPACE ) for csv in csv_list: - if "oadp-operator" in csv: + if "oadp-operator" in csv["metadata"]["name"]: # extract version string +<<<<<<< HEAD <<<<<<< HEAD cmd = f"oc get csv/{csv} -n {constants.ACM_HUB_BACKUP_NAMESPACE} -o wide | awk {{'print $4'}}" p = subprocess.Popen(cmd, stdout=subprocess.PIPE, shell=True) @@ -4531,6 +4532,9 @@ def get_oadp_version(): >>>>>>> 4c498d43 (Handle OADP versions specific pod names) ======= cmd = f"oc get csv/{csv} -n {constants.ACM_HUB_BACKUP_NAMESPACE} -o wide " +======= + cmd = f"oc get csv/{csv['metadata']['name']} -n {constants.ACM_HUB_BACKUP_NAMESPACE} -o wide " +>>>>>>> 2f8a2b5c (Fix oadp-operator version fetch issue) awk_cmd = "awk {{'print $4'}}" p = subprocess.Popen(shlex.split(cmd), stdout=subprocess.PIPE) outbuf = subprocess.Popen( From cba2897729e01dccc23559992e0781b54b0e60c8 Mon Sep 17 00:00:00 2001 From: Shylesh Kumar Mohan Date: Sat, 14 Oct 2023 13:49:34 +0100 Subject: [PATCH 5/6] Fix merge conflicts Signed-off-by: Shylesh Kumar Mohan --- ocs_ci/utility/utils.py | 16 ++-------------- 1 file changed, 2 insertions(+), 14 deletions(-) diff --git a/ocs_ci/utility/utils.py b/ocs_ci/utility/utils.py index 00adb00a73f..75028cc295d 100644 --- a/ocs_ci/utility/utils.py +++ b/ocs_ci/utility/utils.py @@ -4488,7 +4488,6 @@ def archive_ceph_crashes(toolbox_pod): toolbox_pod.exec_ceph_cmd("ceph crash archive-all") -<<<<<<< HEAD def add_time_report_to_email(session, soup): """ Takes the time report dictionary and converts it into HTML table @@ -4508,7 +4507,8 @@ def add_time_report_to_email(session, soup): table = BeautifulSoup(table_html, "html.parser") time_div.append(table) summary_tag.insert_after(time_div) -======= + + def get_oadp_version(): """ Returns: @@ -4523,18 +4523,7 @@ def get_oadp_version(): for csv in csv_list: if "oadp-operator" in csv["metadata"]["name"]: # extract version string -<<<<<<< HEAD -<<<<<<< HEAD - cmd = f"oc get csv/{csv} -n {constants.ACM_HUB_BACKUP_NAMESPACE} -o wide | awk {{'print $4'}}" - p = subprocess.Popen(cmd, stdout=subprocess.PIPE, shell=True) - out = p.communicate() - return out[0].splitlines[1].decode() ->>>>>>> 4c498d43 (Handle OADP versions specific pod names) -======= - cmd = f"oc get csv/{csv} -n {constants.ACM_HUB_BACKUP_NAMESPACE} -o wide " -======= cmd = f"oc get csv/{csv['metadata']['name']} -n {constants.ACM_HUB_BACKUP_NAMESPACE} -o wide " ->>>>>>> 2f8a2b5c (Fix oadp-operator version fetch issue) awk_cmd = "awk {{'print $4'}}" p = subprocess.Popen(shlex.split(cmd), stdout=subprocess.PIPE) outbuf = subprocess.Popen( @@ -4542,4 +4531,3 @@ def get_oadp_version(): ) out = outbuf.communicate() return out[0].splitlines()[1].decode() ->>>>>>> b6c07332 (Fix output redirection issues) From d5e347216a84b5456948b4513f314a1c9feeebde Mon Sep 17 00:00:00 2001 From: Shylesh Kumar Mohan Date: Mon, 16 Oct 2023 12:40:24 +0100 Subject: [PATCH 6/6] Simplify version extraction Signed-off-by: Shylesh Kumar Mohan --- ocs_ci/utility/utils.py | 9 +-------- 1 file changed, 1 insertion(+), 8 deletions(-) diff --git a/ocs_ci/utility/utils.py b/ocs_ci/utility/utils.py index 75028cc295d..02c72a3d1e8 100644 --- a/ocs_ci/utility/utils.py +++ b/ocs_ci/utility/utils.py @@ -4523,11 +4523,4 @@ def get_oadp_version(): for csv in csv_list: if "oadp-operator" in csv["metadata"]["name"]: # extract version string - cmd = f"oc get csv/{csv['metadata']['name']} -n {constants.ACM_HUB_BACKUP_NAMESPACE} -o wide " - awk_cmd = "awk {{'print $4'}}" - p = subprocess.Popen(shlex.split(cmd), stdout=subprocess.PIPE) - outbuf = subprocess.Popen( - shlex.split(awk_cmd), stdin=p.stdout, stdout=subprocess.PIPE - ) - out = outbuf.communicate() - return out[0].splitlines()[1].decode() + return csv["spec"]["version"]