@cryptotaxi247 / netdata-1 / commits / b63d58f1c

Add a random offset to the update script when running non-interactively. (#9245)

* Revert "Revert "Introduce a random sleep in the Netdata updater (#9079)" (#9161)" This reverts commit e92d2ce7a155a33ee6b0acfd928f357251c02c69. * Add option to updater to disable randomized delay. Primarily intended for CI, also useful for automated deployment tools like Ansible. * Use correct paths in CI. * Mke variable name match option name.

Austin S. Hemmelgarn committed Jun 3, 2020 at 07:03 UTC b63d58f1c877fd1302aba3c82776e9f9492c61fd
3 files changed +19 -3
packaging/installer/netdata-updater.sh
+17
@@ -213,6 +213,23 @@ tmpdir=
213
214 trap cleanup EXIT
215
216 +while [ -n "${1}" ]; do
217 + if [ "${1}" = "--not-running-from-cron" ]; then
218 + NETDATA_NOT_RUNNING_FROM_CRON=1
219 + shift 1
220 + else
221 + break
222 + fi
223 +done
224 +
225 +# Random sleep to aileviate stampede effect of Agents upgrading
226 +# and disconnecting/reconnecting at the same time (or near to).
227 +# But only we're not a controlling terminal (tty)
228 +# Randomly sleep between 1s and 60m
229 +if [ ! -t 1 ] && [ -z "${NETDATA_NOT_RUNNING_FROM_CRON}" ]; then
230 + sleep $(((RANDOM % 3600) + 1))s
231 +fi
232 +
233 # Usually stored in /etc/netdata/.environment
234 : "${ENVIRONMENT_FILE:=THIS_SHOULD_BE_REPLACED_BY_INSTALLER_SCRIPT}"
235
tests/lifecycle.bats
+1 -1
@@ -50,7 +50,7 @@ setup() {
50
51 @test "update netdata" {
52 export ENVIRONMENT_FILE="${ENV}"
53 - /etc/cron.daily/netdata-updater
53 + ${INSTALLATION}/netdata/usr/libexec/netdata/netdata-updater.sh --not-running-from-cron
54 ! grep "new_installation" "${ENV}"
55 }
56
tests/updater_checks.bats
+1 -2
@@ -54,9 +54,8 @@ setup() {
54 @test "update netdata using the new updater" {
55 export ENVIRONMENT_FILE="${ENV}"
56 # Run the updater, with the override so that it uses the local repo we have at hand
57 - # Try to run the installed, if any, otherwise just run the one from the repo
57 export NETDATA_LOCAL_TARBAL_OVERRIDE="${PWD}"
59 - /etc/cron.daily/netdata-updater || ./packaging/installer/netdata-updater.sh
58 + ${INSTALLATION}/netdata/usr/libexec/netdata/netdata-updater.sh --not-running-from-cron
59 ! grep "new_installation" "${ENV}"
60 }
61