Skip to content

Commit

Permalink
Merge pull request #3479 from dachary/wip-missed-journalist-notification
Browse files Browse the repository at this point in the history
journalist notifications: allow 30 minutes variance in reboot times
  • Loading branch information
heartsucker authored Jun 5, 2018
2 parents 2cd07a1 + 3ef83d5 commit 4a4122d
Show file tree
Hide file tree
Showing 3 changed files with 14 additions and 2 deletions.
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 }}"
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

0 comments on commit 4a4122d

Please sign in to comment.