From 11cf7564d5e3cdf524c38c6b29141932e5cfcbde Mon Sep 17 00:00:00 2001 From: "Austin S. Hemmelgarn" Date: Wed, 20 Mar 2024 10:14:51 -0400 Subject: 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. --- packaging/installer/kickstart.sh | 22 +++++++++++++++++++++- 1 file changed, 21 insertions(+), 1 deletion(-) diff --git a/packaging/installer/kickstart.sh b/packaging/installer/kickstart.sh index 04b34fd77f..6d9f4ea0e7 100755 --- a/packaging/installer/kickstart.sh +++ b/packaging/installer/kickstart.sh @@ -2,7 +2,7 @@ # # SPDX-License-Identifier: GPL-3.0-or-later # -# Next unused error code: F0516 +# Next unused error code: F0517 # ====================================================================== # Constants @@ -595,6 +595,8 @@ check_for_remote_file() { if echo "${url}" | grep -Eq "^file:///"; then [ -e "${url#file://}" ] || return 1 + elif [ -n "${NETDATA_ASSUME_REMOTE_FILES_ARE_PRESENT}" ]; then + return 0 elif [ -n "${CURL}" ]; then "${CURL}" --output /dev/null --silent --head --fail "${url}" || return 1 elif command -v wget > /dev/null 2>&1; then @@ -1509,15 +1511,21 @@ try_package_install() { deb) repoconfig_file="${repoconfig_name}${pkg_vsep}${REPOCONFIG_DEB_VERSION}${pkg_suffix}.${pkg_type}" repoconfig_url="${REPOCONFIG_DEB_URL_PREFIX}/${repo_prefix}/${repoconfig_file}" + ref_check_url="${REPOCONFIG_DEB_URL_PREFIX}" ;; rpm) repoconfig_file="${repoconfig_name}${pkg_vsep}${REPOCONFIG_RPM_VERSION}${pkg_suffix}.${pkg_type}" repoconfig_url="${REPOCONFIG_RPM_URL_PREFIX}/${repo_prefix}/${SYSARCH}/${repoconfig_file}" + ref_check_url="${REPOCONFIG_RPM_URL_PREFIX}" ;; esac if ! pkg_installed "${repoconfig_name}"; then progress "Checking for availability of repository configuration package." + if ! check_for_remote_file "${ref_check_url}"; then + NETDATA_ASSUME_REMOTE_FILES_ARE_PRESENT=1 + fi + if ! check_for_remote_file "${repoconfig_url}"; then warning "No repository configuration package available for ${DISTRO} ${SYSVERSION}. Cannot install native packages on this system." return 2 @@ -1660,6 +1668,10 @@ try_static_install() { progress "Attempting to install using static build..." fi + if ! check_for_remote_file "${NETDATA_TARBALL_BASEURL}"; then + NETDATA_ASSUME_REMOTE_FILES_ARE_PRESENT=1 + fi + # Check status code first, so that we can provide nicer fallback for dry runs. if check_for_remote_file "${NETDATA_STATIC_ARCHIVE_URL}"; then netdata_agent="${NETDATA_STATIC_ARCHIVE_NAME}" @@ -1898,6 +1910,10 @@ prepare_offline_install_source() { static|'') set_static_archive_urls "${SELECTED_RELEASE_CHANNEL}" "x86_64" + if ! check_for_remote_file "${NETDATA_TARBALL_BASEURL}"; then + NETDATA_ASSUME_REMOTE_FILES_ARE_PRESENT=1 + fi + if check_for_remote_file "${NETDATA_STATIC_ARCHIVE_URL}"; then for arch in ${STATIC_INSTALL_ARCHES}; do set_static_archive_urls "${SELECTED_RELEASE_CHANNEL}" "${arch}" @@ -1922,6 +1938,10 @@ prepare_offline_install_source() { fi fi + if ! find . -name '*.gz.run'; then + fatal "Did not actually download any static installer archives, cannot continue. ${BADNET_MSG}." F0516 + fi + progress "Fetching ${NETDATA_STATIC_ARCHIVE_CHECKSUM_URL}" if ! download "${NETDATA_STATIC_ARCHIVE_CHECKSUM_URL}" "sha256sums.txt"; then fatal "Failed to download checksum file. ${BADNET_MSG}." F0506 -- cgit v1.2.3