Skip to content

Commit 28fdc6e

Browse files
committed
various add-node.sh fixes
- removed role patch as not required - managed error for host install call
1 parent 8ea9b93 commit 28fdc6e

File tree

1 file changed

+10
-9
lines changed

1 file changed

+10
-9
lines changed

data/data/agent/files/usr/local/bin/add-node.sh

Lines changed: 10 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -20,11 +20,6 @@ printf '\nInfra env id is %s\n' "${INFRA_ENV_ID}" 1>&2
2020

2121
status_issue="90_add-node"
2222

23-
# For some reason the initial role patching doesn't seem to work properly
24-
echo "Patching host..."
25-
HOST_ID=$(curl -s "${BASE_URL}/infra-envs/${INFRA_ENV_ID}/hosts" | jq -r '.[].id')
26-
curl -X PATCH -d '{"host_role":"worker"}' -H "Content-Type: application/json" "${BASE_URL}/infra-envs/${INFRA_ENV_ID}/hosts/${HOST_ID}"
27-
2823
# Wait for the current host to be ready
2924
host_ready=false
3025
while [[ $host_ready == false ]]
@@ -38,10 +33,16 @@ do
3833
fi
3934
done
4035

36+
HOST_ID=$(curl -s "${BASE_URL}/infra-envs/${INFRA_ENV_ID}/hosts" | jq -r '.[].id')
37+
printf '\nHost %s is ready for installation\n' "${HOST_ID}" 1>&2
4138
clear_issue "${status_issue}"
4239

43-
sleep 1m
44-
4540
# Add the current host to the cluster
46-
curl -X POST -s -S "${BASE_URL}/infra-envs/${INFRA_ENV_ID}/hosts/${HOST_ID}/actions/install"
47-
echo "Host installation started" 1>&2
41+
res=$(curl -X POST -s -S "${BASE_URL}/infra-envs/${INFRA_ENV_ID}/hosts/${HOST_ID}/actions/install")
42+
code=$(echo "$res" | jq -r '.code')
43+
message=$(echo "$res" | jq -r '.message')
44+
if [[ $res = "200" ]]; then
45+
printf "\nHost installation started\n" 1>&2
46+
else
47+
printf '\nHost installation failed: %s\n' "${message}" 1>&2
48+
fi

0 commit comments

Comments
 (0)