|
| 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 | +- name: Delete OpenStackControlPlane CRs |
| 18 | + kubernetes.core.k8s: |
| 19 | + kubeconfig: "{{ _k8s_kubeconfig }}" |
| 20 | + api_key: "{{ _k8s_api_key }}" |
| 21 | + context: "{{ _k8s_context }}" |
| 22 | + api_version: core.openstack.org/v1beta1 |
| 23 | + kind: OpenStackControlPlane |
| 24 | + namespace: "{{ _openstack_namespace }}" |
| 25 | + state: absent |
| 26 | + wait: true |
| 27 | + wait_timeout: 600 |
| 28 | + register: _delete_controlplane_result |
| 29 | + failed_when: false |
| 30 | + until: _delete_controlplane_result is succeeded or (_delete_controlplane_result.failed and 'not found' in (_delete_controlplane_result.msg | default(''))) |
| 31 | + retries: 3 |
| 32 | + delay: 30 |
| 33 | + |
| 34 | +- name: Wait for control plane pods to terminate |
| 35 | + kubernetes.core.k8s_info: |
| 36 | + kubeconfig: "{{ _k8s_kubeconfig }}" |
| 37 | + api_key: "{{ _k8s_api_key }}" |
| 38 | + context: "{{ _k8s_context }}" |
| 39 | + namespace: "{{ _openstack_namespace }}" |
| 40 | + kind: Pod |
| 41 | + register: _remaining_pods |
| 42 | + until: _remaining_pods.resources | length == 0 or (_remaining_pods.resources | selectattr('metadata.name', 'match', '.*(rabbitmq|galera|openstack).*') | list | length == 0) |
| 43 | + retries: 60 |
| 44 | + delay: 10 |
| 45 | + when: _delete_controlplane_result is succeeded |
| 46 | + |
| 47 | +- name: Delete OpenStack CRs by kind |
| 48 | + kubernetes.core.k8s: |
| 49 | + kubeconfig: "{{ _k8s_kubeconfig }}" |
| 50 | + api_key: "{{ _k8s_api_key }}" |
| 51 | + context: "{{ _k8s_context }}" |
| 52 | + api_version: "{{ item.api_version }}" |
| 53 | + kind: "{{ item.kind }}" |
| 54 | + namespace: "{{ _openstack_namespace }}" |
| 55 | + state: absent |
| 56 | + wait: true |
| 57 | + wait_timeout: "{{ item.wait_timeout | default(300) }}" |
| 58 | + failed_when: false |
| 59 | + loop: |
| 60 | + - api_version: dataplane.openstack.org/v1beta1 |
| 61 | + kind: OpenStackDataPlaneDeployment |
| 62 | + wait_timeout: 600 |
| 63 | + - api_version: dataplane.openstack.org/v1beta1 |
| 64 | + kind: OpenStackDataPlaneNodeSet |
| 65 | + wait_timeout: 600 |
| 66 | + - api_version: dataplane.openstack.org/v1beta1 |
| 67 | + kind: OpenStackDataPlaneService |
| 68 | + wait_timeout: 300 |
| 69 | + - api_version: dataplane.openstack.org/v1beta1 |
| 70 | + kind: OpenStackDataPlaneNode |
| 71 | + wait_timeout: 300 |
| 72 | + - api_version: client.openstack.org/v1beta1 |
| 73 | + kind: OpenStackClient |
| 74 | + wait_timeout: 300 |
| 75 | + - api_version: core.openstack.org/v1beta1 |
| 76 | + kind: OpenStackVersion |
| 77 | + wait_timeout: 300 |
| 78 | + - api_version: openstack.org/v1beta1 |
| 79 | + kind: OpenStack |
| 80 | + wait_timeout: 300 |
| 81 | + loop_control: |
| 82 | + label: "{{ item.kind }}" |
| 83 | + |
| 84 | +- name: Remove finalizers from stuck OpenStackControlPlane CRs |
| 85 | + kubernetes.core.k8s: |
| 86 | + kubeconfig: "{{ _k8s_kubeconfig }}" |
| 87 | + api_key: "{{ _k8s_api_key }}" |
| 88 | + context: "{{ _k8s_context }}" |
| 89 | + api_version: core.openstack.org/v1beta1 |
| 90 | + kind: OpenStackControlPlane |
| 91 | + namespace: "{{ _openstack_namespace }}" |
| 92 | + state: patched |
| 93 | + definition: |
| 94 | + metadata: |
| 95 | + finalizers: [] |
| 96 | + failed_when: false |
| 97 | + when: cifmw_cleanup_openstack_force_remove_finalizers | default(false) |
0 commit comments