Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

journalist notifications: allow 30 minutes variance in reboot times #3479

Merged
merged 2 commits into from Jun 5, 2018
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions install_files/ansible-base/group_vars/staging.yml
Original file line number Diff line number Diff line change
Expand Up @@ -64,3 +64,4 @@ install_local_packages: true
# the Apache service is configured correctly.
securedrop_app_install_from_repo: False

daily_reboot_time: 4 # An integer between 0 and 23
3 changes: 2 additions & 1 deletion install_files/ansible-base/roles/app/tasks/setup_cron.yml
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,7 @@
cron:
name: Update the number of submissions in the past 24h
job: "{{ securedrop_code }}/manage.py were-there-submissions-today"
special_time: daily
# 0 -> 23, 1 -> 0, 2 -> 1, ... 23 -> 22
hour: "{{ (daily_reboot_time + 23) % 24 }}"
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

>>> for x in range(0,24):
...     print((x + 23) % 24)
... 
23
0
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22

tags:
- cron
Original file line number Diff line number Diff line change
Expand Up @@ -17,8 +17,18 @@ function main() {
function modified_in_the_past_24h() {
local stamp
stamp="$1"
#
# 24h is 1440 minutes but we subtract 30min to avoid the following race condition
#
# - machine reboots
# - notification sent
# - machine reboots 24h later but reboots 1 minute faster than the previous day
# - notification is sent 23h59 minutes after the last one and suppressed
#
local one_day
one_day=1410
test -f "${stamp}" && \
find "${stamp}" -mtime -1 | \
find "${stamp}" -mmin "-${one_day}" | \
grep --quiet "${stamp}"
}

Expand Down