@cryptotaxi247 / netdata-1 / commits / 22469558b

Report inability to update due to native packages no longer being published. (#21288)

* Report inability to update due to native packages no longer being published. This adds an extra check in the `netdata-updater.sh` script to fail with an error when trying to update a system that uses our native packages if we have stopped publishing our native packages. The check utilizes a flag file generated by the repository backend code to determine if we are actually publishing packages for the platform or not. If the flag file is not present, then the update process bails very early on with an error message indicating that the user needs to change to a different install type, and a link pointing to our documentation of how to switch install types. * Address review comments. * Skip version change check if no release channel can be determined. Fixes: #21328 * Fix incorrect variable name. * Add missing SYSVERSION definition. * Use correct version flag for version checks in updater. * Don’t duplicate fetching of installed agent version in updater. In the native package handling code, instead of invoking `netdata -V` a second time, just use the parsed version number to determine if something is a nightly build or a stable build. This matches on whether the final five digits of the prased version number are all zeroes (which indicates a stable build) or not.

Austin S. Hemmelgarn committed Dec 8, 2025 at 07:13 UTC 22469558bd735a9821ca39d632bf0b22c9bed063
1 file changed +68 -13
packaging/installer/netdata-updater.sh
+68 -13
@@ -22,7 +22,7 @@
22 # - TMPDIR (set to a usable temporary directory)
23 # - NETDATA_NIGHTLIES_BASEURL (set the base url for downloading the dist tarball)
24
25 -# Next unused error code: U001E
25 +# Next unused error code: U001F
26
27 set -e
28
@@ -30,6 +30,8 @@ PACKAGES_SCRIPT="https://raw.githubusercontent.com/netdata/netdata/master/packag
30
31 NETDATA_STABLE_BASE_URL="${NETDATA_BASE_URL:-https://github.com/netdata/netdata/releases}"
32 NETDATA_NIGHTLY_BASE_URL="${NETDATA_BASE_URL:-https://github.com/netdata/netdata-nightlies/releases}"
33 +NETDATA_STABLE_REPO_URL="${NETDATA_BASE_URL:-https://repository.netdata.cloud/repos/stable}"
34 +NETDATA_NIGHTLY_REPO_URL="${NETDATA_BASE_URL:-https://repository.netdata.cloud/repos/edge}"
35 NETDATA_DEFAULT_ACCEPT_MAJOR_VERSIONS="1 2"
36
37 # Following variables are intended to be overridden by the updater config file.
@@ -602,8 +604,10 @@ download() {
604 url="${1}"
605 dest="${2}"
606
607 + set +e
608 _safe_download "${url}" "${dest}"
609 ret=$?
610 + set -e
611
612 if [ ${ret} -eq 0 ]; then
613 return 0
@@ -787,7 +791,7 @@ get_current_version() {
791 if [ -z "${ndbinary}" ]; then
792 _current_version=0
793 else
790 - _current_version="$(parse_version "$(${ndbinary} -v | cut -f 2 -d ' ')")"
794 + _current_version="$(parse_version "$(${ndbinary} -V | cut -f 2 -d ' ')")"
795 fi
796
797 echo "${_current_version:-0}"
@@ -1038,6 +1042,7 @@ update_binpkg() {
1042 . "${os_release_file}"
1043
1044 DISTRO="${ID}"
1045 + SYSVERSION="${VERSION_ID}"
1046
1047 supported_compat_names="debian ubuntu centos fedora opensuse ol amzn"
1048
@@ -1083,6 +1088,9 @@ update_binpkg() {
1088 repo_update_opts="${interactive_opts}"
1089 pkg_installed_check="dpkg-query -s"
1090 INSTALL_TYPE="binpkg-deb"
1091 + if [ -n "${VERSION_CODENAME}" ]; then
1092 + repo_path="${DISTRO_COMPAT_NAME}/${VERSION_CODENAME}"
1093 + fi
1094 ;;
1095 centos|fedora|ol|amzn)
1096 if [ "${INTERACTIVE}" = "0" ]; then
@@ -1102,6 +1110,7 @@ update_binpkg() {
1110 repo_update_opts="${interactive_opts}"
1111 pkg_installed_check="rpm -q"
1112 INSTALL_TYPE="binpkg-rpm"
1113 + repo_path="${DISTRO_COMPAT_NAME}/${SYSVERSION}/$(uname -m)"
1114 ;;
1115 opensuse)
1116 if [ "${INTERACTIVE}" = "0" ]; then
@@ -1117,6 +1126,7 @@ update_binpkg() {
1126 repo_update_opts=""
1127 pkg_installed_check="rpm -q"
1128 INSTALL_TYPE="binpkg-rpm"
1129 + repo_path="${DISTRO_COMPAT_NAME}/${SYSVERSION}/$(uname -m)"
1130 ;;
1131 *)
1132 warning "We do not provide native packages for ${DISTRO}."
@@ -1131,18 +1141,63 @@ update_binpkg() {
1141 env ${env} ${pm_cmd} ${repo_subcmd} ${repo_update_opts} >&3 2>&3 || fatal "Failed to update repository metadata." U000C
1142 fi
1143
1134 - for repopkg in netdata-repo netdata-repo-edge; do
1135 - if ${pkg_installed_check} ${repopkg} > /dev/null 2>&1; then
1136 - # shellcheck disable=SC2086
1137 - env ${env} ${pm_cmd} ${upgrade_subcmd} ${pkg_install_opts} ${repopkg} >&3 2>&3 || fatal "Failed to update Netdata repository config." U000D
1138 - # shellcheck disable=SC2086
1139 - if [ -n "${repo_subcmd}" ]; then
1140 - env ${env} ${pm_cmd} ${repo_subcmd} ${repo_update_opts} >&3 2>&3 || fatal "Failed to update repository metadata." U000E
1141 - fi
1144 + if ${pkg_installed_check} netdata-repo > /dev/null 2>&1; then
1145 + RELEASE_CHANNEL="stable"
1146 + repopkg="netdata-repo"
1147 + elif ${pkg_installed_check} netdata-repo-edge > /dev/null 2>&1; then
1148 + RELEASE_CHANNEL="nightly"
1149 + repopkg="netdata-repo-edge"
1150 + elif echo "${initial_version}" | grep -Eq -- '^[0-9]*[1-9][0-9]*0{5}$'; then # All five final digits are zero and at least one preceeding digit is non-zero.
1151 + RELEASE_CHANNEL="stable"
1152 + elif echo "${initial_version}" | grep -Eq -- '^[0-9]*[1-9][0-9]{0,4}$'; then # At least one of the final five digits is non-zero.
1153 + RELEASE_CHANNEL="nightly"
1154 + else
1155 + RELEASE_CHANNEL="none"
1156 + warning "Unable to determine which release channel is being used on this system, cannot check if packages are still being published."
1157 + fi
1158 +
1159 + if [ -n "${repo_path}" ]; then
1160 + case "${RELEASE_CHANNEL}" in
1161 + stable) check_url="${NETDATA_STABLE_REPO_URL}/${repo_path}/.currently.published" ;;
1162 + nightly) check_url="${NETDATA_NIGHTLY_REPO_URL}/${repo_path}/.currently.published" ;;
1163 + esac
1164 + fi
1165 +
1166 + if [ -n "${check_url}" ]; then
1167 + info "Checking if native packages are still being published for this platform."
1168 +
1169 + set +e
1170 + _safe_download "${check_url}" /dev/null
1171 + ret=$?
1172 + set -e
1173 +
1174 + case "${ret}" in
1175 + 0) info "Native packages are still being published for this platform." ;;
1176 + 1)
1177 + error ""
1178 + error "NETDATA CANNOT BE UPDATED ON THIS SYSTEM!"
1179 + error ""
1180 + error "Native packages are no longer being published for this platform."
1181 + error ""
1182 + error "To update to the latest version of Netdata, you will need to switch to a different install type."
1183 + error "For details on how to do so, see https://learn.netdata.cloud/docs/netdata-agent/installation/linux/switch-install-types-and-release-channels"
1184 + error ""
1185 + fatal "Unable to update due to native packages no longer being published for this platform" U001E
1186 + ;;
1187 + 255) warning "Unable to check whether native packages are being published, wget or curl is required." ;;
1188 + esac
1189 + fi
1190 +
1191 + if [ -n "${repopkg}" ]; then
1192 + # shellcheck disable=SC2086
1193 + env ${env} ${pm_cmd} ${upgrade_subcmd} ${pkg_install_opts} ${repopkg} >&3 2>&3 || fatal "Failed to update Netdata repository config." U000D
1194 + # shellcheck disable=SC2086
1195 + if [ -n "${repo_subcmd}" ]; then
1196 + env ${env} ${pm_cmd} ${repo_subcmd} ${repo_update_opts} >&3 2>&3 || fatal "Failed to update repository metadata." U000E
1197 fi
1143 - done
1198 + fi
1199
1145 - current_major="$(netdata -v | cut -f 2 -d ' ' | cut -f 1 -d '.' | tr -d 'v')"
1200 + current_major="$(echo "${nd_version}" | cut -f 1 -d '.' | tr -d 'v')"
1201 latest_major="$(get_new_binpkg_major)"
1202
1203 if [ -n "${latest_major}" ] && [ "${latest_major}" -ne "${current_major}" ]; then
@@ -1179,7 +1234,7 @@ update_binpkg() {
1234 current_version="$(get_current_version)"
1235 latest_version="$(get_latest_version)"
1236
1182 - if [ "${current_version}" -ne 0 ] && [ "${latest_version}" -ne 0 ]; then
1237 + if [ "${RELEASE_CHANNEL}" != "none" ] && [ "${current_version}" -ne 0 ] && [ "${latest_version}" -ne 0 ]; then
1238 if [ "${current_version}" -lt "${latest_version}" ] && [ "${initial_version}" -eq "${current_version}" ]; then
1239 error ""
1240 error "NETDATA WAS NOT UPDATED!"