Bug 1300707 - Expose release sanity errors to ship-it status
☠☠ backed out by cde062b6173c ☠ ☠
authorJohan Lorenzo <jlorenzo@mozilla.com>
Tue, 06 Sep 2016 15:36:50 +0200
changeset 7013 865684261e4ed38b10a3c92f7eecaa8a834d0479
parent 7012 8d577a74ae0f9168c501ad604fd890e8c3f60ae3
child 7014 cde062b6173c1d3ce05968918daad3bc9addeca9
push id5231
push userjlorenzo@mozilla.com
push dateTue, 06 Sep 2016 16:27:07 +0000
bugs1300707
Bug 1300707 - Expose release sanity errors to ship-it status MozReview-Commit-ID: ESvlJTliq82
buildfarm/release/release-runner.py
lib/python/kickoff/__init__.py
--- a/buildfarm/release/release-runner.py
+++ b/buildfarm/release/release-runner.py
@@ -428,27 +428,29 @@ def main(options):
             import pprint
             log.debug(pprint.pformat(graph, indent=4, width=160))
             print scheduler.createTaskGraph(graph_id, graph)
 
             rr.mark_as_completed(release)
             email_release_drivers(smtp_server=smtp_server, from_=notify_from,
                                   to=notify_to, release=release,
                                   task_group_id=graph_id)
-        except:
+        except Exception, exception:
             # We explicitly do not raise an error here because there's no
             # reason not to start other releases if creating the Task Graph
             # fails for another one. We _do_ need to set this in order to exit
             # with the right code, though.
             rc = 2
             rr.mark_as_failed(
                 release,
-                'Failed to start release promotion (graph ID: %s)' % graph_id)
-            log.exception("Failed to start release promotion for graph %s %s",
-                          graph_id, release)
+                'Failed to start release promotion (graph ID: %s). Error(s): %s' % (graph_id, exception)
+            )
+            log.exception('Failed to start release "%s" promotion for graph %s. Error(s): %s',
+                          release['name'], graph_id, exception)
+            log.debug('Release failed: %s', release)
 
     if rc != 0:
         sys.exit(rc)
 
     log.debug('Sleeping for %s seconds before polling again', sleeptime)
     time.sleep(sleeptime)
 
 if __name__ == '__main__':
--- a/lib/python/kickoff/__init__.py
+++ b/lib/python/kickoff/__init__.py
@@ -35,17 +35,25 @@ def long_revision(repo, revision):
     """
     url = "https://hg.mozilla.org/{}/json-rev/{}".format(repo, revision)
 
     def _get():
         req = requests.get(url, timeout=60)
         req.raise_for_status()
         return req.json()["node"]
 
-    return retry(_get)
+    try:
+        return retry(_get)
+    except HTTPError, error:
+        if error.response.status_code == 404:
+            raise NotFoundError(error)
+
+
+class NotFoundError(HTTPError):
+    pass
 
 
 class ReleaseRunner(object):
     def __init__(self, api_root=None, username=None, password=None,
                  timeout=60):
         self.new_releases = []
         self.releases_api = Releases((username, password), api_root=api_root,
                                      timeout=timeout)
@@ -57,29 +65,37 @@ class ReleaseRunner(object):
     def get_release_requests(self):
         new_releases = self.releases_api.getReleases()
         if new_releases['releases']:
             new_releases = [self.release_api.getRelease(name) for name in
                             new_releases['releases']]
             our_releases = [r for r in new_releases if
                             matches(r['name'], RELEASE_PATTERNS)]
             if our_releases:
-                # make sure to use long revision
                 for r in our_releases:
-                    r["mozillaRevision"] = long_revision(r["branch"], r["mozillaRevision"])
+                    self._assign_long_revision(r)
+
                 self.new_releases = our_releases
                 log.info("Releases to handle are %s", self.new_releases)
                 return True
             else:
                 log.info("No releases to handle in %s", new_releases)
                 return False
         else:
             log.info("No new releases: %s" % new_releases)
             return False
 
+    def _assign_long_revision(self, release):
+        revision = release['mozillaRevision']
+        branch = release['branch']
+        try:
+            release['mozillaRevision'] = long_revision(branch, revision)
+        except NotFoundError:
+            self.mark_as_failed(r, 'Revision "%s" does not exist in branch "%s"' % (revision, branch))
+
     def get_release_l10n(self, release):
         return self.release_l10n_api.getL10n(release)
 
     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: