@cryptotaxi247 / netdata-1 / commits / 91051b8ac

Summarize encountered errors and warnings at end of kickstart script run. (#12636)

* Summarize encountered errors and warnings at end of kickstart script run. This way users will be more likely to see them, and we will have an easier time actually helping users who encounter issues. * Fix deferred error print formatting.

Austin S. Hemmelgarn committed Apr 13, 2022 at 10:57 UTC 91051b8ac8441fad0074af5d27896062a6aab9cd
1 file changed +21 -10
packaging/installer/kickstart.sh
+21 -10
@@ -36,6 +36,7 @@ NETDATA_ONLY_NATIVE=0
36 NETDATA_ONLY_STATIC=0
37 NETDATA_REQUIRE_CLOUD=1
38 RELEASE_CHANNEL="nightly"
39 +WARNINGS=""
40
41 if [ -n "$DISABLE_TELEMETRY" ]; then
42 NETDATA_DISABLE_TELEMETRY="${DISABLE_TELEMETRY}"
@@ -62,6 +63,8 @@ fi
63 main() {
64 if [ "${ACTION}" = "uninstall" ]; then
65 uninstall
66 + printf >&2 "Finished uninstalling the Netdata Agent."
67 + deferred_warnings
68 cleanup
69 trap - EXIT
70 exit 0
@@ -100,6 +103,7 @@ main() {
103 set_auto_updates
104
105 printf >&2 "%s\n\n" "Successfully installed the Netdata Agent."
106 + deferred_warnings
107 success_banner
108 telemetry_event INSTALL_SUCCESS "" ""
109 cleanup
@@ -252,6 +256,8 @@ trap_handler() {
256 code="${1}"
257 lineno="${2}"
258
259 + deferred_warnings
260 +
261 printf >&2 "%s\n\n" "${TPUT_BGRED}${TPUT_WHITE}${TPUT_BOLD} ERROR ${TPUT_RESET} Installer exited unexpectedly (${code}-${lineno})"
262
263 case "${code}" in
@@ -335,7 +341,16 @@ cleanup() {
341 fi
342 }
343
344 +deferred_warnings() {
345 + if [ -n "${WARNINGS}" ]; then
346 + printf >&2 "%s\n" "The following non-fatal warnings or errors were encountered:"
347 + echo >&2 "${WARNINGS}"
348 + printf >&2 "\n"
349 + fi
350 +}
351 +
352 fatal() {
353 + deferred_warnings
354 printf >&2 "%s\n\n" "${TPUT_BGRED}${TPUT_WHITE}${TPUT_BOLD} ABORTED ${TPUT_RESET} ${1}"
355 printf >&2 "%s\n" "For community support, you can connect with us on:"
356 support_list
@@ -345,14 +360,6 @@ fatal() {
360 exit 1
361 }
362
348 -run_ok() {
349 - printf >&2 "%s\n\n" "${TPUT_BGGREEN}${TPUT_WHITE}${TPUT_BOLD} OK ${TPUT_RESET}"
350 -}
351 -
352 -run_failed() {
353 - printf >&2 "%s\n\n" "${TPUT_BGRED}${TPUT_WHITE}${TPUT_BOLD} FAILED ${TPUT_RESET}"
354 -}
355 -
363 ESCAPED_PRINT_METHOD=
364 # shellcheck disable=SC3050
365 if printf "%s " test > /dev/null 2>&1; then
@@ -408,10 +415,11 @@ run() {
415 fi
416
417 if [ ${ret} -ne 0 ]; then
411 - run_failed
418 + printf >&2 "%s\n\n" "${TPUT_BGRED}${TPUT_WHITE}${TPUT_BOLD} FAILED ${TPUT_RESET}"
419 printf "%s\n" "FAILED with exit code ${ret}" >> "${run_logfile}"
420 + WARNINGS="${WARNINGS}\n - Command \"${*}\" failed with exit code ${ret}."
421 else
414 - run_ok
422 + printf >&2 "%s\n\n" "${TPUT_BGGREEN}${TPUT_WHITE}${TPUT_BOLD} OK ${TPUT_RESET}"
423 printf "OK\n" >> "${run_logfile}"
424 fi
425
@@ -420,6 +428,7 @@ run() {
428
429 warning() {
430 printf >&2 "%s\n\n" "${TPUT_BGRED}${TPUT_WHITE}${TPUT_BOLD} WARNING ${TPUT_RESET} ${*}"
431 + WARNINGS="${WARNINGS}\n - ${*}"
432 }
433
434 _cannot_use_tmpdir() {
@@ -815,6 +824,7 @@ handle_existing_install() {
824 progress "Not attempting to claim existing install at ${ndprefix} (no claiming token provided)."
825 fi
826
827 + deferred_warnings
828 success_banner
829 cleanup
830 trap - EXIT
@@ -1036,6 +1046,7 @@ claim() {
1046 esac
1047
1048 if [ -z "${NETDATA_NEW_INSTALL}" ]; then
1049 + deferred_warnings
1050 printf >&2 "%s\n" "For community support, you can connect with us on:"
1051 support_list
1052 cleanup