Merge lp:~cprov/charms/trusty/tanuki-spec-manager/store-poller-fixes into lp:~tanuki/charms/trusty/tanuki-spec-manager/trunk

Proposed by Celso Providelo
Status: Merged
Approved by: Celso Providelo
Approved revision: 26
Merged at revision: 26
Proposed branch: lp:~cprov/charms/trusty/tanuki-spec-manager/store-poller-fixes
Merge into: lp:~tanuki/charms/trusty/tanuki-spec-manager/trunk
Diff against target: 40 lines (+4/-10)
2 files modified
hooks/actions.py (+3/-8)
templates/store-poller.cron (+1/-2)
To merge this branch: bzr merge lp:~cprov/charms/trusty/tanuki-spec-manager/store-poller-fixes
Reviewer Review Type Date Requested Status
Thomi Richards (community) Approve
Review via email: mp+271420@code.launchpad.net

Commit message

Fixing upgrading issue (empty hookenv.Config(), using global config) and also adjusting store-poller cron template to benefit of new logging support.

Description of the change

Fixing upgrading issue (empty hookenv.Config(), using global config) and also adjusting store-poller cron template to benefit of new logging support.

To post a comment you must log in.
Revision history for this message
Thomi Richards (thomir-deactivatedaccount) wrote :

LGTM

review: Approve

Preview Diff

[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
=== modified file 'hooks/actions.py'
--- hooks/actions.py 2015-09-17 01:09:03 +0000
+++ hooks/actions.py 2015-09-17 04:18:22 +0000
@@ -328,22 +328,17 @@
328328
329 if local_unit == config_unit:329 if local_unit == config_unit:
330 environment = hookenv.Config()['environment']330 environment = hookenv.Config()['environment']
331 log_path = os.path.join('/srv/spec-manager/', environment, 'logs/store_poller.log')331 log_path = os.path.join(LOG_DIR, 'store-poller.log')
332 # Create the file now, so the nagios check doesn't fail right after332 # Create the file now, so the nagios check doesn't fail right after
333 # we've completed the deployment.333 # we've completed the deployment.
334 host.write_file(log_path,"", "www-data", "www-data")334 host.write_file(log_path,"", "www-data", "www-data")
335 max_age_seconds = int(config['store_poller_nagios_file_age_max_minutes']) * 60
335 nrpe_compat.add_check(336 nrpe_compat.add_check(
336 shortname="store_poller_check",337 shortname="store_poller_check",
337 description="Store poller check.",338 description="Store poller check.",
338 check_cmd="/usr/lib/nagios/plugins/check_file_age -w {0} -c {0} -f {1}".format(339 check_cmd="/usr/lib/nagios/plugins/check_file_age -w {0} -c {0} -f {1}".format(
339 get_poll_frequency_in_seconds(),340 max_age_seconds,
340 log_path,341 log_path,
341 )342 )
342 )343 )
343 nrpe_compat.write()344 nrpe_compat.write()
344
345
346def get_poll_frequency_in_seconds():
347 config = hookenv.Config()
348 max_age_minutes = int(config['store_poller_nagios_file_age_max_minutes'])
349 return max_age_minutes * 60
350345
=== modified file 'templates/store-poller.cron'
--- templates/store-poller.cron 2015-09-16 05:34:29 +0000
+++ templates/store-poller.cron 2015-09-17 04:18:22 +0000
@@ -3,5 +3,4 @@
3# Run installed `store_poller.py` script according3# Run installed `store_poller.py` script according
4# to charm configuration. 4# to charm configuration.
55
6{{ store_poller_frequency }} www-data run-one sh -c 'cd /srv/spec-manager/{{ environment }}/spec-manager && ./env/bin/python3 scripts/store_poller.py -c service.conf' 2>&1 >> /srv/spec-manager/{{ environment }}/logs/store_poller.log6{{ store_poller_frequency }} www-data run-one sh -c 'cd /srv/spec-manager/{{ environment }}/spec-manager && LOG_DIR=../logs ./env/bin/python3 scripts/store_poller.py -c service.conf' 2>&1 >> /dev/null
7

Subscribers

People subscribed via source and target branches

to all changes: