Fix custom backup PVC name not used with create_backup_pvc (#2105)

Use backup_pvc for custom backup PVC name in templates

When backup_pvc is specified with create_backup_pvc: true, the PVC
template and ownerReference removal used the hardcoded default name
(deployment_name-backup-claim) instead of the user-specified name.
This caused the management pod to reference a PVC that didn't exist.

Replace backup_claim variable with backup_pvc throughout the backup
role so the resolved PVC name is used consistently in all templates.

Authored By: Adam Knochowski <aknochow@redhat.com>
Assisted By: Claude
This commit is contained in:
aknochow
2026-03-05 07:22:22 -05:00
committed by GitHub
parent c996c88178
commit 56f10cf966
4 changed files with 5 additions and 5 deletions

View File

@@ -43,7 +43,7 @@
# by default, it will re-use the old pvc if already created (unless a pvc is provided)
- name: Set PVC to use for backup
set_fact:
backup_claim: "{{ backup_pvc | default(_default_backup_pvc, true) }}"
backup_pvc: "{{ backup_pvc | default(_default_backup_pvc, true) }}"
- block:
- name: Create PVC for backup
@@ -57,7 +57,7 @@
apiVersion: v1
kind: PersistentVolumeClaim
metadata:
name: "{{ deployment_name }}-backup-claim"
name: "{{ backup_pvc }}"
namespace: "{{ backup_pvc_namespace }}"
ownerReferences: null
when:

View File

@@ -9,5 +9,5 @@
namespace: "{{ ansible_operator_meta.namespace }}"
status:
backupDirectory: "{{ backup_dir }}"
backupClaim: "{{ backup_claim }}"
backupClaim: "{{ backup_pvc }}"
when: backup_complete

View File

@@ -2,7 +2,7 @@
apiVersion: v1
kind: PersistentVolumeClaim
metadata:
name: {{ deployment_name }}-backup-claim
name: {{ backup_pvc }}
namespace: "{{ backup_pvc_namespace }}"
ownerReferences: null
labels:

View File

@@ -27,6 +27,6 @@ spec:
volumes:
- name: {{ ansible_operator_meta.name }}-backup
persistentVolumeClaim:
claimName: {{ backup_claim }}
claimName: {{ backup_pvc }}
readOnly: false
restartPolicy: Never