Browse Source

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 5 years ago
parent
commit
bec7b83e19
1 changed files with 26 additions and 0 deletions
  1. 26 0
      netdata-installer.sh

+ 26 - 0
netdata-installer.sh

@@ -40,6 +40,24 @@ fi
 # make sure /etc/profile does not change our current directory
 cd "${NETDATA_SOURCE_DIR}" || exit 1
 
+# -----------------------------------------------------------------------------
+# set up handling for deferred error messages
+NETDATA_DEFERRED_ERRORS=""
+
+defer_error() {
+  NETDATA_DEFERRED_ERRORS="${NETDATA_DEFERRED_ERRORS}\n* ${1}"
+}
+
+print_deferred_errors() {
+  if [ -n "${NETDATA_DEFERRED_ERRORS}" ] ; then
+    echo >&2
+    echo >&2 "The following non-fatal errors were encountered during the installation process:"
+    # shellcheck disable=SC2059
+    printf >&2 "${NETDATA_DEFERRED_ERRORS}"
+    echo >&2
+  fi
+}
+
 # -----------------------------------------------------------------------------
 # load the required functions
 
@@ -480,9 +498,11 @@ bundle_libmosquitto() {
       run_ok "libmosquitto built and prepared."
     else
       run_failed "Failed to build libmosquitto. The install process will continue, but you will not be able to connect this node to Netdata Cloud."
+      defer_error "Failed to build libmosquitto. The install process will continue, but you will not be able to connect this node to Netdata Cloud."
     fi
   else
     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."
+    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."
   fi
 }
 
@@ -532,9 +552,11 @@ bundle_libwebsockets() {
       run_ok "libwebsockets built and prepared."
     else
       run_failed "Failed to build libwebsockets. The install process will continue, but you may not be able to connect this node to Netdata Cloud."
+      defer_error "Failed to build libwebsockets. The install process will continue, but you may not be able to connect this node to Netdata Cloud."
     fi
   else
     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."
+    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."
   fi
 }
 
@@ -1042,6 +1064,7 @@ install_go() {
 
   if [ ! -f "${tmp}/${GO_PACKAGE_BASENAME}" ] || [ ! -f "${tmp}/config.tar.gz" ] || [ ! -s "${tmp}/config.tar.gz" ] || [ ! -s "${tmp}/${GO_PACKAGE_BASENAME}" ]; then
     run_failed "go.d plugin download failed, go.d plugin will not be available"
+    defer_error "go.d plugin download failed, go.d plugin will not be available"
     echo >&2 "Either check the error or consider disabling it by issuing '--disable-go' in the installer"
     echo >&2
     return 0
@@ -1058,6 +1081,7 @@ install_go() {
     echo >&2
 
     run_failed "go.d.plugin package files checksum validation failed."
+    defer_error "go.d.plugin package files checksum validation failed, go.d.plugin will not be available"
     return 0
   fi
 
@@ -1487,6 +1511,8 @@ cat << EOF > "${NETDATA_LIB_DIR}/netdata.tarball.checksum"
 new_installation
 EOF
 
+print_deferred_errors
+
 # -----------------------------------------------------------------------------
 echo >&2
 progress "We are done!"