Skip to content
Open
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
55 changes: 50 additions & 5 deletions hooks/playbooks/cinder_multiattach_volume_type.yml
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -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
Expand All @@ -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
Loading