From e39d6d88ef9e1ee15d28b07e92e5148dcd1e4fcd Mon Sep 17 00:00:00 2001 From: Rawa Resul Date: Mon, 9 Dec 2024 18:00:46 +0000 Subject: [PATCH 1/7] [patch] Fix subscription lookup in upgrade --- .../suite_app_upgrade/tasks/check_app_compatibility.yml | 5 +++-- .../suite_app_upgrade/tasks/check_core_compatibility.yml | 5 +++-- ibm/mas_devops/roles/suite_app_upgrade/tasks/main.yml | 5 +++-- ibm/mas_devops/roles/suite_app_upgrade/tasks/upgrade.yml | 5 +++-- .../roles/suite_upgrade/tasks/check_app_compatibility.yml | 5 +++-- .../roles/suite_upgrade/tasks/check_core_compatibility.yml | 5 +++-- 6 files changed, 18 insertions(+), 12 deletions(-) diff --git a/ibm/mas_devops/roles/suite_app_upgrade/tasks/check_app_compatibility.yml b/ibm/mas_devops/roles/suite_app_upgrade/tasks/check_app_compatibility.yml index b581f8360..9fac9c1a0 100644 --- a/ibm/mas_devops/roles/suite_app_upgrade/tasks/check_app_compatibility.yml +++ b/ibm/mas_devops/roles/suite_app_upgrade/tasks/check_app_compatibility.yml @@ -14,9 +14,10 @@ - name: "{{ mas_app_id }} : Get subscription for {{ mas_app_fqn }}" kubernetes.core.k8s_info: api_version: operators.coreos.com/v1alpha1 - name: "{{ mas_app_fqn }}" - namespace: "{{ mas_app_namespace }}" kind: Subscription + namespace: "{{ mas_app_namespace }}" + label_selectors: + - "operators.coreos.com/ibm-mas-{{ mas_app_fqn }}.{{ mas_app_namespace }}" register: app_sub_info - name: "{{ mas_app_id }} : Debug existing Subscription" diff --git a/ibm/mas_devops/roles/suite_app_upgrade/tasks/check_core_compatibility.yml b/ibm/mas_devops/roles/suite_app_upgrade/tasks/check_core_compatibility.yml index 7065a46b6..5c7a80da0 100644 --- a/ibm/mas_devops/roles/suite_app_upgrade/tasks/check_core_compatibility.yml +++ b/ibm/mas_devops/roles/suite_app_upgrade/tasks/check_core_compatibility.yml @@ -4,9 +4,10 @@ - name: "core : Get subscription for ibm-mas" kubernetes.core.k8s_info: api_version: operators.coreos.com/v1alpha1 - name: "ibm-mas-operator" - namespace: "{{ mas_namespace }}" kind: Subscription + namespace: "{{ mas_namespace }}" + label_selectors: + - "operators.coreos.com/ibm-mas.{{ mas_namespace }}" register: core_sub_info - name: "core : Debug existing Subscription" diff --git a/ibm/mas_devops/roles/suite_app_upgrade/tasks/main.yml b/ibm/mas_devops/roles/suite_app_upgrade/tasks/main.yml index 755acadc9..e89715ce8 100644 --- a/ibm/mas_devops/roles/suite_app_upgrade/tasks/main.yml +++ b/ibm/mas_devops/roles/suite_app_upgrade/tasks/main.yml @@ -47,9 +47,10 @@ - name: "{{ mas_app_id }} : Get subscription for {{ mas_app_fqn }}" kubernetes.core.k8s_info: api_version: operators.coreos.com/v1alpha1 - name: "{{ mas_app_fqn }}" - namespace: "{{ mas_app_namespace }}" kind: Subscription + namespace: "{{ mas_app_namespace }}" + label_selectors: + - "operators.coreos.com/ibm-mas-{{ mas_app_fqn }}.{{ mas_app_namespace }}" register: app_sub_info diff --git a/ibm/mas_devops/roles/suite_app_upgrade/tasks/upgrade.yml b/ibm/mas_devops/roles/suite_app_upgrade/tasks/upgrade.yml index 023e5e73b..f3de53d0e 100644 --- a/ibm/mas_devops/roles/suite_app_upgrade/tasks/upgrade.yml +++ b/ibm/mas_devops/roles/suite_app_upgrade/tasks/upgrade.yml @@ -5,9 +5,10 @@ - name: "Lookup subscription" kubernetes.core.k8s_info: api_version: operators.coreos.com/v1alpha1 - name: "{{ mas_app_fqn }}" - namespace: "{{ mas_app_namespace }}" kind: Subscription + namespace: "{{ mas_app_namespace }}" + label_selectors: + - "operators.coreos.com/ibm-mas-{{ mas_app_fqn }}.{{ mas_app_namespace }}" register: suite_app_sub - name: "Assert subscription exists" diff --git a/ibm/mas_devops/roles/suite_upgrade/tasks/check_app_compatibility.yml b/ibm/mas_devops/roles/suite_upgrade/tasks/check_app_compatibility.yml index ce78793fc..7781d8894 100644 --- a/ibm/mas_devops/roles/suite_upgrade/tasks/check_app_compatibility.yml +++ b/ibm/mas_devops/roles/suite_upgrade/tasks/check_app_compatibility.yml @@ -8,9 +8,10 @@ - name: "{{ check_app.id }} : Get subscription for ibm-mas-{{ check_app.id }}" kubernetes.core.k8s_info: api_version: operators.coreos.com/v1alpha1 - name: "ibm-mas-{{ check_app.id }}" - namespace: "{{ check_app_namespace }}" kind: Subscription + namespace: "{{ check_app_namespace }}" + label_selectors: + - "operators.coreos.com/ibm-mas-{{ check_app.id }}.{{ check_app_namespace }}" register: checkapp_sub_info - name: "{{ check_app.id }} : Debug existing Subscription" diff --git a/ibm/mas_devops/roles/suite_upgrade/tasks/check_core_compatibility.yml b/ibm/mas_devops/roles/suite_upgrade/tasks/check_core_compatibility.yml index 7a2c2696b..f5b59893c 100644 --- a/ibm/mas_devops/roles/suite_upgrade/tasks/check_core_compatibility.yml +++ b/ibm/mas_devops/roles/suite_upgrade/tasks/check_core_compatibility.yml @@ -4,9 +4,10 @@ - name: "core : Get subscription for ibm-mas" kubernetes.core.k8s_info: api_version: operators.coreos.com/v1alpha1 - name: "ibm-mas-operator" - namespace: "{{ mas_namespace }}" kind: Subscription + namespace: "{{ mas_namespace }}" + label_selectors: + - "operators.coreos.com/ibm-mas.{{ mas_namespace }}" register: suite_sub_info - name: "core : Debug existing Subscription" From c600c5101fb26a62fc85001ac6fa293860c79ec9 Mon Sep 17 00:00:00 2001 From: Rawa Resul Date: Mon, 9 Dec 2024 21:47:02 +0000 Subject: [PATCH 2/7] [patch] More fixes --- ibm/mas_devops/roles/suite_upgrade/tasks/upgrade.yml | 10 ++++++---- 1 file changed, 6 insertions(+), 4 deletions(-) diff --git a/ibm/mas_devops/roles/suite_upgrade/tasks/upgrade.yml b/ibm/mas_devops/roles/suite_upgrade/tasks/upgrade.yml index efa48eda8..e23ded050 100644 --- a/ibm/mas_devops/roles/suite_upgrade/tasks/upgrade.yml +++ b/ibm/mas_devops/roles/suite_upgrade/tasks/upgrade.yml @@ -4,9 +4,10 @@ - name: "upgrade : Update ibm-mas subscription channel" kubernetes.core.k8s: api_version: operators.coreos.com/v1alpha1 - name: "ibm-mas-operator" - namespace: "{{ mas_namespace }}" kind: Subscription + namespace: "{{ mas_namespace }}" + label_selectors: + - "operators.coreos.com/ibm-mas.{{ mas_namespace }}" definition: spec: channel: "{{ mas_channel }}" @@ -18,9 +19,10 @@ - name: "upgrade : Get updated subscription for ibm-mas" kubernetes.core.k8s_info: api_version: operators.coreos.com/v1alpha1 - name: "ibm-mas-operator" - namespace: "{{ mas_namespace }}" kind: Subscription + namespace: "{{ mas_namespace }}" + label_selectors: + - "operators.coreos.com/ibm-mas.{{ mas_namespace }}" register: updated_suite_sub_info retries: 20 # about 10 minutes delay: 30 # seconds From be74d1704b116122e47c492ab0eafacd9ceac151 Mon Sep 17 00:00:00 2001 From: Rawa Resul Date: Mon, 9 Dec 2024 21:51:54 +0000 Subject: [PATCH 3/7] [patch] Fix installPlanApproval check in Subscription --- .../roles/suite_app_upgrade/tasks/check_app_compatibility.yml | 4 +++- .../suite_app_upgrade/tasks/check_core_compatibility.yml | 4 +++- .../roles/suite_upgrade/tasks/check_app_compatibility.yml | 4 +++- .../roles/suite_upgrade/tasks/check_core_compatibility.yml | 4 +++- 4 files changed, 12 insertions(+), 4 deletions(-) diff --git a/ibm/mas_devops/roles/suite_app_upgrade/tasks/check_app_compatibility.yml b/ibm/mas_devops/roles/suite_app_upgrade/tasks/check_app_compatibility.yml index 9fac9c1a0..b8d3cc732 100644 --- a/ibm/mas_devops/roles/suite_app_upgrade/tasks/check_app_compatibility.yml +++ b/ibm/mas_devops/roles/suite_app_upgrade/tasks/check_app_compatibility.yml @@ -47,7 +47,9 @@ fail_msg: "Unable to upgrade from {{ app_sub_info.resources[0].spec.channel }} to {{ mas_app_upgrade_target_channel }}" - name: "{{ mas_app_id }} : Check that install plan approvals are set to 'Automatic'" - when: app_sub_info.resources[0].spec.channel != mas_app_upgrade_target_channel + when: + - app_sub_info.resources[0].spec.channel != mas_app_upgrade_target_channel + - app_sub_info.resources[0].spec.installPlanApproval is defined assert: that: app_sub_info.resources[0].spec.installPlanApproval == 'Automatic' fail_msg: "Automatic install plan approvals must be enabled to upgrade via this role" diff --git a/ibm/mas_devops/roles/suite_app_upgrade/tasks/check_core_compatibility.yml b/ibm/mas_devops/roles/suite_app_upgrade/tasks/check_core_compatibility.yml index 5c7a80da0..871b3ade4 100644 --- a/ibm/mas_devops/roles/suite_app_upgrade/tasks/check_core_compatibility.yml +++ b/ibm/mas_devops/roles/suite_app_upgrade/tasks/check_core_compatibility.yml @@ -23,7 +23,9 @@ fail_msg: "Unable to upgrade to {{ mas_app_upgrade_target_channel }} because {{ mas_app_fqn }} channel {{ mas_app_upgrade_target_channel }} is not supported with MAS Core {{ core_sub_info.resources[0].spec.channel }}. Supported application channels are: {{ compatibility_matrix[core_sub_info.resources[0].spec.channel][mas_app_id] }}" - name: "core : Check that install plan approvals are set to 'Automatic'" - when: core_sub_info.resources is defined and core_sub_info.resources | length == 1 + when: + - core_sub_info.resources is defined and core_sub_info.resources | length == 1 + - core_sub_info.resources[0].spec.installPlanApproval is defined assert: that: core_sub_info.resources[0].spec.installPlanApproval == 'Automatic' fail_msg: "Automatic install plan approvals must be enabled to upgrade via this role" diff --git a/ibm/mas_devops/roles/suite_upgrade/tasks/check_app_compatibility.yml b/ibm/mas_devops/roles/suite_upgrade/tasks/check_app_compatibility.yml index 7781d8894..92604990d 100644 --- a/ibm/mas_devops/roles/suite_upgrade/tasks/check_app_compatibility.yml +++ b/ibm/mas_devops/roles/suite_upgrade/tasks/check_app_compatibility.yml @@ -35,7 +35,9 @@ fail_msg: "Unable to upgrade to {{ mas_channel }} because ibm-mas-{{ check_app.id }} is subscribed to a channel that is not compatible with this release ({{ checkapp_sub_info.resources[0].spec.channel }}). Supported channels are: {{ compatibility_matrix[mas_channel][check_app.id] }}" - name: "{{ check_app.id }} : Check that install plan approvals are set to 'Automatic'" - when: checkapp_sub_info.resources is defined and checkapp_sub_info.resources | length == 1 + when: + - checkapp_sub_info.resources is defined and checkapp_sub_info.resources | length == 1 + - checkapp_sub_info.resources[0].spec.installPlanApproval is defined assert: that: checkapp_sub_info.resources[0].spec.installPlanApproval == 'Automatic' fail_msg: "Automatic install plan approvals must be enabled to upgrade via this role" diff --git a/ibm/mas_devops/roles/suite_upgrade/tasks/check_core_compatibility.yml b/ibm/mas_devops/roles/suite_upgrade/tasks/check_core_compatibility.yml index f5b59893c..7270315e8 100644 --- a/ibm/mas_devops/roles/suite_upgrade/tasks/check_core_compatibility.yml +++ b/ibm/mas_devops/roles/suite_upgrade/tasks/check_core_compatibility.yml @@ -37,7 +37,9 @@ fail_msg: "Unable to upgrade from {{ suite_sub_info.resources[0].spec.channel }} to {{ mas_channel }}" - name: "core : Check that install plan approvals are set to 'Automatic'" - when: suite_sub_info.resources[0].spec.channel != mas_channel + when: + - suite_sub_info.resources[0].spec.channel != mas_channel + - suite_sub_info.resources[0].spec.installPlanApproval is defined assert: that: suite_sub_info.resources[0].spec.installPlanApproval == 'Automatic' fail_msg: "Automatic install plan approvals must be enabled to upgrade via this role" From f6bd344da206e90d2a7f62a60111c1e478c12ee6 Mon Sep 17 00:00:00 2001 From: Rawa Resul Date: Mon, 9 Dec 2024 22:16:30 +0000 Subject: [PATCH 4/7] [patch] linting fixes --- ibm/mas_devops/roles/nvidia_gpu/tasks/main.yml | 1 - .../roles/suite_upgrade/tasks/check_app_compatibility.yml | 2 +- .../roles/suite_upgrade/tasks/check_core_compatibility.yml | 2 +- 3 files changed, 2 insertions(+), 3 deletions(-) diff --git a/ibm/mas_devops/roles/nvidia_gpu/tasks/main.yml b/ibm/mas_devops/roles/nvidia_gpu/tasks/main.yml index 96b3f7d2a..598db8a3b 100644 --- a/ibm/mas_devops/roles/nvidia_gpu/tasks/main.yml +++ b/ibm/mas_devops/roles/nvidia_gpu/tasks/main.yml @@ -133,4 +133,3 @@ when: - gpu_clusterpolicy_result.resources | length == 0 - gpu_clusterpolicy_result.resources[0].status is not defined - diff --git a/ibm/mas_devops/roles/suite_upgrade/tasks/check_app_compatibility.yml b/ibm/mas_devops/roles/suite_upgrade/tasks/check_app_compatibility.yml index 92604990d..5a5fa3249 100644 --- a/ibm/mas_devops/roles/suite_upgrade/tasks/check_app_compatibility.yml +++ b/ibm/mas_devops/roles/suite_upgrade/tasks/check_app_compatibility.yml @@ -35,7 +35,7 @@ fail_msg: "Unable to upgrade to {{ mas_channel }} because ibm-mas-{{ check_app.id }} is subscribed to a channel that is not compatible with this release ({{ checkapp_sub_info.resources[0].spec.channel }}). Supported channels are: {{ compatibility_matrix[mas_channel][check_app.id] }}" - name: "{{ check_app.id }} : Check that install plan approvals are set to 'Automatic'" - when: + when: - checkapp_sub_info.resources is defined and checkapp_sub_info.resources | length == 1 - checkapp_sub_info.resources[0].spec.installPlanApproval is defined assert: diff --git a/ibm/mas_devops/roles/suite_upgrade/tasks/check_core_compatibility.yml b/ibm/mas_devops/roles/suite_upgrade/tasks/check_core_compatibility.yml index 7270315e8..22eb13a6e 100644 --- a/ibm/mas_devops/roles/suite_upgrade/tasks/check_core_compatibility.yml +++ b/ibm/mas_devops/roles/suite_upgrade/tasks/check_core_compatibility.yml @@ -37,7 +37,7 @@ fail_msg: "Unable to upgrade from {{ suite_sub_info.resources[0].spec.channel }} to {{ mas_channel }}" - name: "core : Check that install plan approvals are set to 'Automatic'" - when: + when: - suite_sub_info.resources[0].spec.channel != mas_channel - suite_sub_info.resources[0].spec.installPlanApproval is defined assert: From e5ec7fe30c1bf43020f19c188e306dbb8043126d Mon Sep 17 00:00:00 2001 From: Rawa Resul Date: Mon, 9 Dec 2024 23:05:27 +0000 Subject: [PATCH 5/7] [patch] Fix apply subscription --- ibm/mas_devops/roles/suite_upgrade/tasks/upgrade.yml | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/ibm/mas_devops/roles/suite_upgrade/tasks/upgrade.yml b/ibm/mas_devops/roles/suite_upgrade/tasks/upgrade.yml index e23ded050..c51913633 100644 --- a/ibm/mas_devops/roles/suite_upgrade/tasks/upgrade.yml +++ b/ibm/mas_devops/roles/suite_upgrade/tasks/upgrade.yml @@ -5,9 +5,8 @@ kubernetes.core.k8s: api_version: operators.coreos.com/v1alpha1 kind: Subscription + name: "{{ core_sub_info.resources[0].metadata.name }}" namespace: "{{ mas_namespace }}" - label_selectors: - - "operators.coreos.com/ibm-mas.{{ mas_namespace }}" definition: spec: channel: "{{ mas_channel }}" From ee7d750f1e23a2e8ce4a8f3819e4a333d69d7039 Mon Sep 17 00:00:00 2001 From: Rawa Resul Date: Mon, 9 Dec 2024 23:30:24 +0000 Subject: [PATCH 6/7] [patch] Add missing fields --- ibm/mas_devops/roles/suite_app_upgrade/tasks/upgrade.yml | 3 +++ ibm/mas_devops/roles/suite_upgrade/tasks/upgrade.yml | 3 +++ 2 files changed, 6 insertions(+) diff --git a/ibm/mas_devops/roles/suite_app_upgrade/tasks/upgrade.yml b/ibm/mas_devops/roles/suite_app_upgrade/tasks/upgrade.yml index f3de53d0e..dc9058ba8 100644 --- a/ibm/mas_devops/roles/suite_app_upgrade/tasks/upgrade.yml +++ b/ibm/mas_devops/roles/suite_app_upgrade/tasks/upgrade.yml @@ -26,6 +26,9 @@ definition: spec: channel: "{{ mas_app_upgrade_target_channel }}" + name: "{{ app_sub_info.resources[0].spec.name }}" + source: "{{ app_sub_info.resources[0].spec.source }}" + sourceNamespace: "{{ app_sub_info.resources[0].spec.sourceNamespace }}" apply: true - name: "Pause for 5 minutes before checking upgrade status..." diff --git a/ibm/mas_devops/roles/suite_upgrade/tasks/upgrade.yml b/ibm/mas_devops/roles/suite_upgrade/tasks/upgrade.yml index c51913633..0e4490689 100644 --- a/ibm/mas_devops/roles/suite_upgrade/tasks/upgrade.yml +++ b/ibm/mas_devops/roles/suite_upgrade/tasks/upgrade.yml @@ -10,6 +10,9 @@ definition: spec: channel: "{{ mas_channel }}" + name: "{{ core_sub_info.resources[0].spec.name }}" + source: "{{ core_sub_info.resources[0].spec.source }}" + sourceNamespace: "{{ core_sub_info.resources[0].spec.sourceNamespace }}" apply: true From f2a62d5e5ade019a93c7ccc95813e7fe652268e4 Mon Sep 17 00:00:00 2001 From: Rawa Resul Date: Tue, 10 Dec 2024 13:06:29 +0000 Subject: [PATCH 7/7] [patch] More fixes --- .../roles/suite_app_upgrade/tasks/check_app_compatibility.yml | 2 +- ibm/mas_devops/roles/suite_app_upgrade/tasks/main.yml | 2 +- ibm/mas_devops/roles/suite_app_upgrade/tasks/upgrade.yml | 2 +- 3 files changed, 3 insertions(+), 3 deletions(-) diff --git a/ibm/mas_devops/roles/suite_app_upgrade/tasks/check_app_compatibility.yml b/ibm/mas_devops/roles/suite_app_upgrade/tasks/check_app_compatibility.yml index b8d3cc732..174df9878 100644 --- a/ibm/mas_devops/roles/suite_app_upgrade/tasks/check_app_compatibility.yml +++ b/ibm/mas_devops/roles/suite_app_upgrade/tasks/check_app_compatibility.yml @@ -17,7 +17,7 @@ kind: Subscription namespace: "{{ mas_app_namespace }}" label_selectors: - - "operators.coreos.com/ibm-mas-{{ mas_app_fqn }}.{{ mas_app_namespace }}" + - "operators.coreos.com/{{ mas_app_fqn }}.{{ mas_app_namespace }}" register: app_sub_info - name: "{{ mas_app_id }} : Debug existing Subscription" diff --git a/ibm/mas_devops/roles/suite_app_upgrade/tasks/main.yml b/ibm/mas_devops/roles/suite_app_upgrade/tasks/main.yml index e89715ce8..42daa0a99 100644 --- a/ibm/mas_devops/roles/suite_app_upgrade/tasks/main.yml +++ b/ibm/mas_devops/roles/suite_app_upgrade/tasks/main.yml @@ -50,7 +50,7 @@ kind: Subscription namespace: "{{ mas_app_namespace }}" label_selectors: - - "operators.coreos.com/ibm-mas-{{ mas_app_fqn }}.{{ mas_app_namespace }}" + - "operators.coreos.com/{{ mas_app_fqn }}.{{ mas_app_namespace }}" register: app_sub_info diff --git a/ibm/mas_devops/roles/suite_app_upgrade/tasks/upgrade.yml b/ibm/mas_devops/roles/suite_app_upgrade/tasks/upgrade.yml index dc9058ba8..924687f25 100644 --- a/ibm/mas_devops/roles/suite_app_upgrade/tasks/upgrade.yml +++ b/ibm/mas_devops/roles/suite_app_upgrade/tasks/upgrade.yml @@ -8,7 +8,7 @@ kind: Subscription namespace: "{{ mas_app_namespace }}" label_selectors: - - "operators.coreos.com/ibm-mas-{{ mas_app_fqn }}.{{ mas_app_namespace }}" + - "operators.coreos.com/{{ mas_app_fqn }}.{{ mas_app_namespace }}" register: suite_app_sub - name: "Assert subscription exists"