Skip to content

Commit 6833755

Browse files
stuggiclaude
authored andcommitted
[update] Improve update of new operator version
Add validation to ensure the subscription's installedCSV matches currentCSV after the installplan is applied. This confirms the operator upgrade has completed successfully before proceeding with the rest of the update workflow. Uses label selector to find the subscription rather than hardcoding the name. Add missing wait for OpenStackControlPlane to reach ready state after operator updates in OLM mode. Include a 60-second delay before the wait to allow the control plane's ready condition to transition from its initial state, preventing premature completion while the control plane is still reconciling the operator changes. This step is important to validate that the current deployed control plane can successfully reach ready state with the new set of operators, but using the old service containers. Otherwise we start alreay updating to the new service images. Jira: OSPRH-23688 Co-Authored-By: Claude <[email protected]> Signed-off-by: Martin Schuppert <[email protected]>
1 parent f41088f commit 6833755

File tree

3 files changed

+57
-0
lines changed

3 files changed

+57
-0
lines changed

roles/update/README.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -21,5 +21,6 @@ Role to run update
2121
* `cifmw_update_ansible_ssh_private_key_file`: (String) Define the path to the private key file used for the compute nodes.
2222
* `cifmw_update_wait_retries_reboot`: (Integer) Number of retries to wait for a compute node reboot. One retry is done every five seconds. Default to 60, so five minutes.
2323
* `cifmw_update_resources_monitoring_interval`: (Integer) Interval, in seconds, between two resources monitor during update. Default to 10 seconds.
24+
* `cifmw_update_wait_controplane_status_change_sec`: (Integer) Time, in seconds, to wait before checking openstack control plane deployment status. Used when need to wait to allow the control plane's ready condition to transition from its initial state, preventing premature completion while the control plane is still reconciling the operator changes. Defaults to `60`.
2425

2526
## Examples

roles/update/defaults/main.yml

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -67,3 +67,8 @@ cifmw_update_ctl_plane_max_tries: 84
6767

6868
# Resource Monitoring during update
6969
cifmw_update_resources_monitoring_interval: 10 # in seconds.
70+
71+
# How long should we wait (in seconds) before checking control plane status. Useful
72+
# when we install the new operators and have to wait until they start to reconcile
73+
# the current deployed control plane.
74+
cifmw_update_wait_controplane_status_change_sec: 60

roles/update/tasks/main.yml

Lines changed: 51 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -50,6 +50,34 @@
5050
- cifmw_ci_gen_kustomize_values_installplan_approval is defined
5151
- cifmw_ci_gen_kustomize_values_installplan_approval | lower == 'manual'
5252

53+
- name: Validate subscription CSV version after installplan
54+
when:
55+
- cifmw_ci_gen_kustomize_values_installplan_approval is defined
56+
- cifmw_ci_gen_kustomize_values_installplan_approval | lower == 'manual'
57+
block:
58+
- name: Wait for subscription installedCSV to match currentCSV
59+
kubernetes.core.k8s_info:
60+
kubeconfig: "{{ cifmw_openshift_kubeconfig }}"
61+
api_key: "{{ cifmw_openshift_token | default(omit) }}"
62+
context: "{{ cifmw_openshift_context | default(omit) }}"
63+
api_version: operators.coreos.com/v1alpha1
64+
kind: Subscription
65+
namespace: openstack-operators
66+
label_selectors:
67+
- operators.coreos.com/openstack-operator.openstack-operators
68+
register: _cifmw_update_subscription_info
69+
until: >
70+
_cifmw_update_subscription_info.resources | length > 0
71+
and
72+
_cifmw_update_subscription_info.resources[0].status.installedCSV is defined
73+
and
74+
_cifmw_update_subscription_info.resources[0].status.currentCSV is defined
75+
and
76+
_cifmw_update_subscription_info.resources[0].status.installedCSV ==
77+
_cifmw_update_subscription_info.resources[0].status.currentCSV
78+
retries: 30
79+
delay: 10
80+
5381
- name: Handle OpenStack operator initialization
5482
when:
5583
- cifmw_ci_gen_kustomize_values_deployment_version is defined
@@ -145,6 +173,29 @@
145173
Got new version {{ cifmw_update_next_available_version }}
146174
({{ openstackversion_info.resources[0].status.deployedVersion }})
147175
176+
- name: Wait for OpenStackControlPlane to be ready after operator update
177+
when:
178+
- not (cifmw_update_run_dryrun | bool)
179+
- cifmw_ci_gen_kustomize_values_deployment_version is defined
180+
block:
181+
- name: Delay to allow OpenStackControlPlane ready condition to transition
182+
# If we install the new operators, the control plane is in 'ready' status, so
183+
# we need to wait a few seconds so it changes to a 'non-ready' status first.
184+
ansible.builtin.pause:
185+
seconds: "{{ cifmw_update_wait_controplane_status_change_sec }}"
186+
187+
- name: Wait for OpenStackControlPlane ready condition
188+
environment:
189+
KUBECONFIG: "{{ cifmw_openshift_kubeconfig }}"
190+
PATH: "{{ cifmw_path }}"
191+
ansible.builtin.command:
192+
cmd: >-
193+
oc wait OpenStackControlPlane
194+
--all
195+
--namespace={{ cifmw_update_namespace }}
196+
--for=condition=ready
197+
--timeout={{ cifmw_update_openstack_update_run_timeout }}
198+
148199
- name: Set openstack_update_run Makefile environment variables
149200
tags:
150201
- always

0 commit comments

Comments
 (0)