diff options
author | Austin S. Hemmelgarn <austin@netdata.cloud> | 2020-06-03 07:03:55 -0400 |
---|---|---|
committer | GitHub <noreply@github.com> | 2020-06-03 07:03:55 -0400 |
commit | b63d58f1c877fd1302aba3c82776e9f9492c61fd (patch) | |
tree | 6c7e8fa8b0b5fe303926c08520f696bc9b9fcfb3 /packaging/installer/netdata-updater.sh | |
parent | 49719a961d6c079004b65458ea8c5e08ada1c44c (diff) |
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.
Diffstat (limited to 'packaging/installer/netdata-updater.sh')
-rwxr-xr-x | packaging/installer/netdata-updater.sh | 17 |
1 files changed, 17 insertions, 0 deletions
diff --git a/packaging/installer/netdata-updater.sh b/packaging/installer/netdata-updater.sh index 922d63eaa6..7e2b630a23 100755 --- a/packaging/installer/netdata-updater.sh +++ b/packaging/installer/netdata-updater.sh @@ -213,6 +213,23 @@ tmpdir= trap cleanup EXIT +while [ -n "${1}" ]; do + if [ "${1}" = "--not-running-from-cron" ]; then + NETDATA_NOT_RUNNING_FROM_CRON=1 + shift 1 + else + break + fi +done + +# Random sleep to aileviate stampede effect of Agents upgrading +# and disconnecting/reconnecting at the same time (or near to). +# But only we're not a controlling terminal (tty) +# Randomly sleep between 1s and 60m +if [ ! -t 1 ] && [ -z "${NETDATA_NOT_RUNNING_FROM_CRON}" ]; then + sleep $(((RANDOM % 3600) + 1))s +fi + # Usually stored in /etc/netdata/.environment : "${ENVIRONMENT_FILE:=THIS_SHOULD_BE_REPLACED_BY_INSTALLER_SCRIPT}" |