Skip to content

Commit 4b4ff69

Browse files
committed
#1123 Don't fail if not --confirm-destroy and namespace no longer exists
1 parent 4630686 commit 4b4ff69

2 files changed

Lines changed: 28 additions & 18 deletions

File tree

Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,20 @@
1+
---
2+
- name: Fail if destroy was not confirmed
3+
fail:
4+
msg: "Destroy of Cloud Pak for Data cluster {{ _p_current_cp4d_cluster.project }} was not confirmed with --confirm-destroy parameter or via global_config confirm_destroy property"
5+
when:
6+
- _confirm_destroy | bool != True
7+
- not cpd_dry_run
8+
9+
- name: Login to the OpenShift cluster "{{ _p_current_cp4d_cluster.openshift_cluster_name }}"
10+
include_role:
11+
name: openshift-login
12+
vars:
13+
_p_openshift_cluster_name: "{{ _p_current_cp4d_cluster.openshift_cluster_name }}"
14+
15+
- name: Delete Cloud Pak for Data instance {{ _p_current_cp4d_cluster.project }} and its operators, logs are in {{ status_dir }}/log/{{ _p_current_cp4d_cluster.project }}-destroy.log
16+
shell: |
17+
{{ playbook_dir }}/../scripts/cp4d/cp4d-delete-instance.sh {{ _p_current_cp4d_cluster.project }} | tee -a {{ status_dir }}/log/{{ _p_current_cp4d_cluster.project }}-destroy.log
18+
environment:
19+
CPD_CONFIRM_DELETE: "true"
20+
CPD_DESTROY_CLUSTER_WIDE: "false"
Lines changed: 8 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -1,20 +1,10 @@
11
---
2-
- name: Fail if destroy was not confirmed
3-
fail:
4-
msg: "Destroy of Cloud Pak for Data cluster {{ _p_current_cp4d_cluster.project }} was not confirmed with --confirm-destroy parameter or via global_config confirm_destroy property"
5-
when:
6-
- _confirm_destroy | bool != True
7-
- not cpd_dry_run
2+
- name: Check if {{ _p_current_cp4d_cluster.project }} still exists
3+
kubernetes.core.k8s_info:
4+
kind: namespace
5+
name: "{{ _p_current_cp4d_cluster.project }}"
6+
api_version: v1
7+
register: _cp4d_namespace
88

9-
- name: Login to the OpenShift cluster "{{ _p_current_cp4d_cluster.openshift_cluster_name }}"
10-
include_role:
11-
name: openshift-login
12-
vars:
13-
_p_openshift_cluster_name: "{{ _p_current_cp4d_cluster.openshift_cluster_name }}"
14-
15-
- name: Delete Cloud Pak for Data instance {{ _p_current_cp4d_cluster.project }} and its operators, logs are in {{ status_dir }}/log/{{ _p_current_cp4d_cluster.project }}-destroy.log
16-
shell: |
17-
{{ playbook_dir }}/../scripts/cp4d/cp4d-delete-instance.sh {{ _p_current_cp4d_cluster.project }} | tee -a {{ status_dir }}/log/{{ _p_current_cp4d_cluster.project }}-destroy.log
18-
environment:
19-
CPD_CONFIRM_DELETE: "true"
20-
CPD_DESTROY_CLUSTER_WIDE: "false"
9+
- include_tasks: cp4d-cluster-delete.yml
10+
when: (_cp4d_namespace.resources | default([])) != []

0 commit comments

Comments
 (0)