mirror of
https://github.com/ansible/awx-operator.git
synced 2026-05-08 06:12:54 +00:00
Add automatic backup PVC creation with create_backup_pvc option (#2097)
When users specify a custom backup_pvc name, the operator now automatically creates the PVC instead of failing with "does not exist, please create this pvc first." Changes: - Add create_backup_pvc variable (default: true) to backup defaults - Update error condition to check create_backup_pvc before failing - Update PVC creation condition to include create_backup_pvc - Add create_backup_pvc field to AWXBackup CRD Users who want the previous behavior can set create_backup_pvc: false.
This commit is contained in:
@@ -51,6 +51,10 @@ spec:
|
|||||||
backup_pvc:
|
backup_pvc:
|
||||||
description: Name of the backup PVC
|
description: Name of the backup PVC
|
||||||
type: string
|
type: string
|
||||||
|
create_backup_pvc:
|
||||||
|
description: If true (default), automatically create the backup PVC if it does not exist
|
||||||
|
type: boolean
|
||||||
|
default: true
|
||||||
backup_pvc_namespace:
|
backup_pvc_namespace:
|
||||||
description: (Deprecated) Namespace the PVC is in
|
description: (Deprecated) Namespace the PVC is in
|
||||||
type: string
|
type: string
|
||||||
|
|||||||
@@ -8,6 +8,9 @@ api_version: '{{ deployment_type }}.ansible.com/v1beta1'
|
|||||||
backup_pvc: ''
|
backup_pvc: ''
|
||||||
backup_pvc_namespace: "{{ ansible_operator_meta.namespace }}"
|
backup_pvc_namespace: "{{ ansible_operator_meta.namespace }}"
|
||||||
|
|
||||||
|
# If true (default), automatically create the backup PVC if it does not exist
|
||||||
|
create_backup_pvc: true
|
||||||
|
|
||||||
# Size of backup PVC if created dynamically
|
# Size of backup PVC if created dynamically
|
||||||
backup_storage_requirements: ''
|
backup_storage_requirements: ''
|
||||||
|
|
||||||
|
|||||||
@@ -22,17 +22,18 @@
|
|||||||
block:
|
block:
|
||||||
- name: Set error message
|
- name: Set error message
|
||||||
set_fact:
|
set_fact:
|
||||||
error_msg: "{{ backup_pvc }} does not exist, please create this pvc first."
|
error_msg: "{{ backup_pvc }} does not exist, please create this pvc first or ensure create_backup_pvc is set to true (default) for automatic backup_pvc creation."
|
||||||
|
|
||||||
- name: Handle error
|
- name: Handle error
|
||||||
import_tasks: error_handling.yml
|
import_tasks: error_handling.yml
|
||||||
|
|
||||||
- name: Fail early if pvc is defined but does not exist
|
- name: Fail early if pvc is defined but does not exist
|
||||||
fail:
|
fail:
|
||||||
msg: "{{ backup_pvc }} does not exist, please create this pvc first."
|
msg: "{{ backup_pvc }} does not exist, please create this pvc first or ensure create_backup_pvc is set to true (default) for automatic backup_pvc creation."
|
||||||
when:
|
when:
|
||||||
- backup_pvc != ''
|
- backup_pvc != ''
|
||||||
- provided_pvc.resources | length == 0
|
- provided_pvc.resources | length == 0
|
||||||
|
- not create_backup_pvc | bool
|
||||||
|
|
||||||
# If backup_pvc is defined, use in management-pod.yml.j2
|
# If backup_pvc is defined, use in management-pod.yml.j2
|
||||||
- name: Set default pvc name
|
- name: Set default pvc name
|
||||||
@@ -60,7 +61,7 @@
|
|||||||
namespace: "{{ backup_pvc_namespace }}"
|
namespace: "{{ backup_pvc_namespace }}"
|
||||||
ownerReferences: null
|
ownerReferences: null
|
||||||
when:
|
when:
|
||||||
- backup_pvc == '' or backup_pvc is not defined
|
- (backup_pvc == '' or backup_pvc is not defined) or (create_backup_pvc | bool)
|
||||||
|
|
||||||
- name: Set default postgres image
|
- name: Set default postgres image
|
||||||
set_fact:
|
set_fact:
|
||||||
|
|||||||
Reference in New Issue
Block a user