From 8334297ade31320324a388222d6584872b6f2e12 Mon Sep 17 00:00:00 2001 From: Francesco Pantano Date: Wed, 15 Jul 2026 22:44:38 +0200 Subject: [PATCH] [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 (Ready=False) Closes: OSPCIX-1454 Co-Authored-By: Claude Opus 4.6 Signed-off-by: Francesco Pantano --- .../cinder_multiattach_volume_type.yml | 55 +++++++++++++++++-- 1 file changed, 50 insertions(+), 5 deletions(-) diff --git a/hooks/playbooks/cinder_multiattach_volume_type.yml b/hooks/playbooks/cinder_multiattach_volume_type.yml index 4ccd6b472..bc22fb2aa 100644 --- a/hooks/playbooks/cinder_multiattach_volume_type.yml +++ b/hooks/playbooks/cinder_multiattach_volume_type.yml @@ -28,6 +28,16 @@ - name: Block to configure cinder_volume_type when needed when: configure_cinder_volume_type | default(false) | bool block: + - name: Get OpenStackControlPlane CR name + environment: + KUBECONFIG: "{{ cifmw_openshift_kubeconfig }}" + PATH: "{{ cifmw_path }}" + ansible.builtin.shell: | + set -xe -o pipefail + oc get openstackcontrolplane -o name -n {{ namespace }} + register: _ctlplane_name + changed_when: false + - name: Create tempfile ansible.builtin.tempfile: state: file @@ -37,8 +47,7 @@ - name: Write current glance customServiceConfig to tempfile ansible.builtin.shell: | set -xe -o pipefail - crname=$(oc get openstackcontrolplane -o name -n {{ namespace }}) - oc -n {{ namespace }} get ${crname} -o jsonpath={.spec.glance.template.customServiceConfig} > {{ _glance_custom_service_config_file.path }} + oc -n {{ namespace }} get {{ _ctlplane_name.stdout }} -o jsonpath={.spec.glance.template.customServiceConfig} > {{ _glance_custom_service_config_file.path }} changed_when: false - name: Ensure cinder_volume_type is configured with proper value in tempfile @@ -65,8 +74,44 @@ customServiceConfig: "{{ _glance_ini_content.content | b64decode }}" ansible.builtin.shell: | set -xe -o pipefail - crname=$(oc get openstackcontrolplane -o name -n {{ namespace }}) - oc -n {{ namespace }} patch ${crname} --type=merge --patch "{{ _yaml_patch | to_nice_yaml }}" - oc -n {{ namespace }} wait ${crname} --for condition=Ready --timeout=10m + oc -n {{ namespace }} patch {{ _ctlplane_name.stdout }} --type=merge --patch "{{ _yaml_patch | to_nice_yaml }}" changed_when: _glance_ini_file.changed when: _glance_ini_file.changed + + # After patching the controlplane, there is a window where both + # Glance and the controlplane still report Ready because the + # reconciliation has not propagated yet. Wait for Glance to + # enter reconciliation (Ready=False) before waiting for it + # and the controlplane to become Ready again. + - name: Get Glance CR name # noqa: no-handler + environment: + KUBECONFIG: "{{ cifmw_openshift_kubeconfig }}" + PATH: "{{ cifmw_path }}" + ansible.builtin.shell: | + set -xe -o pipefail + oc -n {{ namespace }} get glance -o name + register: _glance_name + changed_when: false + when: _glance_ini_file.changed + + - name: Wait for Glance reconciliation to start # noqa: no-handler + environment: + KUBECONFIG: "{{ cifmw_openshift_kubeconfig }}" + PATH: "{{ cifmw_path }}" + ansible.builtin.shell: | + set -xe -o pipefail + oc -n {{ namespace }} wait {{ _glance_name.stdout }} \ + --for=condition=Ready=False --timeout=5m + when: _glance_ini_file.changed + + - name: Wait for Glance and the ctlplane to complete reconciliation # noqa: no-handler + environment: + KUBECONFIG: "{{ cifmw_openshift_kubeconfig }}" + PATH: "{{ cifmw_path }}" + ansible.builtin.shell: | + set -xe -o pipefail + oc -n {{ namespace }} wait {{ item }} --for condition=Ready --timeout=10m + loop: + - "{{ _glance_name.stdout }}" + - "{{ _ctlplane_name.stdout }}" + when: _glance_ini_file.changed