From: Todd Malsbary Date: Thu, 3 Dec 2020 00:17:22 +0000 (-0800) Subject: Do not error when a deleted resource is not found X-Git-Tag: v0.4.0~2 X-Git-Url: https://gerrit.akraino.org/r/gitweb?a=commitdiff_plain;h=03f301ffa25a248fdd8f17d210b20ace4d1bf42f;p=icn.git Do not error when a deleted resource is not found Issue-ID: ICN-504 Signed-off-by: Todd Malsbary Change-Id: I6bf9aa9bba7342258d4d3943fa76ff44e3416166 --- diff --git a/cmd/bpa-operator/e2etest/bpa_bmh_verifier.sh b/cmd/bpa-operator/e2etest/bpa_bmh_verifier.sh index edf93df..aa0d8dc 100755 --- a/cmd/bpa-operator/e2etest/bpa_bmh_verifier.sh +++ b/cmd/bpa-operator/e2etest/bpa_bmh_verifier.sh @@ -48,6 +48,6 @@ kubectl logs $podName printf "\n\nBeginning BMH E2E Test Teardown\n\n" kubectl delete -f e2etest/test_bmh_provisioning_cr.yaml kubectl delete job kud-${CLUSTER_NAME} -kubectl delete configmap ${CLUSTER_NAME}-configmap +kubectl delete --ignore-not-found=true configmap ${CLUSTER_NAME}-configmap rm -rf /opt/kud/multi-cluster/${CLUSTER_NAME} make delete diff --git a/cmd/bpa-operator/e2etest/bpa_remote_virtletvm_verifier.sh b/cmd/bpa-operator/e2etest/bpa_remote_virtletvm_verifier.sh index 78096b5..6f0fa1f 100755 --- a/cmd/bpa-operator/e2etest/bpa_remote_virtletvm_verifier.sh +++ b/cmd/bpa-operator/e2etest/bpa_remote_virtletvm_verifier.sh @@ -73,5 +73,5 @@ kubectl ${KUBECONFIG} logs $podName kubectl ${KUBECONFIG} delete -f bpa_remote_virtletvm_cr.yaml kubectl ${KUBECONFIG} delete job kud-remotevvm -kubectl ${KUBECONFIG} delete configmap remotevvm-configmap +kubectl ${KUBECONFIG} delete --ignore-not-found=true configmap remotevvm-configmap kubectl ${KUBECONFIG} delete -f bpa_remote_virtletvm.yaml diff --git a/cmd/bpa-operator/e2etest/bpa_virtletvm_verifier.sh b/cmd/bpa-operator/e2etest/bpa_virtletvm_verifier.sh index 946a1f9..949aad2 100755 --- a/cmd/bpa-operator/e2etest/bpa_virtletvm_verifier.sh +++ b/cmd/bpa-operator/e2etest/bpa_virtletvm_verifier.sh @@ -211,7 +211,7 @@ printf "\n\nBeginning E2E VM Test Teardown\n\n" kubectl delete -f e2e_bpa_test.yaml kubectl delete job kud-vmcluster110 -kubectl delete configmap vmcluster110-configmap +kubectl delete --ignore-not-found=true configmap vmcluster110-configmap kubectl delete -f virtlet_test_vm.yaml rm -rf /opt/kud/multi-cluster/vmcluster110 rm -rf $BPA_DIR diff --git a/cmd/bpa-operator/e2etest/bpa_vm_verifier.sh b/cmd/bpa-operator/e2etest/bpa_vm_verifier.sh index b1f490e..2d93572 100755 --- a/cmd/bpa-operator/e2etest/bpa_vm_verifier.sh +++ b/cmd/bpa-operator/e2etest/bpa_vm_verifier.sh @@ -109,7 +109,7 @@ kubectl logs $podName printf "\n\nBeginning E2E Test Teardown\n\n" kubectl delete -f e2etest/e2e_test_provisioning_cr.yaml kubectl delete job kud-${CLUSTER_NAME} -kubectl delete configmap ${CLUSTER_NAME}-configmap +kubectl delete --ignore-not-found=true configmap ${CLUSTER_NAME}-configmap rm e2etest/e2e_test_provisioning_cr.yaml rm -rf /opt/kud/multi-cluster/${CLUSTER_NAME} rm /opt/icn/dhcp/dhcpd.leases diff --git a/deploy/metal3/scripts/01_metal3.sh b/deploy/metal3/scripts/01_metal3.sh index 27a6685..d419b82 100755 --- a/deploy/metal3/scripts/01_metal3.sh +++ b/deploy/metal3/scripts/01_metal3.sh @@ -59,8 +59,10 @@ EOF function deprovision_compute_node { name="$1" - kubectl patch baremetalhost $name -n metal3 --type merge \ - -p '{"spec":{"image":{"url":"","checksum":""}}}' + if kubectl get baremetalhost $name -n metal3 &>/dev/null; then + kubectl patch baremetalhost $name -n metal3 --type merge \ + -p '{"spec":{"image":{"url":"","checksum":""}}}' + fi } function set_compute_ssh_config { @@ -239,9 +241,9 @@ function remove_bm_hosts { function cleanup { while IFS=',' read -r name ipmi_username ipmi_password ipmi_address os_username os_password os_image_name; do - kubectl delete bmh $name -n metal3 - kubectl delete secrets $name-bmc-secret -n metal3 - kubectl delete secrets $name-user-data -n metal3 + kubectl delete --ignore-not-found=true bmh $name -n metal3 + kubectl delete --ignore-not-found=true secrets $name-bmc-secret -n metal3 + kubectl delete --ignore-not-found=true secrets $name-user-data -n metal3 if [ -f $name-bm-node.yaml ]; then rm -rf $name-bm-node.yaml fi diff --git a/deploy/metal3/scripts/03_verify_deprovisioning.sh b/deploy/metal3/scripts/03_verify_deprovisioning.sh index 4223cd8..5c49d1d 100755 --- a/deploy/metal3/scripts/03_verify_deprovisioning.sh +++ b/deploy/metal3/scripts/03_verify_deprovisioning.sh @@ -16,10 +16,15 @@ function check_deprovisioned { echo "Baremetal state: 1 means deprovisioned & 0 means not yet deprovisioned" while IFS=',' read -r name ipmi_username ipmi_password ipmi_address os_username os_password os_image_name; do declare -i current_host_state=0 - state=$(kubectl get baremetalhosts $name -n metal3 -o json | jq -r '.status.provisioning.state') + if kubectl get baremetalhost $name -n metal3 &>/dev/null; then + state=$(kubectl get baremetalhosts $name -n metal3 -o json | jq -r '.status.provisioning.state') + else + # When the named BareMetalHost is not found, assume its deprovisioned + state="ready" + fi echo "Baremetal host metal3 state - "$name" : "$state - if [ $state == "ready" ];then + if [ "$state" == "ready" ];then current_host_state=1 fi diff --git a/env/metal3/03_launch_prereq.sh b/env/metal3/03_launch_prereq.sh index 9d58f57..7559f2f 100755 --- a/env/metal3/03_launch_prereq.sh +++ b/env/metal3/03_launch_prereq.sh @@ -154,7 +154,7 @@ function install_dhcp { } function reset_dhcp { - kubectl delete -f $PWD/04_dhcp.yaml + kubectl delete --ignore-not-found=true -f $PWD/04_dhcp.yaml if [ -d $BS_DHCP_DIR ]; then rm -rf $BS_DHCP_DIR fi