|
28 | 28 | - name: Block to configure cinder_volume_type when needed |
29 | 29 | when: configure_cinder_volume_type | default(false) | bool |
30 | 30 | 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 | + |
31 | 41 | - name: Create tempfile |
32 | 42 | ansible.builtin.tempfile: |
33 | 43 | state: file |
|
37 | 47 | - name: Write current glance customServiceConfig to tempfile |
38 | 48 | ansible.builtin.shell: | |
39 | 49 | 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 }} |
42 | 51 | changed_when: false |
43 | 52 |
|
44 | 53 | - name: Ensure cinder_volume_type is configured with proper value in tempfile |
|
65 | 74 | customServiceConfig: "{{ _glance_ini_content.content | b64decode }}" |
66 | 75 | ansible.builtin.shell: | |
67 | 76 | 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 }}" |
71 | 78 | changed_when: _glance_ini_file.changed |
72 | 79 | when: _glance_ini_file.changed |
| 80 | + |
| 81 | + # The controlplane patch triggers a reconciliation that propagates |
| 82 | + # customServiceConfig to the Glance CR. We must confirm that the |
| 83 | + # updated CR is available before waiting for Ready, otherwise oc wait |
| 84 | + # returns immediately on the stale Ready=True from before the rolling |
| 85 | + # update. |
| 86 | + - name: Verify Glance CR reflects the cinder_volume_type change |
| 87 | + environment: |
| 88 | + KUBECONFIG: "{{ cifmw_openshift_kubeconfig }}" |
| 89 | + PATH: "{{ cifmw_path }}" |
| 90 | + ansible.builtin.shell: | |
| 91 | + set -xe -o pipefail |
| 92 | + gcr=$(oc -n {{ namespace }} get glance -o custom-columns=NAME:.metadata.name --no-headers) |
| 93 | + oc -n {{ namespace }} get glance ${gcr} -o jsonpath='{.spec.customServiceConfig}' |
| 94 | + register: _glance_cr_config |
| 95 | + retries: 30 |
| 96 | + delay: 5 |
| 97 | + until: "'cinder_volume_type' in _glance_cr_config.stdout" |
| 98 | + when: _glance_ini_file.changed |
| 99 | + |
| 100 | + - name: Wait for controlplane to complete reconciliation |
| 101 | + environment: |
| 102 | + KUBECONFIG: "{{ cifmw_openshift_kubeconfig }}" |
| 103 | + PATH: "{{ cifmw_path }}" |
| 104 | + ansible.builtin.shell: | |
| 105 | + set -xe -o pipefail |
| 106 | + oc -n {{ namespace }} wait {{ _ctlplane_name.stdout }} --for condition=Ready --timeout=10m |
| 107 | + when: _glance_ini_file.changed |
0 commit comments