Update make-bm-worker call for Go 1.16
[icn.git] / deploy / metal3 / scripts / 01_metal3.sh
index 563a924..ac6a80b 100755 (executable)
@@ -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 {
@@ -214,7 +216,7 @@ function make_bm_hosts {
         create_userdata $name $os_username $os_password
         apply_userdata_credential $name
 
-        go run $GOPATH/src/github.com/metal3-io/baremetal-operator/cmd/make-bm-worker/main.go \
+        GO111MODULE=auto go run $GOPATH/src/github.com/metal3-io/baremetal-operator/cmd/make-bm-worker/main.go \
            -address "ipmi://$ipmi_address" \
            -password "$ipmi_password" \
            -user "$ipmi_username" \
@@ -251,9 +253,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