Skip to content

Commit 33e304d

Browse files
author
Gais Ameer
committed
[hooks] Wait for cinder-backup services before running backup/restore checks
The backup/restore validation in distributed architectures could start hitting the Cinder API before all per-AZ cinder-backup services had finished initializing, causing intermittent failures. Adding a wait task that polls `openstack volume service list` and blocks until no cinder-backup service reports state as "down" in any availability zone, with a rescue block that dumps the last observed Host/State values before failing. Signed-off-by: Gais Ameer <gameer@redhat.com>
1 parent 97f346f commit 33e304d

1 file changed

Lines changed: 34 additions & 1 deletion

File tree

hooks/playbooks/cinder_backups.yaml

Lines changed: 34 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
---
2-
# Test Cinder backup and restore capabilities across availability zones in dz-storage DT
2+
# Test Cinder backup and restore capabilities across availability zones in dz-storage/DCN DT
33
# Tests three scenarios:
44
# 1. AZ1 backs up to AZ1 and restores to AZ1
55
# 2. AZ1 backs up to AZ2 and restores to AZ1
@@ -14,6 +14,39 @@
1414
KUBECONFIG: "{{ cifmw_openshift_kubeconfig | default('/home/' + ansible_user | default('zuul') + '/.kube/config') }}"
1515
PATH: "{{ cifmw_path | default(ansible_env.PATH) }}"
1616
tasks:
17+
- name: Wait for cinder-backup services to be up in all availability zones
18+
block:
19+
- name: Check cinder-backup service status
20+
ansible.builtin.command: >-
21+
oc rsh
22+
-n {{ cifmw_openstack_namespace }}
23+
openstackclient
24+
openstack volume service list
25+
--service cinder-backup
26+
-c Host -c State
27+
-f json
28+
register: cinder_backup_service_status
29+
until: >-
30+
(cinder_backup_service_status.stdout | from_json | length > 0)
31+
and ((cinder_backup_service_status.stdout | from_json)
32+
| selectattr('State', 'equalto', 'down')
33+
| list
34+
| length == 0)
35+
retries: 30
36+
delay: 10
37+
rescue:
38+
- name: Show cinder-backup service status
39+
ansible.builtin.debug:
40+
msg: >-
41+
Here is the output of openstack volume service list:
42+
{{ cinder_backup_service_status.stdout | default('<no output>') }}
43+
- name: Fail because cinder-backup services are missing or still down
44+
ansible.builtin.fail:
45+
msg: >-
46+
Timed out waiting for cinder-backup services to be up in all
47+
availability zones (or no cinder-backup services were found
48+
at all). See the debug output above for the last observed
49+
Host/State values.
1750
# ==================================================================================
1851
# Scenario 1: AZ1 backs up to AZ1 and restores to AZ1
1952
# ==================================================================================

0 commit comments

Comments
 (0)