bug 1032978: Add a standalone process that listens to pulse for release related buildbot messages. r=bhearsum
authorJohn Zeller <jozeller@mozilla.com>
Wed, 20 Aug 2014 11:04:52 -0400
changeset 4847 0962383550de653196a17316117b26ceb8a264d2
parent 4846 8edcfcb1975574889da4167bf2c71d08d9058259
child 4848 a57f329922701bc72f28ebbef21d495b7b45feaf
push id3572
push userbhearsum@mozilla.com
push dateWed, 20 Aug 2014 15:05:02 +0000
reviewersbhearsum
bugs1032978
bug 1032978: Add a standalone process that listens to pulse for release related buildbot messages. r=bhearsum
buildfarm/release/release-runner.py
lib/python/kickoff/api.py
setup.py
--- a/buildfarm/release/release-runner.py
+++ b/buildfarm/release/release-runner.py
@@ -1,15 +1,16 @@
 #!/usr/bin/env python
 
 import site
 import time
 import logging
 import sys
 import os
+import json
 from os import path
 from optparse import OptionParser
 from smtplib import SMTPException
 from functools import partial
 import textwrap
 from twisted.python.lockfile import FilesystemLock
 
 site.addsitedir(path.join(path.dirname(__file__), "../../lib/python"))
@@ -81,31 +82,32 @@ class ReleaseRunner(object):
     def update_status(self, release, status):
         log.info('updating status for %s to %s' % (release['name'], status))
         try:
             self.release_api.update(release['name'], status=status)
         except requests.HTTPError, e:
             log.warning('Caught HTTPError: %s' % e.response.content)
             log.warning('status update failed, continuing...', exc_info=True)
 
-    def start_release_automation(self, release, master):
+    def start_release_automation(self, release, master, enUSPlatforms):
         sendchange(
             release['branch'],
             getReleaseTag(getBaseTag(release['product'],
                                      release['version'])),
             release['submitter'],
             master,
             release['product']
         )
-        self.mark_as_completed(release)
+        self.mark_as_completed(release, enUSPlatforms)
 
-    def mark_as_completed(self, release):
+    def mark_as_completed(self, release, enUSPlatforms):
         log.info('mark as completed %s' % release['name'])
-        self.release_api.update(
-            release['name'], complete=True, status='Started')
+        self.release_api.update(release['name'], complete=True, 
+                                status='Started', 
+                                enUSPlatforms=json.dumps(enUSPlatforms))
 
     def mark_as_failed(self, release, why):
         log.info('mark as failed %s' % release['name'])
         self.release_api.update(release['name'], ready=False, status=why)
 
 
 def getPartials(release):
     partials = {}
@@ -415,17 +417,21 @@ def main(options):
         for release in rr.new_releases:
             rr.mark_as_failed(release, 'Failed: %s' % repr(e))
         raise
 
     rc = 0
     for release in rr.new_releases:
         try:
             rr.update_status(release, 'Running sendchange command')
-            rr.start_release_automation(release, sendchange_master)
+            cfgFile = getReleaseConfigName(
+                release['product'], path.basename(release['branch']),
+                release['version'], staging)
+            enUSPlatforms = readReleaseConfig(cfgFile)['enUSPlatforms']
+            rr.start_release_automation(release, sendchange_master, enUSPlatforms)
         except:
             # We explicitly do not raise an error here because there's no
             # reason not to start other releases if the sendchange fails for
             # another one. We _do_ need to set this in order to exit
             # with the right code, though.
             rc = 2
             rr.update_status(release, 'Sendchange failed')
             log.error('Sendchange failed for %s: ' % release, exc_info=True)
--- a/lib/python/kickoff/api.py
+++ b/lib/python/kickoff/api.py
@@ -46,24 +46,27 @@ class API(object):
                     config=self.config, timeout=self.timeout,
                     auth=self.auth)
                 self.csrf_token = res.headers['X-CSRF-Token']
             data['csrf_token'] = self.csrf_token
         log.debug('Request to %s' % url)
         log.debug('Data sent: %s' % data)
         try:
             return retry(self.session.request, sleeptime=5, max_sleeptime=15,
-                         retry_exceptions=(requests.HTTPError, requests.ConnectionError),
+                         retry_exceptions=(requests.HTTPError, 
+                                           requests.ConnectionError),
                          attempts=self.retries,
                          kwargs=dict(method=method, url=url, data=data,
                                      config=self.config, timeout=self.timeout,
                                      auth=self.auth, params=params)
-            )
+                        )
         except requests.HTTPError, e:
-            log.error('Caught HTTPError: %d %s' % (e.response.status_code, e.response.content), exc_info=True)
+            log.error('Caught HTTPError: %d %s' % 
+                     (e.response.status_code, e.response.content), 
+                     exc_info=True)
             raise
 
 
 class Releases(API):
     url_template = '/releases'
 
     def getReleases(self, ready=1, complete=0):
         resp = None
@@ -90,16 +93,25 @@ class Release(API):
             log.error('Caught error while getting release', exc_info=True)
             if resp:
                 log.error(resp.content)
                 log.error('Response code: %d' % resp.status_code)
             raise
 
     def update(self, name, **data):
         url_template_vars = {'name': name}
-        return self.request(method='POST', data=data, url_template_vars=url_template_vars).content
+        return self.request(method='POST', data=data, 
+                            url_template_vars=url_template_vars).content
 
 
 class ReleaseL10n(API):
     url_template = '/releases/%(name)s/l10n'
 
     def getL10n(self, name):
         return self.request(url_template_vars={'name': name}).content
+
+
+class Status(API):
+    url_template = '/releases/%(name)s/status'
+
+    def update(self, name, data):
+        return self.request(method='POST', data=data,
+                            url_template_vars={'name': name}).content
--- a/setup.py
+++ b/setup.py
@@ -20,16 +20,17 @@ setup(
     install_requires=[
         'sqlalchemy',
         'argparse',
         'twisted',
         'simplejson',
         'furl',
         'requests',
         'docopt',
+        'python-dateutil',
     ],
 
     entry_points={
         'console_scripts': [
             'slavealloc = slavealloc.scripts.main:main'
         ],
     },