Skip to content

Commit c08588e

Browse files
stuggiclaude
andcommitted
[b/r] Add live progress reporting for OADP backup waits
Replace oc wait with a polling loop that writes progress directly to /dev/tty for live visibility during Ansible execution. Shows phase, items backed up, and Data Mover operations (only when present). Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
1 parent b924edb commit c08588e

1 file changed

Lines changed: 49 additions & 25 deletions

File tree

docs/dev/backup-restore/backup/backup-openstack.yaml

Lines changed: 49 additions & 25 deletions
Original file line numberDiff line numberDiff line change
@@ -193,22 +193,34 @@
193193

194194
- name: Wait for PVC backup to complete
195195
ansible.builtin.shell: |
196-
oc wait --for=jsonpath='{.status.phase}'=Completed \
197-
backup/openstack-backup-pvcs-{{ backup_name_suffix }} \
198-
-n {{ oadp_namespace }} \
199-
--timeout={{ oadp_backup_timeout }}
200-
changed_when: false
201-
202-
- name: Get PVC backup status
203-
ansible.builtin.shell: |
204-
oc get backup openstack-backup-pvcs-{{ backup_name_suffix }} -n {{ oadp_namespace }} \
205-
-o jsonpath='{.status.phase}'
206-
register: pvc_backup_status
196+
BACKUP_NAME="openstack-backup-pvcs-{{ backup_name_suffix }}"
197+
TIMEOUT={{ oadp_backup_timeout | regex_replace('[^0-9]', '') }}
198+
ELAPSED=0
199+
while [ $ELAPSED -lt $((TIMEOUT * 60)) ]; do
200+
read -r PHASE ITEMS_DONE ITEMS_TOTAL OPS_DONE OPS_TOTAL <<< $(oc get backup ${BACKUP_NAME} -n {{ oadp_namespace }} \
201+
-o jsonpath='{.status.phase} {.status.progress.itemsBackedUp} {.status.progress.totalItems} {.status.backupItemOperationsCompleted} {.status.backupItemOperationsAttempted}' 2>/dev/null)
202+
PROGRESS="Phase: ${PHASE:-Pending} | Items: ${ITEMS_DONE:-0}/${ITEMS_TOTAL:-?}"
203+
[ -n "${OPS_TOTAL}" ] && PROGRESS="${PROGRESS} | Operations: ${OPS_DONE:-0}/${OPS_TOTAL}"
204+
echo " $(date +%H:%M:%S) ${PROGRESS}" > /dev/tty
205+
case "${PROGRESS}" in
206+
*"Phase: Completed"*)
207+
echo "${PROGRESS}"
208+
exit 0 ;;
209+
*"Phase: Failed"*|*"Phase: PartiallyFailed"*)
210+
echo "${PROGRESS}" >&2
211+
exit 1 ;;
212+
esac
213+
sleep 10
214+
ELAPSED=$((ELAPSED + 10))
215+
done
216+
echo "Timeout waiting for backup ${BACKUP_NAME} after ${TIMEOUT}m" >&2
217+
exit 1
218+
register: pvc_backup_progress
207219
changed_when: false
208220

209221
- name: Print Step 2 result
210222
ansible.builtin.debug:
211-
msg: "PVC backup status: {{ pvc_backup_status.stdout }}"
223+
msg: "PVC backup: {{ pvc_backup_progress.stdout }}"
212224

213225
# ========================================
214226
# Step 3: OADP Resources Backup
@@ -233,7 +245,7 @@
233245
- name: Pause before resources backup
234246
ansible.builtin.pause:
235247
prompt: >-
236-
Step 2 complete: PVC backup ({{ pvc_backup_status.stdout }}).
248+
Step 2 complete: PVC backup ({{ pvc_backup_progress.stdout }}).
237249
Press Enter to create resources backup, or Ctrl+C then 'A' to abort
238250
when: not (auto_ack | bool)
239251

@@ -244,22 +256,34 @@
244256

245257
- name: Wait for resources backup to complete
246258
ansible.builtin.shell: |
247-
oc wait --for=jsonpath='{.status.phase}'=Completed \
248-
backup/openstack-backup-resources-{{ backup_name_suffix }} \
249-
-n {{ oadp_namespace }} \
250-
--timeout={{ oadp_backup_timeout }}
251-
changed_when: false
252-
253-
- name: Get resources backup status
254-
ansible.builtin.shell: |
255-
oc get backup openstack-backup-resources-{{ backup_name_suffix }} -n {{ oadp_namespace }} \
256-
-o jsonpath='{.status.phase}'
257-
register: resources_backup_status
259+
BACKUP_NAME="openstack-backup-resources-{{ backup_name_suffix }}"
260+
TIMEOUT={{ oadp_backup_timeout | regex_replace('[^0-9]', '') }}
261+
ELAPSED=0
262+
while [ $ELAPSED -lt $((TIMEOUT * 60)) ]; do
263+
read -r PHASE ITEMS_DONE ITEMS_TOTAL OPS_DONE OPS_TOTAL <<< $(oc get backup ${BACKUP_NAME} -n {{ oadp_namespace }} \
264+
-o jsonpath='{.status.phase} {.status.progress.itemsBackedUp} {.status.progress.totalItems} {.status.backupItemOperationsCompleted} {.status.backupItemOperationsAttempted}' 2>/dev/null)
265+
PROGRESS="Phase: ${PHASE:-Pending} | Items: ${ITEMS_DONE:-0}/${ITEMS_TOTAL:-?}"
266+
[ -n "${OPS_TOTAL}" ] && PROGRESS="${PROGRESS} | Operations: ${OPS_DONE:-0}/${OPS_TOTAL}"
267+
echo " $(date +%H:%M:%S) ${PROGRESS}" > /dev/tty
268+
case "${PROGRESS}" in
269+
*"Phase: Completed"*)
270+
echo "${PROGRESS}"
271+
exit 0 ;;
272+
*"Phase: Failed"*|*"Phase: PartiallyFailed"*)
273+
echo "${PROGRESS}" >&2
274+
exit 1 ;;
275+
esac
276+
sleep 10
277+
ELAPSED=$((ELAPSED + 10))
278+
done
279+
echo "Timeout waiting for backup ${BACKUP_NAME} after ${TIMEOUT}m" >&2
280+
exit 1
281+
register: resources_backup_progress
258282
changed_when: false
259283

260284
- name: Print Step 3 result
261285
ansible.builtin.debug:
262-
msg: "Resources backup status: {{ resources_backup_status.stdout }}"
286+
msg: "Resources backup: {{ resources_backup_progress.stdout }}"
263287

264288
# ========================================
265289
# Summary

0 commit comments

Comments
 (0)