Skip to content

Commit 500aa49

Browse files
stuggiclaude
authored andcommitted
[cifmw_backup_restore] Skip Swift tests when Swift is not enabled and cleanup namespace filters
The e2e flow unconditionally ran Swift data upload/verify steps even when Swift was not deployed, causing failures on non-Swift environments. Query `.spec.swift.enabled` from the `OpenStackControlPlane` CR before attempting Swift operations and skip gracefully when Swift is absent. Also remove unnecessary `namespaces` filter from resource modifier rules and `includedNamespaces` from Swift xattr backup hook — the backup already scopes to the openstack namespace via labelSelector and omitting the filter makes rules apply to all matching resources. Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com> Signed-off-by: Martin Schuppert <mschuppert@redhat.com>
1 parent 21dbd39 commit 500aa49

3 files changed

Lines changed: 28 additions & 10 deletions

File tree

roles/cifmw_backup_restore/tasks/e2e.yml

Lines changed: 28 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -78,9 +78,34 @@
7878
# ========================================
7979
# Step 2.5: Upload Swift test data
8080
# ========================================
81-
- name: Upload Swift test data before backup
82-
ansible.builtin.include_tasks: swift_data_upload.yml
81+
- name: Detect Swift and upload test data
8382
when: cifmw_backup_restore_test_swift_data | bool
83+
block:
84+
- name: Check if Swift is enabled in the control plane
85+
ansible.builtin.shell: |
86+
set -o pipefail
87+
oc get openstackcontrolplane -n {{ cifmw_backup_restore_namespace }} \
88+
-o jsonpath='{.items[0].spec.swift.enabled}'
89+
register: _swift_enabled_result
90+
changed_when: false
91+
failed_when: false
92+
93+
- name: Set Swift availability fact
94+
ansible.builtin.set_fact:
95+
_cifmw_backup_restore_swift_available: >-
96+
{{ (_swift_enabled_result.rc == 0) and
97+
(_swift_enabled_result.stdout | default('false') | bool) }}
98+
99+
- name: Skip Swift tests — Swift is not enabled
100+
ansible.builtin.debug:
101+
msg: >-
102+
Swift is not enabled in the OpenStackControlPlane CR.
103+
Skipping Swift data upload/verify steps.
104+
when: not (_cifmw_backup_restore_swift_available | bool)
105+
106+
- name: Upload Swift test data before backup
107+
ansible.builtin.include_tasks: swift_data_upload.yml
108+
when: _cifmw_backup_restore_swift_available | bool
84109

85110
# ========================================
86111
# Step 3: Create backup
@@ -275,6 +300,7 @@
275300
ansible.builtin.include_tasks: swift_data_verify.yml
276301
when:
277302
- cifmw_backup_restore_test_swift_data | bool
303+
- _cifmw_backup_restore_swift_available | default(false) | bool
278304
- cifmw_backup_restore_run_restore | bool
279305

280306
# ========================================

roles/cifmw_backup_restore/templates/00-resource-modifiers-configmap.yaml.j2

Lines changed: 0 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -11,8 +11,6 @@ data:
1111
resourceModifierRules:
1212
- conditions:
1313
groupResource: "*"
14-
namespaces:
15-
- {{ cifmw_backup_restore_namespace }}
1614
mergePatches:
1715
- patchData: |
1816
metadata:
@@ -21,8 +19,6 @@ data:
2119
kubectl.kubernetes.io/last-applied-configuration: null
2220
- conditions:
2321
groupResource: openstackcontrolplanes.core.openstack.org
24-
namespaces:
25-
- {{ cifmw_backup_restore_namespace }}
2622
mergePatches:
2723
- patchData: |
2824
metadata:
@@ -31,8 +27,6 @@ data:
3127
core.openstack.org/deployment-stage: "infrastructure-only"
3228
- conditions:
3329
groupResource: instancehas.instanceha.openstack.org
34-
namespaces:
35-
- {{ cifmw_backup_restore_namespace }}
3630
mergePatches:
3731
- patchData: |
3832
spec:

roles/cifmw_backup_restore/templates/backup-pvcs.yaml.j2

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -27,8 +27,6 @@ spec:
2727
hooks:
2828
resources:
2929
- name: swift-xattr-backup
30-
includedNamespaces:
31-
- {{ cifmw_backup_restore_namespace }}
3230
labelSelector:
3331
matchLabels:
3432
component: swift-storage

0 commit comments

Comments
 (0)