Skip to content

Commit ef442aa

Browse files
committed
[cleanup_openstack] enhance cleanup for infrastructure reuse
Enhance the cleanup_openstack role to support infrastructure reuse by cleaning up OpenStack resources while preserving the OpenShift cluster infrastructure. This enables faster test cycles by avoiding full infrastructure reprovisioning. Changes: - Add cleanup-openstack-for-reuse.yml playbook for direct use - Add cleanup_crs_direct.yaml to delete OpenStack CRs directly from cluster - Add cleanup_openstack_api.yaml to delete OpenStack API resources (servers, networks, volumes, etc.) before CR deletion to prevent orphaned resources - Add cleanup_storage.yaml to clean up PVCs, secrets, ConfigMaps, and PVs - Add cleanup_namespaces.yaml to optionally delete empty namespaces - Add common.yaml to eliminate code duplication (kubeconfig/auth params) - Refactor CR deletion patterns to use loops, reducing code duplication - Fix execution order: API resources are deleted first while control plane is still running, then CRs are deleted - Preserve infrastructure operators (NMState, MetalLB, OLM) for cluster reuse - Add configurable variables for granular cleanup control - Update README with comprehensive documentation Related: OSPRH-21759 Signed-off-by: Roberto Alfieri <[email protected]>
1 parent fbb79d3 commit ef442aa

37 files changed

+1934
-203
lines changed

.github/workflows/commit-message-validator.yml

Lines changed: 1 addition & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -29,16 +29,4 @@ jobs:
2929
- name: Run commit message check
3030
id: bodylength
3131
run: |
32-
set +e
33-
./scripts/git-check-commit-body-length.sh commit-message-file > result.log 2>&1
34-
EXIT_CODE=$?
35-
echo "exit_code=$EXIT_CODE" >> $GITHUB_OUTPUT
36-
cat result.log
37-
38-
- name: Comment on PR if body length check failed
39-
if: steps.bodylength.outputs.exit_code != '0'
40-
uses: peter-evans/create-or-update-comment@v5
41-
with:
42-
issue-number: ${{ github.event.pull_request.number }}
43-
body-path: ./result.log
44-
reactions: confused
32+
./scripts/git-check-commit-body-length.sh commit-message-file

.github/workflows/verify-pr-prefix.yml

Lines changed: 6 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -20,19 +20,12 @@ jobs:
2020
with:
2121
fetch-depth: 0
2222

23+
- name: Dump commit message to file
24+
run: |
25+
git fetch origin ${{ github.event.pull_request.head.sha }}
26+
git log -1 --pretty=format:"%B" ${{ github.event.pull_request.head.sha }} | head -n1 > commit-message-file
27+
2328
- name: Run commit message check
2429
id: prefixcheck
2530
run: |
26-
set +e
27-
./scripts/check-role-prefix.sh > result.log 2>&1
28-
EXIT_CODE=$?
29-
echo "exit_code=$EXIT_CODE" >> $GITHUB_OUTPUT
30-
cat result.log
31-
32-
- name: Comment on PR if prefix check failed
33-
if: steps.prefixcheck.outputs.exit_code != '0'
34-
uses: peter-evans/create-or-update-comment@v5
35-
with:
36-
issue-number: ${{ github.event.pull_request.number }}
37-
body-path: ./result.log
38-
reactions: confused
31+
./scripts/check-role-prefix.sh commit-message-file

cleanup-openstack-for-reuse.yml

