Skip to content

Commit d08d483

Browse files
stuggiclaude
andcommitted
[b/r] Add live progress reporting for OADP restore waits
Replace until/retries polling with a shell loop that writes progress directly to /dev/tty for live visibility during Ansible execution. Shows phase and items restored count. Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
1 parent c08588e commit d08d483

1 file changed

Lines changed: 21 additions & 6 deletions

File tree

docs/dev/backup-restore/restore/wait-for-restore.yaml

Lines changed: 21 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -11,15 +11,30 @@
1111
# restore_timeout: Timeout in seconds (default: 900)
1212
# strict_restore: Fail on PartiallyFailed (default: true)
1313

14-
- name: "{{ step_name }}: Poll restore phase"
14+
- name: "{{ step_name }}: Wait for restore with progress"
1515
ansible.builtin.shell: |
16-
oc get restore {{ restore_name }} -n {{ oadp_namespace | default('openshift-adp') }} \
17-
-o jsonpath='{.status.phase}' 2>/dev/null || echo "NotFound"
16+
RESTORE_NAME="{{ restore_name }}"
17+
NS="{{ oadp_namespace | default('openshift-adp') }}"
18+
TIMEOUT={{ restore_timeout | default(900) }}
19+
ELAPSED=0
20+
while [ $ELAPSED -lt $TIMEOUT ]; do
21+
read -r PHASE ITEMS_DONE ITEMS_TOTAL <<< $(oc get restore ${RESTORE_NAME} -n ${NS} \
22+
-o jsonpath='{.status.phase} {.status.progress.itemsRestored} {.status.progress.totalItems}' 2>/dev/null)
23+
PHASE=${PHASE:-Pending}
24+
PROGRESS="Phase: ${PHASE} | Items: ${ITEMS_DONE:-0}/${ITEMS_TOTAL:-?}"
25+
echo " $(date +%H:%M:%S) ${PROGRESS}" > /dev/tty
26+
case "${PHASE}" in
27+
Completed|PartiallyFailed|Failed|FailedValidation)
28+
echo "${PHASE}"
29+
exit 0 ;;
30+
esac
31+
sleep 10
32+
ELAPSED=$((ELAPSED + 10))
33+
done
34+
echo "Timeout waiting for restore ${RESTORE_NAME} after $((TIMEOUT/60))m" >&2
35+
exit 1
1836
register: restore_phase
1937
changed_when: false
20-
until: restore_phase.stdout in ["Completed", "PartiallyFailed", "Failed", "FailedValidation"]
21-
retries: "{{ ((restore_timeout | default(900)) | int / 10) | int }}"
22-
delay: 10
2338

2439
- name: "{{ step_name }}: Get restore details on non-Completed phase"
2540
ansible.builtin.shell: |

0 commit comments

Comments
 (0)