a43a457e3fbde1d4cb76623efd14c36e3e0f0e19
[releng/builder.git] / jjb / packaging / openstack-k8s-cluster-delete.sh
1 #!/bin/bash -l
2 # SPDX-License-Identifier: EPL-1.0
3 ##############################################################################
4 # Copyright (c) 2021 The Linux Foundation and others.
5 #
6 # All rights reserved. This program and the accompanying materials
7 # are made available under the terms of the Eclipse Public License v1.0
8 # which accompanies this distribution, and is available at
9 # http://www.eclipse.org/legal/epl-v10.html
10 ##############################################################################
11 # shellcheck disable=SC2153,SC2034
12 echo "---> Delete K8S cluster"
13
14 set -eux -o pipefail
15 # shellcheck disable=SC1090
16 . ~/lf-env.sh
17
18 os_cloud="${OS_CLOUD:-vex}"
19 cluster_name="${CLUSTER_NAME}"
20
21 cluster_delete_status="$(openstack --os-cloud "$OS_CLOUD" coe cluster delete "${CLUSTER_NAME}")"
22 if [[ -z "$cluster_delete_status" ]]; then
23     echo "ERROR: Failed to delete coe cluster ${cluster_name}"
24     exit 1
25 elif [[ "${cluster_delete_status}" =~ .*accepted.* ]]; then
26     echo "Cluster ${CLUSTER_NAME} delete in progress ..."
27     echo "${cluster_delete_status}"
28 fi