Lines changed: 68 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,68 @@
1+
---
2+
# Copyright Red Hat, Inc.
3+
# All Rights Reserved.
4+
#
5+
# Licensed under the Apache License, Version 2.0 (the "License"); you may
6+
# not use this file except in compliance with the License. You may obtain
7+
# a copy of the License at
8+
#
9+
# http://www.apache.org/licenses/LICENSE-2.0
10+
#
11+
# Unless required by applicable law or agreed to in writing, software
12+
# distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
13+
# WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
14+
# License for the specific language governing permissions and limitations
15+
# under the License.
16+
17+
# This playbook cleans up OpenStack resources while preserving the OpenShift
18+
# cluster infrastructure for reuse. It removes:
19+
# - All OpenStack CRs (ControlPlane, DataPlane, etc.)
20+
# - Storage resources (PVCs, secrets, ConfigMaps)
21+
# - Optionally: OpenStack API resources (servers, networks, volumes, etc.)
22+
#
23+
# Usage examples:
24+
#
25+
# Basic cleanup (removes OpenStack CRs and storage, keeps cluster):
26+
# ansible-playbook -i inventory.yml cleanup-openstack-for-reuse.yml
27+
#
28+
# Skip API resource cleanup (if needed):
29+
# ansible-playbook -i inventory.yml cleanup-openstack-for-reuse.yml \
30+
# -e cleanup_api_resources=false
31+
#
32+
# Aggressive cleanup (removes everything including namespaces):
33+
# ansible-playbook -i inventory.yml cleanup-openstack-for-reuse.yml \
34+
# -e cleanup_api_resources=true \
35+
# -e cleanup_namespaces=true \
36+
# -e force_remove_finalizers=true
37+
38+
- name: Clean OpenStack deployment for infrastructure reuse
39+
hosts: "{{ target_host | default('localhost') }}"
40+
gather_facts: true
41+
vars:
42+
# By default, clean OpenStack CRs, storage, and API resources but keep OpenShift cluster
43+
# Set to false to skip OpenStack API resource cleanup
44+
cifmw_cleanup_openstack_delete_api_resources: "{{ cleanup_api_resources | default(true) }}"
45+
# Set to true to delete namespaces (use with caution)
46+
cifmw_cleanup_openstack_delete_namespaces: "{{ cleanup_namespaces | default(false) }}"
47+
# Set to true to force remove finalizers from stuck CRs
48+
cifmw_cleanup_openstack_force_remove_finalizers: "{{ force_remove_finalizers | default(false) }}"
49+
tasks:
50+
- name: Cleanup OpenStack deployment
51+
ansible.builtin.include_role:
52+
name: cleanup_openstack
53+
54+
- name: Display cleanup summary
55+
ansible.builtin.debug:
56+
msg: >-
57+
OpenStack cleanup completed. The OpenShift cluster is now ready for reuse.
58+
59+
Cleaned resources:
60+
- OpenStack CRs (ControlPlane, DataPlane, etc.)
61+
- Storage resources (PVCs, secrets, ConfigMaps)
62+
- OpenStack API resources (servers, networks, volumes, etc.)
63+
- Artifacts and logs
64+
{% if cifmw_cleanup_openstack_delete_namespaces %}
65+
- OpenStack namespaces (if empty)
66+
{% endif %}
67+
68+
The cluster infrastructure is preserved and ready for a new deployment.

docs/dictionary/en-custom.txt

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -55,6 +55,7 @@ buildah
5555
buildpkgs
5656
cacert
5757
cacheable
58+
certmanager
5859
catalogsource
5960
cci
6061
ccitredhat
@@ -138,6 +139,7 @@ deepscrub
138139
delorean
139140
deployer
140141
deprovision
142+
deprovisioned
141143
deps
142144
dest
143145
dev
@@ -185,7 +187,9 @@ extraRPMs
185187
ezzmy
186188
favorit
187189
fbqufbqkfbzxrja
190+
finalizers
188191
fci
192+
fdp
189193
fedoraproject
190194
fil
191195
filesystem
@@ -298,6 +302,7 @@ kvm
298302
lacp
299303
lajly
300304
LDAP
305+
Lifecycle
301306
ldp
302307
libguestfs
303308
libvirt
@@ -414,8 +419,12 @@ openstack
414419
openstackclient
415420
openstackcontrolplane
416421
openstackdataplane
422+
openstackdataplanedeployment
423+
OpenStackDataPlaneDeployment
417424
openstackdataplanenodeset
418425
openstackdataplanenodesets
426+
openstackdataplaneservice
427+
OpenStackDataPlaneService
419428
openstackprovisioner
420429
openstacksdk
421430
openstackversion
@@ -442,6 +451,8 @@ passwd
442451
passwordless
443452
pastebin
444453
pem
454+
persistentvolumes
455+
PersistentVolumes
445456
pkgs
446457
pki
447458
png
@@ -467,6 +478,7 @@ pubkey
467478
publicdomain
468479
pullsecret
469480
pvs
481+
PVCs
470482
pwd
471483
pxe
472484
py
@@ -490,6 +502,7 @@ readmes
490502
readthedocs
491503
reauthenticate
492504
rebaser
505+
reusability
493506
redfish
494507
redhat
495508
refspec

0 commit comments

Comments
 (0)