Merge lp:~hloeung/ubuntu-repository-cache/splay-cron-daily into lp:ubuntu-repository-cache

Proposed by Haw Loeung
Status: Merged
Approved by: Colin Misare
Approved revision: 331
Merged at revision: 331
Proposed branch: lp:~hloeung/ubuntu-repository-cache/splay-cron-daily
Merge into: lp:ubuntu-repository-cache
Diff against target: 48 lines (+28/-0)
2 files modified
files/cron_random_sleep.sh (+23/-0)
reactive/ubuntu_repository_cache.py (+5/-0)
To merge this branch: bzr merge lp:~hloeung/ubuntu-repository-cache/splay-cron-daily
Reviewer Review Type Date Requested Status
Colin Misare Approve
Canonical IS Reviewers Pending
Review via email: mp+399553@code.launchpad.net

Commit message

Ensure daily apache2 graceful restart is splayed - LP:1918211

We ship out a random sleep script to cron.daily to ensure that
graceful restarts from logrotation is spread out across the various
units.

To post a comment you must log in.
Revision history for this message
🤖 Canonical IS Merge Bot (canonical-is-mergebot) wrote :

This merge proposal is being monitored by mergebot. Change the status to Approved to merge.

Revision history for this message
Colin Misare (cmisare) wrote :

LGTM

review: Approve
Revision history for this message
🤖 Canonical IS Merge Bot (canonical-is-mergebot) wrote :

Change successfully merged at revision 331

Revision history for this message
Junien F (axino) wrote :

May I suggest RAND=$(( RANDOM % (MAX-MIN) + MIN )) ?

Revision history for this message
Haw Loeung (hloeung) wrote :

Preview Diff

[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
=== added file 'files/cron_random_sleep.sh'
--- files/cron_random_sleep.sh 1970-01-01 00:00:00 +0000
+++ files/cron_random_sleep.sh 2021-03-11 23:44:25 +0000
@@ -0,0 +1,23 @@
1#!/bin/bash
2
3# Taken from basenode.
4
5# Maximum of 20 mins.
6MAX=1200
7# Minimum of 30 secs.
8MIN=30
9
10RAND=$RANDOM
11(( RAND %= $MAX ))
12
13if [ $RAND -lt $MIN ]; then
14 echo $RAND
15 (( RAND += MIN ))
16fi
17
18# if we're running it from the command line, don't sleep
19if [ -t 0 ]; then
20 echo skipped sleep $RAND
21else
22 sleep $RAND
23fi
024
=== modified file 'reactive/ubuntu_repository_cache.py'
--- reactive/ubuntu_repository_cache.py 2021-03-08 22:18:19 +0000
+++ reactive/ubuntu_repository_cache.py 2021-03-11 23:44:25 +0000
@@ -6,6 +6,7 @@
66
7import os7import os
8import pwd8import pwd
9import shutil
910
10from charms import reactive11from charms import reactive
11from charms.layer import status12from charms.layer import status
@@ -68,6 +69,10 @@
68 LOG('Disabling {}'.format(azure_disk_warning))69 LOG('Disabling {}'.format(azure_disk_warning))
69 host.service_pause(azure_disk_warning)70 host.service_pause(azure_disk_warning)
7071
72 # We want to ensure not all units rotate out and graceful
73 # restart/reload apache at the same time.
74 shutil.copy2('files/cron_random_sleep.sh', '/etc/cron.daily/000-cron-random-sleep')
75
71 reactive.set_flag('ubuntu-repository-cache.configured')76 reactive.set_flag('ubuntu-repository-cache.configured')
7277
7378

Subscribers

People subscribed via source and target branches