@cryptotaxi247 / netdata-1 / commits / 11cf7564d

Improve offline install error handling. (#17153)

* Handle braindead firewalls that block HTTP HEAD requests. Apparently there exist firewalls out there that allow HTTP GET requests but block HTTP HEAD requests. This causes issues in our installer code because we use HEAD requests to efficiently check if files exist on remote servers. In most cases, correct behavior here is to check if a known valid URL fails our remote file check, and if it does short-circuit the check on subsequent calls. * Bail early if we fail to download anything for offline installs. This ensures we give a proper error message.

Austin S. Hemmelgarn committed Mar 20, 2024 at 10:14 UTC 11cf7564d5e3cdf524c38c6b29141932e5cfcbde
1 file changed +21 -1
packaging/installer/kickstart.sh
+21 -1
@@ -2,7 +2,7 @@
2 #
3 # SPDX-License-Identifier: GPL-3.0-or-later
4 #
5 -# Next unused error code: F0516
5 +# Next unused error code: F0517
6
7 # ======================================================================
8 # Constants
@@ -595,6 +595,8 @@ check_for_remote_file() {
595
596 if echo "${url}" | grep -Eq "^file:///"; then
597 [ -e "${url#file://}" ] || return 1
598 + elif [ -n "${NETDATA_ASSUME_REMOTE_FILES_ARE_PRESENT}" ]; then
599 + return 0
600 elif [ -n "${CURL}" ]; then
601 "${CURL}" --output /dev/null --silent --head --fail "${url}" || return 1
602 elif command -v wget > /dev/null 2>&1; then
@@ -1509,15 +1511,21 @@ try_package_install() {
1511 deb)
1512 repoconfig_file="${repoconfig_name}${pkg_vsep}${REPOCONFIG_DEB_VERSION}${pkg_suffix}.${pkg_type}"
1513 repoconfig_url="${REPOCONFIG_DEB_URL_PREFIX}/${repo_prefix}/${repoconfig_file}"
1514 + ref_check_url="${REPOCONFIG_DEB_URL_PREFIX}"
1515 ;;
1516 rpm)
1517 repoconfig_file="${repoconfig_name}${pkg_vsep}${REPOCONFIG_RPM_VERSION}${pkg_suffix}.${pkg_type}"
1518 repoconfig_url="${REPOCONFIG_RPM_URL_PREFIX}/${repo_prefix}/${SYSARCH}/${repoconfig_file}"
1519 + ref_check_url="${REPOCONFIG_RPM_URL_PREFIX}"
1520 ;;
1521 esac
1522
1523 if ! pkg_installed "${repoconfig_name}"; then
1524 progress "Checking for availability of repository configuration package."
1525 + if ! check_for_remote_file "${ref_check_url}"; then
1526 + NETDATA_ASSUME_REMOTE_FILES_ARE_PRESENT=1
1527 + fi
1528 +
1529 if ! check_for_remote_file "${repoconfig_url}"; then
1530 warning "No repository configuration package available for ${DISTRO} ${SYSVERSION}. Cannot install native packages on this system."
1531 return 2
@@ -1660,6 +1668,10 @@ try_static_install() {
1668 progress "Attempting to install using static build..."
1669 fi
1670
1671 + if ! check_for_remote_file "${NETDATA_TARBALL_BASEURL}"; then
1672 + NETDATA_ASSUME_REMOTE_FILES_ARE_PRESENT=1
1673 + fi
1674 +
1675 # Check status code first, so that we can provide nicer fallback for dry runs.
1676 if check_for_remote_file "${NETDATA_STATIC_ARCHIVE_URL}"; then
1677 netdata_agent="${NETDATA_STATIC_ARCHIVE_NAME}"
@@ -1898,6 +1910,10 @@ prepare_offline_install_source() {
1910 static|'')
1911 set_static_archive_urls "${SELECTED_RELEASE_CHANNEL}" "x86_64"
1912
1913 + if ! check_for_remote_file "${NETDATA_TARBALL_BASEURL}"; then
1914 + NETDATA_ASSUME_REMOTE_FILES_ARE_PRESENT=1
1915 + fi
1916 +
1917 if check_for_remote_file "${NETDATA_STATIC_ARCHIVE_URL}"; then
1918 for arch in ${STATIC_INSTALL_ARCHES}; do
1919 set_static_archive_urls "${SELECTED_RELEASE_CHANNEL}" "${arch}"
@@ -1922,6 +1938,10 @@ prepare_offline_install_source() {
1938 fi
1939 fi
1940
1941 + if ! find . -name '*.gz.run'; then
1942 + fatal "Did not actually download any static installer archives, cannot continue. ${BADNET_MSG}." F0516
1943 + fi
1944 +
1945 progress "Fetching ${NETDATA_STATIC_ARCHIVE_CHECKSUM_URL}"
1946 if ! download "${NETDATA_STATIC_ARCHIVE_CHECKSUM_URL}" "sha256sums.txt"; then
1947 fatal "Failed to download checksum file. ${BADNET_MSG}." F0506