Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[patch] Fix subscription lookup in upgrade #1589

Merged
merged 8 commits into from
Dec 12, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 0 additions & 1 deletion ibm/mas_devops/roles/nvidia_gpu/tasks/main.yml
Original file line number Diff line number Diff line change
Expand Up @@ -133,4 +133,3 @@
when:
- gpu_clusterpolicy_result.resources | length == 0
- gpu_clusterpolicy_result.resources[0].status is not defined

Original file line number Diff line number Diff line change
Expand Up @@ -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/{{ mas_app_fqn }}.{{ mas_app_namespace }}"
register: app_sub_info

- name: "{{ mas_app_id }} : Debug existing Subscription"
Expand Down Expand Up @@ -46,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"
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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"
Expand All @@ -22,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"
5 changes: 3 additions & 2 deletions ibm/mas_devops/roles/suite_app_upgrade/tasks/main.yml
Original file line number Diff line number Diff line change
Expand Up @@ -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/{{ mas_app_fqn }}.{{ mas_app_namespace }}"
register: app_sub_info


Expand Down
8 changes: 6 additions & 2 deletions ibm/mas_devops/roles/suite_app_upgrade/tasks/upgrade.yml
Original file line number Diff line number Diff line change
Expand Up @@ -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/{{ mas_app_fqn }}.{{ mas_app_namespace }}"
register: suite_app_sub

- name: "Assert subscription exists"
Expand All @@ -25,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..."
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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"
Expand All @@ -34,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"
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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"
Expand Down Expand Up @@ -36,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"
Expand Down
12 changes: 8 additions & 4 deletions ibm/mas_devops/roles/suite_upgrade/tasks/upgrade.yml
Original file line number Diff line number Diff line change
Expand Up @@ -4,12 +4,15 @@
- 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
name: "{{ core_sub_info.resources[0].metadata.name }}"
namespace: "{{ mas_namespace }}"
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


Expand All @@ -18,9 +21,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
Expand Down
Loading