Merge lp:~abentley/charms/precise/juju-reports/cron-store-trigger into lp:~juju-qa/charms/precise/juju-reports/trunk

Proposed by Aaron Bentley on 2014-08-14
Status: Merged
Merged at revision: 42
Proposed branch: lp:~abentley/charms/precise/juju-reports/cron-store-trigger
Merge into: lp:~juju-qa/charms/precise/juju-reports/trunk
Diff against target: 66 lines (+23/-7)
2 files modified
hooks/common.py (+21/-6)
templates/crontab.tmpl (+2/-1)
To merge this branch: bzr merge lp:~abentley/charms/precise/juju-reports/cron-store-trigger
Reviewer Review Type Date Requested Status
Curtis Hovey (community) code 2014-08-14 Approve on 2014-08-14
Review via email: mp+230853@code.launchpad.net

Commit message

Add store-trigger & cbtest to cron, update template handling.

Description of the change

Add store-trigger and cbtest to cron.

cbtest is run before store-trigger because store-trigger needs to know about all tests that were run.

The charm is updated to delete the template if the required variables are mising, so that stale templates are not left behind.

The check for unset variables now lists all unset variables at once.

Fixed the mailto handling. It was broken because error-email will be the empty string, not None, if unset.

To post a comment you must log in.
Curtis Hovey (sinzui) wrote :

Thank you.

review: Approve (code)

Preview Diff

[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
1=== modified file 'hooks/common.py'
2--- hooks/common.py 2014-08-08 18:55:10 +0000
3+++ hooks/common.py 2014-08-14 16:56:21 +0000
4@@ -170,15 +170,28 @@
5 subprocess.check_call(['apt-get', 'autoremove', '--yes'])
6
7
8+def update_cronjob(contents=None):
9+ path = '/etc/cron.d/ubuntu'
10+ if contents is None:
11+ try:
12+ os.unlink(path)
13+ except OSError as e:
14+ if e.errno != errno.ENOENT:
15+ raise
16+ else:
17+ with open('/etc/cron.d/ubuntu', 'w') as outfile:
18+ outfile.write(contents)
19+
20+
21 def install_cronjob(interval, error_email):
22 t = Template(file='templates/crontab.tmpl')
23 t.interval = interval
24- if error_email is not None:
25+ if error_email != '':
26 t.error_email = 'MAILTO=%s' % error_email
27 else:
28 t.error_email = ''
29 t.reports_home = PROJECT_DIR
30- open('/etc/cron.d/ubuntu', 'w').write(str(t))
31+ update_cronjob(str(t))
32
33
34 def ini_get(ini, section, key):
35@@ -261,10 +274,12 @@
36 ini = install_ini(mongo_url, config['gh-token'], config['jujuci-url'],
37 config['charm-bundle-test-token'])
38 configure_s3(config)
39- for key in ['lp-key', 'lp-oauth', 'gh-token']:
40- if config[key] == '':
41- hookenv.log('Not setting up cron because {} not set.'.format(key))
42- break
43+ unset = [key for key in ['lp-key', 'lp-oauth', 'gh-token',
44+ 'charm-bundle-test-token'] if config[key] == '']
45+ if len(unset) > 0:
46+ hookenv.log('Not setting up cron because {} not set.'.format(
47+ ', '.join(unset)))
48+ update_cronjob(None)
49 else:
50 install_cronjob(config['cron-interval'], config['error-email'])
51 start()
52
53=== modified file 'templates/crontab.tmpl'
54--- templates/crontab.tmpl 2014-05-29 18:58:13 +0000
55+++ templates/crontab.tmpl 2014-08-14 16:56:21 +0000
56@@ -2,8 +2,9 @@
57 PATH=/usr/local/sbin:/usr/local/bin:/sbin:/bin:/usr/sbin:/usr/bin
58 $error_email
59
60+* * * * * ubuntu INI=$reports_home/production.ini $reports_home/bin/cbtest > /dev/null && INI=$reports_home/production.ini $reports_home/bin/store-trigger > /dev/null 2> /dev/null
61 */$interval * * * * ubuntu INI=$reports_home/production.ini $reports_home/bin/python $reports_home/jujureports/jobs/jujuci.py
62-*/$interval * * * * ubuntu INI=$reports_home/production.ini $reports_home/bin/python $reports_home/jujureports/jobs/charm_testing.py
63+# */$interval * * * * ubuntu INI=$reports_home/production.ini $reports_home/bin/python $reports_home/jujureports/jobs/charm_testing.py
64 # The weekday below should match the value scorecard.collection_day
65 # in the file production.ini in lp:juju-reports.
66 0 16 * * 0 ubuntu INI=$reports_home/production.ini $reports_home/bin/update-stats $reports_home/bugs.json $reports_home/jujureports/lp_credentials.txt

Subscribers

People subscribed via source and target branches

to all changes: