Add deferred error message handling to the installer. (#8381)
This adds handling for deferring non-fatal error messages so that they get shown at the end of the install. It also adds code to do this for failures to fetch, build, or install libmosquitto, LWS, and the go.d plugin.
Austin S. Hemmelgarn committed
Mar 12, 2020 at 07:15 UTC
bec7b83e19944a7e844c6c7777f92ccba6d504e3
1 file changed
+26
netdata-installer.sh
+26
@@ -40,6 +40,24 @@ fi
40
# make sure /etc/profile does not change our current directory
41
cd "${NETDATA_SOURCE_DIR}" || exit 1
42
43
+# -----------------------------------------------------------------------------
44
+# set up handling for deferred error messages
45
+NETDATA_DEFERRED_ERRORS=""
46
+
47
+defer_error() {
48
+ NETDATA_DEFERRED_ERRORS="${NETDATA_DEFERRED_ERRORS}\n* ${1}"
49
+}
50
+
51
+print_deferred_errors() {
52
+ if [ -n "${NETDATA_DEFERRED_ERRORS}" ] ; then
53
+ echo >&2
54
+ echo >&2 "The following non-fatal errors were encountered during the installation process:"
55
+ # shellcheck disable=SC2059
56
+ printf >&2 "${NETDATA_DEFERRED_ERRORS}"
57
+ echo >&2
58
+ fi
59
+}
60
+
61
# -----------------------------------------------------------------------------
62
# load the required functions
63
@@ -480,9 +498,11 @@ bundle_libmosquitto() {
498
run_ok "libmosquitto built and prepared."
499
else
500
run_failed "Failed to build libmosquitto. The install process will continue, but you will not be able to connect this node to Netdata Cloud."
501
+ defer_error "Failed to build libmosquitto. The install process will continue, but you will not be able to connect this node to Netdata Cloud."
502
fi
503
else
504
run_failed "Unable to fetch sources for libmosquitto. The install process will continue, but you will not be able to connect this node to Netdata Cloud."
505
+ defer_error "Unable to fetch sources for libmosquitto. The install process will continue, but you will not be able to connect this node to Netdata Cloud."
506
fi
507
}
508
@@ -532,9 +552,11 @@ bundle_libwebsockets() {
552
run_ok "libwebsockets built and prepared."
553
else
554
run_failed "Failed to build libwebsockets. The install process will continue, but you may not be able to connect this node to Netdata Cloud."
555
+ defer_error "Failed to build libwebsockets. The install process will continue, but you may not be able to connect this node to Netdata Cloud."
556
fi
557
else
558
run_failed "Unable to fetch sources for libwebsockets. The install process will continue, but you may not be able to connect this node to Netdata Cloud."
559
+ defer_error "Unable to fetch sources for libwebsockets. The install process will continue, but you may not be able to connect this node to Netdata Cloud."
560
fi
561
}
562
@@ -1042,6 +1064,7 @@ install_go() {
1064
1065
if [ ! -f "${tmp}/${GO_PACKAGE_BASENAME}" ] || [ ! -f "${tmp}/config.tar.gz" ] || [ ! -s "${tmp}/config.tar.gz" ] || [ ! -s "${tmp}/${GO_PACKAGE_BASENAME}" ]; then
1066
run_failed "go.d plugin download failed, go.d plugin will not be available"
1067
+ defer_error "go.d plugin download failed, go.d plugin will not be available"
1068
echo >&2 "Either check the error or consider disabling it by issuing '--disable-go' in the installer"
1069
echo >&2
1070
return 0
@@ -1058,6 +1081,7 @@ install_go() {
1081
echo >&2
1082
1083
run_failed "go.d.plugin package files checksum validation failed."
1084
+ defer_error "go.d.plugin package files checksum validation failed, go.d.plugin will not be available"
1085
return 0
1086
fi
1087
@@ -1487,6 +1511,8 @@ cat << EOF > "${NETDATA_LIB_DIR}/netdata.tarball.checksum"
1511
new_installation
1512
EOF
1513
1514
+print_deferred_errors
1515
+
1516
# -----------------------------------------------------------------------------
1517
echo >&2
1518
progress "We are done!"