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 e92d2ce7a1
.
* 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.
This commit is contained in:
parent
49719a961d
commit
b63d58f1c8
|
@ -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}"
|
||||
|
||||
|
|
|
@ -50,7 +50,7 @@ setup() {
|
|||
|
||||
@test "update netdata" {
|
||||
export ENVIRONMENT_FILE="${ENV}"
|
||||
/etc/cron.daily/netdata-updater
|
||||
${INSTALLATION}/netdata/usr/libexec/netdata/netdata-updater.sh --not-running-from-cron
|
||||
! grep "new_installation" "${ENV}"
|
||||
}
|
||||
|
||||
|
|
|
@ -54,9 +54,8 @@ setup() {
|
|||
@test "update netdata using the new updater" {
|
||||
export ENVIRONMENT_FILE="${ENV}"
|
||||
# Run the updater, with the override so that it uses the local repo we have at hand
|
||||
# Try to run the installed, if any, otherwise just run the one from the repo
|
||||
export NETDATA_LOCAL_TARBAL_OVERRIDE="${PWD}"
|
||||
/etc/cron.daily/netdata-updater || ./packaging/installer/netdata-updater.sh
|
||||
${INSTALLATION}/netdata/usr/libexec/netdata/netdata-updater.sh --not-running-from-cron
|
||||
! grep "new_installation" "${ENV}"
|
||||
}
|
||||
|
||||
|
|
Loading…
Reference in New Issue