Skip to content

Commit 8bd8430

Browse files
stuggiclaude
andcommitted
Add PVC labeling step to backup playbook
Problem: Backup playbook checks for labeled PVCs but never actually labels them, causing OADP backup to skip PVCs even when they exist. Changes: - Added Step 9b: Label PVCs for OADP Backup (between database backup and OADP backup) - Label Galera backup PVCs by name pattern (mysql-backup-.*-backup-) - Catches: mysql-backup-openstack-backup-openstack - Catches: mysql-backup-openstack-cell1-backup-openstack-cell1 - Label service PVCs by service label selector: - Glance: service=glance - Cinder: service=cinder - Swift: service=swift - Manila: service=manila - Show summary of labeled PVCs (name, size, service) - All label commands use --overwrite to be idempotent Now OADP backup in Step 10 will correctly find and snapshot all labeled PVCs. Co-Authored-By: Claude Sonnet 4.5 <noreply@anthropic.com>
1 parent 774e8ef commit 8bd8430

1 file changed

Lines changed: 78 additions & 0 deletions

File tree

docs/dev/playbooks/backup-openstack-ctlplane.yaml

Lines changed: 78 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -504,6 +504,84 @@
504504
msg: "No GaleraBackup cronjobs found, skipping database backup"
505505
when: galera_backup_cronjobs.stdout == ""
506506

507+
# Step 9b: Label PVCs for backup
508+
- name: Print Step 9b header
509+
ansible.builtin.debug:
510+
msg:
511+
- "========================================"
512+
- "Step 9b: Label PVCs for OADP Backup"
513+
- "========================================"
514+
- ""
515+
- "Labeling PVCs with openstack.org/backup=true for CSI snapshot backup"
516+
517+
- name: Label Galera backup PVCs (database dump storage)
518+
ansible.builtin.shell: |
519+
# Get all PVCs matching Galera backup naming pattern
520+
oc get pvc -n {{ openstack_namespace }} --no-headers -o custom-columns=NAME:.metadata.name | \
521+
grep -E '^mysql-backup-.*-backup-' || true
522+
register: galera_backup_pvcs
523+
changed_when: false
524+
525+
- name: Apply backup label to Galera backup PVCs
526+
ansible.builtin.shell: |
527+
oc label pvc {{ item }} -n {{ openstack_namespace }} openstack.org/backup=true --overwrite
528+
loop: "{{ galera_backup_pvcs.stdout_lines }}"
529+
changed_when: true
530+
when: galera_backup_pvcs.stdout_lines | length > 0
531+
532+
- name: Label Glance PVCs (image storage)
533+
ansible.builtin.shell: |
534+
oc label pvc -n {{ openstack_namespace }} -l service=glance openstack.org/backup=true --overwrite
535+
register: glance_pvc_label
536+
changed_when: glance_pvc_label.rc == 0
537+
failed_when: false
538+
539+
- name: Label Cinder PVCs (volume storage)
540+
ansible.builtin.shell: |
541+
oc label pvc -n {{ openstack_namespace }} -l service=cinder openstack.org/backup=true --overwrite
542+
register: cinder_pvc_label
543+
changed_when: cinder_pvc_label.rc == 0
544+
failed_when: false
545+
546+
- name: Label Swift PVCs (object storage)
547+
ansible.builtin.shell: |
548+
oc label pvc -n {{ openstack_namespace }} -l service=swift openstack.org/backup=true --overwrite
549+
register: swift_pvc_label
550+
changed_when: swift_pvc_label.rc == 0
551+
failed_when: false
552+
553+
- name: Label Manila PVCs (share storage)
554+
ansible.builtin.shell: |
555+
oc label pvc -n {{ openstack_namespace }} -l service=manila openstack.org/backup=true --overwrite
556+
register: manila_pvc_label
557+
changed_when: manila_pvc_label.rc == 0
558+
failed_when: false
559+
560+
- name: Get count of labeled PVCs
561+
ansible.builtin.shell: |
562+
oc get pvc -n {{ openstack_namespace }} -l openstack.org/backup=true --no-headers 2>/dev/null | wc -l
563+
register: labeled_pvc_count
564+
changed_when: false
565+
566+
- name: List labeled PVCs
567+
ansible.builtin.shell: |
568+
oc get pvc -n {{ openstack_namespace }} -l openstack.org/backup=true -o custom-columns=NAME:.metadata.name,SIZE:.spec.resources.requests.storage,SERVICE:.metadata.labels.service --no-headers
569+
register: labeled_pvc_list
570+
changed_when: false
571+
when: labeled_pvc_count.stdout|int > 0
572+
573+
- name: Print Step 9b completion
574+
ansible.builtin.debug:
575+
msg:
576+
- "✓ Labeled {{ labeled_pvc_count.stdout }} PVC(s) for backup:"
577+
- "{{ labeled_pvc_list.stdout_lines }}"
578+
when: labeled_pvc_count.stdout|int > 0
579+
580+
- name: Print Step 9b no PVCs message
581+
ansible.builtin.debug:
582+
msg: "No PVCs found to label (this is OK if not using persistent storage)"
583+
when: labeled_pvc_count.stdout|int == 0
584+
507585
# Step 10: Backup Storage Volumes (OADP)
508586
- name: Print Step 10 header
509587
ansible.builtin.debug:

0 commit comments

Comments
 (0)