Merge lp:~thomir/charms/trusty/tanuki-spec-manager/trunk-fix-ng-alert into lp:~tanuki/charms/trusty/tanuki-spec-manager/trunk

Proposed by Thomi Richards on 2015-09-22
Status: Merged
Approved by: Celso Providelo on 2015-09-22
Approved revision: 29
Merged at revision: 29
Proposed branch: lp:~thomir/charms/trusty/tanuki-spec-manager/trunk-fix-ng-alert
Merge into: lp:~tanuki/charms/trusty/tanuki-spec-manager/trunk
Diff against target: 31 lines (+7/-3)
1 file modified
hooks/actions.py (+7/-3)
To merge this branch: bzr merge lp:~thomir/charms/trusty/tanuki-spec-manager/trunk-fix-ng-alert
Reviewer Review Type Date Requested Status
Celso Providelo (community) 2015-09-22 Approve on 2015-09-22
Review via email: mp+271908@code.launchpad.net

Commit message

Fix a race condition in the nagios check for the store poller.

Description of the change

Fix a race condition in the nagios check for the store poller.

To post a comment you must log in.
Celso Providelo (cprov) wrote :

Thomi, thanks.

review: Approve

Preview Diff

[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
1=== modified file 'hooks/actions.py'
2--- hooks/actions.py 2015-09-21 14:51:30 +0000
3+++ hooks/actions.py 2015-09-22 04:33:53 +0000
4@@ -325,7 +325,6 @@
5
6 # Builds a nagios check command to verify `store-poller` log file age
7 # according the service configuration.
8- environment = hookenv.Config()['environment']
9 log_path = os.path.join(LOG_DIR, 'store-poller.log')
10 max_age_seconds = int(config['store_poller_nagios_file_age_max_minutes']) * 60
11 check_cmd = "/usr/lib/nagios/plugins/check_file_age -w {0} -c {0} -f {1}".format(
12@@ -334,12 +333,17 @@
13 )
14
15 # If `store-poller` cronscript is enabled in this unit, ensure the log file
16- # exists. Otherwise 'negate' standard check (verifies cronscript is not running).
17+ # exists. Otherwise 'negate' standard check (verifies cronscript is not running).
18 config_unit = config.get('store_poller_unit')
19 local_unit = int(hookenv.local_unit().split('/')[-1])
20 if local_unit == config_unit:
21- host.write_file(log_path,"", "www-data", "www-data", perms=0o660)
22+ host.write_file(log_path, "", "www-data", "www-data", perms=0o660)
23 else:
24+ # The poller might have been run on this unit before, possibly before
25+ # the timeout period. To avoid spurious alerts, we rename the file if
26+ # it exists.
27+ if os.path.exists(log_path):
28+ os.rename(log_path, log_path + ".old")
29 check_cmd = "negate {}".format(check_cmd)
30
31 nrpe_compat.add_check(

Subscribers

People subscribed via source and target branches

to all changes: