fatal in claim() only if --claim-only is used (#15039)
Ilya Mashchenko committed
May 11, 2023 at 16:14 UTC
8bde63a914ba41e45948aefef1b9f87e3c2d7af5
1 file changed
+22
-8
packaging/installer/kickstart.sh
+22
-8
@@ -972,7 +972,7 @@ handle_existing_install() {
972
claim
973
ret=$?
974
elif [ "${ACTION}" = "claim" ]; then
975
- fatal "User asked to claim, but did not proide a claiming token." F0202
975
+ fatal "User asked to claim, but did not provide a claiming token." F0202
976
else
977
progress "Not attempting to claim existing install at ${ndprefix} (no claiming token provided)."
978
fi
@@ -1010,7 +1010,7 @@ handle_existing_install() {
1010
trap - EXIT
1011
exit $ret
1012
elif [ "${ACTION}" = "claim" ]; then
1013
- fatal "User asked to claim, but did not proide a claiming token." F0202
1013
+ fatal "User asked to claim, but did not provide a claiming token." F0202
1014
else
1015
fatal "Found an existing netdata install at ${ndprefix}, but the install type is '${INSTALL_TYPE}', which is not supported by this script, refusing to proceed." F0103
1016
fi
@@ -1120,7 +1120,6 @@ claim() {
1120
progress "Attempting to claim agent to ${NETDATA_CLAIM_URL}"
1121
fi
1122
1123
- progress "Attempting to claim agent to ${NETDATA_CLAIM_URL}"
1123
if command -v netdata-claim.sh > /dev/null 2>&1; then
1124
NETDATA_CLAIM_PATH="$(command -v netdata-claim.sh)"
1125
elif [ -z "${INSTALL_PREFIX}" ] || [ "${INSTALL_PREFIX}" = "/" ]; then
@@ -1137,14 +1136,29 @@ claim() {
1136
NETDATA_CLAIM_PATH="${INSTALL_PREFIX}/netdata/usr/sbin/netdata-claim.sh"
1137
fi
1138
1139
+ err_msg=
1140
+ err_code=
1141
if [ -z "${NETDATA_CLAIM_PATH}" ]; then
1141
- fatal "Unable to find usable claiming script. Reinstalling Netdata may resolve this." F050B
1142
+ err_msg="Unable to claim node: could not find usable claiming script. Reinstalling Netdata may resolve this."
1143
+ err_code=F050B
1144
elif [ ! -e "${NETDATA_CLAIM_PATH}" ]; then
1143
- fatal "${NETDATA_CLAIM_PATH} does not exist." F0512
1145
+ err_msg="Unable to claim node: ${NETDATA_CLAIM_PATH} does not exist."
1146
+ err_code=F0512
1147
elif [ ! -f "${NETDATA_CLAIM_PATH}" ]; then
1145
- fatal "${NETDATA_CLAIM_PATH} is not a file." F0513
1148
+ err_msg="Unable to claim node: ${NETDATA_CLAIM_PATH} is not a file."
1149
+ err_code=F0513
1150
elif [ ! -x "${NETDATA_CLAIM_PATH}" ]; then
1147
- fatal "Claiming script at ${NETDATA_CLAIM_PATH} is not executable. Reinstalling Netdata may resolve this." F0514
1151
+ err_msg="Unable to claim node: claiming script at ${NETDATA_CLAIM_PATH} is not executable. Reinstalling Netdata may resolve this."
1152
+ err_code=F0514
1153
+ fi
1154
+
1155
+ if [ -n "$err_msg" ]; then
1156
+ if [ "${ACTION}" = "claim" ]; then
1157
+ fatal "$err_msg" "$err_code"
1158
+ else
1159
+ warning "$err_msg"
1160
+ return 1
1161
+ fi
1162
fi
1163
1164
if ! is_netdata_running; then
@@ -1178,7 +1192,7 @@ claim() {
1192
*) 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}" ;;
1193
esac
1194
1181
- if [ -z "${NETDATA_NEW_INSTALL}" ]; then
1195
+ if [ "${ACTION}" = "claim" ]; then
1196
deferred_warnings
1197
printf >&2 "%s\n" "For community support, you can connect with us on:"
1198
support_list