Revise claiming error message in kickstart script. (#12248)
* Revise claiming error message in kickstart script. * Addressed review feedback. * Apply suggestions from code review Co-authored-by: Austin S. Hemmelgarn <ahferroin7@gmail.com> * Update packaging/installer/kickstart.sh Co-authored-by: Tina Luedtke <kickoke@users.noreply.github.com> * Fix broken rebase. Co-authored-by: Tina Luedtke <kickoke@users.noreply.github.com>
Austin S. Hemmelgarn committed
Mar 16, 2022 at 08:26 UTC
472bf451601a1aec1b1d17810502a0a83e676df6
1 file changed
+60
-20
packaging/installer/kickstart.sh
+60
-20
@@ -844,6 +844,7 @@ claim() {
844
progress "Attempting to claim agent to ${NETDATA_CLAIM_URL}"
845
fi
846
847
+ progress "Attempting to claim agent to ${NETDATA_CLAIM_URL}"
848
if [ -z "${INSTALL_PREFIX}" ] || [ "${INSTALL_PREFIX}" = "/" ]; then
849
NETDATA_CLAIM_PATH=/usr/sbin/netdata-claim.sh
850
elif [ "${INSTALL_PREFIX}" = "/opt/netdata" ]; then
@@ -852,30 +853,69 @@ claim() {
853
NETDATA_CLAIM_PATH="${INSTALL_PREFIX}/netdata/usr/sbin/netdata-claim.sh"
854
fi
855
855
- claim_opts="-token=${NETDATA_CLAIM_TOKEN} -url=${NETDATA_CLAIM_URL}"
856
-
857
- if [ -n "${NETDATA_CLAIM_ROOMS}" ]; then
858
- claim_opts="${claim_opts} -rooms=${NETDATA_CLAIM_ROOMS}"
859
- fi
860
-
856
if ! is_netdata_running; then
862
- claim_opts="${claim_opts} -daemon-not-running"
863
- fi
864
-
865
- if [ -n "${NETDATA_CLAIM_EXTRA}" ]; then
866
- claim_opts="${claim_opts} ${NETDATA_CLAIM_EXTRA}"
857
+ NETDATA_CLAIM_EXTRA="${NETDATA_CLAIM_EXTRA} -daemon-not-running"
858
fi
859
860
# shellcheck disable=SC2086
870
- if run ${ROOTCMD} "${NETDATA_CLAIM_PATH}" ${claim_opts}; then
871
- progress "Successfully claimed node"
872
- else
873
- warning "Unable to claim node, you must do so manually."
874
- if [ -z "${NETDATA_NEW_INSTALL}" ]; then
875
- cleanup
876
- trap - EXIT
877
- exit 1
878
- fi
861
+ run ${ROOTCMD} "${NETDATA_CLAIM_PATH}" -token="${NETDATA_CLAIM_TOKEN}" -rooms="${NETDATA_CLAIM_ROOMS}" -url="${NETDATA_CLAIM_URL}" ${NETDATA_CLAIM_EXTRA}
862
+ case $? in
863
+ 0)
864
+ progress "Successfully claimed node"
865
+ return 0
866
+ ;;
867
+ 1)
868
+ warning "Unable to claim node due to invalid claiming options. If you are seeing this message, you’ve probably found a bug and should open a bug report at ${AGENT_BUG_REPORT_URL}"
869
+ ;;
870
+ 2)
871
+ warning "Unable to claim node due to issues creating the claiming directory or preparing the local claiming key. Make sure you have a working openssl command and that ${INSTALL_PREFIX}/var/lib/netdata/cloud.d exists, then try again."
872
+ ;;
873
+ 3)
874
+ warning "Unable to claim node due to missing dependencies. Usually this means that the Netdata Agent was built without support for Netdata Cloud. If you built the agent from source, please install all needed dependencies for Cloud support. If you used the regular installation script and see this error, please file a bug."
875
+ ;;
876
+ 4)
877
+ warning "Failed to claim node due to inability to connect to ${NETDATA_CLAIM_URL}. Usually this either means that the specified claiming URL is wrong, or that you are having networking problems."
878
+ ;;
879
+ 5)
880
+ progress "Successfully claimed node, but was not able to notify the Netdata Agent. You will need to restart the Netdata service on this node before it will show up in the Cloud."
881
+ return 0
882
+ ;;
883
+ 8)
884
+ warning "Failed to claim node due to an invalid agent ID. You can usually resolve this by removing ${INSTALL_PREFIX}/var/lib/netdata/registry/netdata.public.unique.id and restarting the agent. Then try to claim it again using the same options."
885
+ ;;
886
+ 9)
887
+ warning "Failed to claim node due to an invalid node name. This probably means you tried to specify a custom name for this node (for example, using the --claim-hostname option), but the hostname itself was either empty or consisted solely of whitespace. You can resolve this by specifying a valid host name and trying again."
888
+ ;;
889
+ 10)
890
+ warning "Failed to claim node due to an invalid room ID. This issue is most likely caused by a typo. Please check if the room(s) you are trying to add appear on the list of rooms provided to the --claim-rooms option ('${NETDATA_CLAIM_ROOMS}'). Then verify if the rooms are visible in Netdata Cloud and try again."
891
+ ;;
892
+ 11)
893
+ warning "Failed to claim node due to an issue with the generated RSA key pair. You can usually resolve this by removing all files in ${INSTALL_PREFIX}/var/lib/netdata/cloud.d and then trying again."
894
+ ;;
895
+ 12)
896
+ warning "Failed to claim node due to an invalid or expired claiming token. Please check that the token specified with the --claim-token option ('${NETDATA_CLAIM_TOKEN}') matches what you see in the Cloud and try again."
897
+ ;;
898
+ 13)
899
+ warning "Failed to claim node because the Cloud thinks it is already claimed. If this node was created by cloning a VM or as a container from a template, please remove the file ${INSTALL_PREFIX}/var/lib/netdata/registry/netdata.public.unique.id and restart the agent. Then try to claim it again with the same options. Otherwise, if you are certain this node has never been claimed before, you can use the --claim-id option to specify a new node ID to use for claiming, for example by using the uuidgen command like so: --claim-id \"\$(uuidgen)\""
900
+ ;;
901
+ 14)
902
+ warning "Failed to claim node because the node is already in the process of being claimed. You should not need to do anything to resolve this, the node should show up properly in the Cloud soon. If it does not, please report a bug at ${AGENT_BUG_REPORT_URL}."
903
+ ;;
904
+ 15|16|17)
905
+ warning "Failed to claim node due to an internal server error in the Cloud. Please retry claiming this node later, and if you still see this message file a bug report at ${CLOUD_BUG_REPORT_URL}."
906
+ ;;
907
+ 18)
908
+ warning "Unable to claim node because this Netdata installation does not have a unique ID yet. Make sure the agent is running and started up correctly, and then try again."
909
+ ;;
910
+ *)
911
+ warning "Failed to claim node for an unknown reason. This usually means either networking problems or a bug. Please retry claiming later, and if you still see this message file a bug report at ${AGENT_BUG_REPORT_URL}"
912
+ ;;
913
+ esac
914
+
915
+ if [ -z "${NETDATA_NEW_INSTALL}" ]; then
916
+ cleanup
917
+ trap - EXIT
918
+ exit 1
919
fi
920
}
921