Skip to content

Commit aaa3ded

Browse files
fmountclaude
andcommitted
[cinder_multiattach] Wait for Glance reconciliation after config patch
The oc wait --for=condition=Ready on the controlplane returns immediately when the condition is already true, before the StatefulSet rolling update triggered by the config change completes. This causes a race with subsequent hooks (e.g. amphora image upload) that depend on Glance being stable. Replace the inline oc wait with two explicit steps: 1. Poll the Glance CR until customServiceConfig reflects the change 2. Wait for both the glance CR and the controlplane Ready condition after reconciliation starts Closes: OSPCIX-1454 Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com> Signed-off-by: Francesco Pantano <fpantano@redhat.com>
1 parent 670f562 commit aaa3ded

1 file changed

Lines changed: 56 additions & 5 deletions

File tree

hooks/playbooks/cinder_multiattach_volume_type.yml

Lines changed: 56 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -28,6 +28,16 @@
2828
- name: Block to configure cinder_volume_type when needed
2929
when: configure_cinder_volume_type | default(false) | bool
3030
block:
31+
- name: Get OpenStackControlPlane CR name
32+
environment:
33+
KUBECONFIG: "{{ cifmw_openshift_kubeconfig }}"
34+
PATH: "{{ cifmw_path }}"
35+
ansible.builtin.shell: |
36+
set -xe -o pipefail
37+
oc get openstackcontrolplane -o name -n {{ namespace }}
38+
register: _ctlplane_name
39+
changed_when: false
40+
3141
- name: Create tempfile
3242
ansible.builtin.tempfile:
3343
state: file
@@ -37,8 +47,7 @@
3747
- name: Write current glance customServiceConfig to tempfile
3848
ansible.builtin.shell: |
3949
set -xe -o pipefail
40-
crname=$(oc get openstackcontrolplane -o name -n {{ namespace }})
41-
oc -n {{ namespace }} get ${crname} -o jsonpath={.spec.glance.template.customServiceConfig} > {{ _glance_custom_service_config_file.path }}
50+
oc -n {{ namespace }} get {{ _ctlplane_name.stdout }} -o jsonpath={.spec.glance.template.customServiceConfig} > {{ _glance_custom_service_config_file.path }}
4251
changed_when: false
4352

4453
- name: Ensure cinder_volume_type is configured with proper value in tempfile
@@ -65,8 +74,50 @@
6574
customServiceConfig: "{{ _glance_ini_content.content | b64decode }}"
6675
ansible.builtin.shell: |
6776
set -xe -o pipefail
68-
crname=$(oc get openstackcontrolplane -o name -n {{ namespace }})
69-
oc -n {{ namespace }} patch ${crname} --type=merge --patch "{{ _yaml_patch | to_nice_yaml }}"
70-
oc -n {{ namespace }} wait ${crname} --for condition=Ready --timeout=10m
77+
oc -n {{ namespace }} patch {{ _ctlplane_name.stdout }} --type=merge --patch "{{ _yaml_patch | to_nice_yaml }}"
7178
changed_when: _glance_ini_file.changed
7279
when: _glance_ini_file.changed
80+
81+
# The controlplane patch triggers a reconciliation that propagates
82+
# customServiceConfig to the Glance CR. We confirm the Glance CR
83+
# spec is updated, then we check that the Glance CR has finished
84+
# reconciling before trusting the controlplane Ready condition.
85+
- name: Get Glance CR name # noqa: no-handler
86+
environment:
87+
KUBECONFIG: "{{ cifmw_openshift_kubeconfig }}"
88+
PATH: "{{ cifmw_path }}"
89+
ansible.builtin.shell: |
90+
set -xe -o pipefail
91+
oc -n {{ namespace }} get glance -o name
92+
register: _glance_name
93+
changed_when: false
94+
when: _glance_ini_file.changed
95+
96+
- name: Verify Glance CR reflects the cinder_volume_type change # noqa: no-handler
97+
environment:
98+
KUBECONFIG: "{{ cifmw_openshift_kubeconfig }}"
99+
PATH: "{{ cifmw_path }}"
100+
ansible.builtin.shell: |
101+
set -xe -o pipefail
102+
oc -n {{ namespace }} get {{ _glance_name.stdout }} -o jsonpath='{.spec.customServiceConfig}'
103+
register: _glance_cr_config
104+
retries: 30
105+
delay: 5
106+
until: "'cinder_volume_type' in _glance_cr_config.stdout"
107+
when: _glance_ini_file.changed
108+
109+
- name: Wait for reconciliation to start
110+
pause:
111+
seconds: 10
112+
113+
- name: Wait for both glance and the ctlplane CRs to complete reconciliation # noqa: no-handler
114+
environment:
115+
KUBECONFIG: "{{ cifmw_openshift_kubeconfig }}"
116+
PATH: "{{ cifmw_path }}"
117+
ansible.builtin.shell: |
118+
set -xe -o pipefail
119+
oc -n {{ namespace }} wait {{ item }} --for condition=Ready --timeout=10m
120+
loop:
121+
- "{{ _glance_name.stdout }}"
122+
- "{{ _ctlplane_name.stdout }}"
123+
when: _glance_ini_file.changed

0 commit comments

Comments
 (0)