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

Proposed by Aaron Bentley
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 Approve
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.
Revision history for this message
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
=== modified file 'hooks/common.py'
--- hooks/common.py 2014-08-08 18:55:10 +0000
+++ hooks/common.py 2014-08-14 16:56:21 +0000
@@ -170,15 +170,28 @@
170 subprocess.check_call(['apt-get', 'autoremove', '--yes'])170 subprocess.check_call(['apt-get', 'autoremove', '--yes'])
171171
172172
173def update_cronjob(contents=None):
174 path = '/etc/cron.d/ubuntu'
175 if contents is None:
176 try:
177 os.unlink(path)
178 except OSError as e:
179 if e.errno != errno.ENOENT:
180 raise
181 else:
182 with open('/etc/cron.d/ubuntu', 'w') as outfile:
183 outfile.write(contents)
184
185
173def install_cronjob(interval, error_email):186def install_cronjob(interval, error_email):
174 t = Template(file='templates/crontab.tmpl')187 t = Template(file='templates/crontab.tmpl')
175 t.interval = interval188 t.interval = interval
176 if error_email is not None:189 if error_email != '':
177 t.error_email = 'MAILTO=%s' % error_email190 t.error_email = 'MAILTO=%s' % error_email
178 else:191 else:
179 t.error_email = ''192 t.error_email = ''
180 t.reports_home = PROJECT_DIR193 t.reports_home = PROJECT_DIR
181 open('/etc/cron.d/ubuntu', 'w').write(str(t))194 update_cronjob(str(t))
182195
183196
184def ini_get(ini, section, key):197def ini_get(ini, section, key):
@@ -261,10 +274,12 @@
261 ini = install_ini(mongo_url, config['gh-token'], config['jujuci-url'],274 ini = install_ini(mongo_url, config['gh-token'], config['jujuci-url'],
262 config['charm-bundle-test-token'])275 config['charm-bundle-test-token'])
263 configure_s3(config)276 configure_s3(config)
264 for key in ['lp-key', 'lp-oauth', 'gh-token']:277 unset = [key for key in ['lp-key', 'lp-oauth', 'gh-token',
265 if config[key] == '':278 'charm-bundle-test-token'] if config[key] == '']
266 hookenv.log('Not setting up cron because {} not set.'.format(key))279 if len(unset) > 0:
267 break280 hookenv.log('Not setting up cron because {} not set.'.format(
281 ', '.join(unset)))
282 update_cronjob(None)
268 else:283 else:
269 install_cronjob(config['cron-interval'], config['error-email'])284 install_cronjob(config['cron-interval'], config['error-email'])
270 start()285 start()
271286
=== modified file 'templates/crontab.tmpl'
--- templates/crontab.tmpl 2014-05-29 18:58:13 +0000
+++ templates/crontab.tmpl 2014-08-14 16:56:21 +0000
@@ -2,8 +2,9 @@
2PATH=/usr/local/sbin:/usr/local/bin:/sbin:/bin:/usr/sbin:/usr/bin2PATH=/usr/local/sbin:/usr/local/bin:/sbin:/bin:/usr/sbin:/usr/bin
3$error_email3$error_email
44
5* * * * * 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
5*/$interval * * * * ubuntu INI=$reports_home/production.ini $reports_home/bin/python $reports_home/jujureports/jobs/jujuci.py6*/$interval * * * * ubuntu INI=$reports_home/production.ini $reports_home/bin/python $reports_home/jujureports/jobs/jujuci.py
6*/$interval * * * * ubuntu INI=$reports_home/production.ini $reports_home/bin/python $reports_home/jujureports/jobs/charm_testing.py7# */$interval * * * * ubuntu INI=$reports_home/production.ini $reports_home/bin/python $reports_home/jujureports/jobs/charm_testing.py
7# The weekday below should match the value scorecard.collection_day8# The weekday below should match the value scorecard.collection_day
8# in the file production.ini in lp:juju-reports.9# in the file production.ini in lp:juju-reports.
90 16 * * 0 ubuntu INI=$reports_home/production.ini $reports_home/bin/update-stats $reports_home/bugs.json $reports_home/jujureports/lp_credentials.txt100 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: