Bug 1455325 - Staging release: promotion task should contact staging balrog, instead of prod one r=bhearsum draft
authorJohan Lorenzo <jlorenzo@mozilla.com>
Thu, 19 Apr 2018 16:18:50 +0200
changeset 785069 7f8ef022d1e6b79bd1e39bbdd3225bbf400500b7
parent 784946 8ed49dd81059dfdd876cf62ad5def1cfa56ffbbf
push id107118
push userbmo:jlorenzo@mozilla.com
push dateThu, 19 Apr 2018 14:52:23 +0000
reviewersbhearsum
bugs1455325
milestone61.0a1
Bug 1455325 - Staging release: promotion task should contact staging balrog, instead of prod one r=bhearsum MozReview-Commit-ID: 8CLcuaJHixP
taskcluster/taskgraph/util/partials.py
--- a/taskcluster/taskgraph/util/partials.py
+++ b/taskcluster/taskgraph/util/partials.py
@@ -5,18 +5,16 @@
 from __future__ import absolute_import, print_function, unicode_literals
 
 import requests
 import redo
 
 import logging
 logger = logging.getLogger(__name__)
 
-BALROG_API_ROOT = 'https://aus5.mozilla.org/api/v1'
-
 PLATFORM_RENAMES = {
     'windows2012-32': 'win32',
     'windows2012-64': 'win64',
     'osx-cross': 'macosx64',
 }
 
 BALROG_PLATFORM_MAP = {
     "linux": [
@@ -125,41 +123,48 @@ def _retry_on_http_errors(url, verify, p
 
 
 def get_sorted_releases(product, branch):
     """Returns a list of release names from Balrog.
     :param product: product name, AKA appName
     :param branch: branch name, e.g. mozilla-central
     :return: a sorted list of release names, most recent first.
     """
-    url = "{}/releases".format(BALROG_API_ROOT)
+    url = "{}/releases".format(_get_balrog_api_root(branch))
     params = {
         "product": product,
         # Adding -nightly-2 (2 stands for the beginning of build ID
         # based on date) should filter out release and latest blobs.
         # This should be changed to -nightly-3 in 3000 ;)
         "name_prefix": "{}-{}-nightly-2".format(product, branch),
         "names_only": True
     }
     req = _retry_on_http_errors(
         url=url, verify=True, params=params,
         errors=[500])
     releases = req.json()["names"]
     releases = sorted(releases, reverse=True)
     return releases
 
 
-def get_release_builds(release):
-    url = "{}/releases/{}".format(BALROG_API_ROOT, release)
+def get_release_builds(release, branch):
+    url = "{}/releases/{}".format(_get_balrog_api_root(branch), release)
     req = _retry_on_http_errors(
         url=url, verify=True, params=None,
         errors=[500])
     return req.json()
 
 
+def _get_balrog_api_root(branch):
+    if branch in ('mozilla-central', 'mozilla-beta', 'mozilla-release') or 'mozilla-esr' in branch:
+        return 'https://aus5.mozilla.org/api/v1'
+    else:
+        return 'https://aus5.stage.mozaws.net/api/v1'
+
+
 def find_localtest(fileUrls):
     for channel in fileUrls:
         if "-localtest" in channel:
             return channel
 
 
 def populate_release_history(product, branch, maxbuilds=4, maxsearch=10,
                              partial_updates=None):
@@ -209,17 +214,17 @@ def _populate_nightly_history(product, b
     builds = dict()
     for release in last_releases[:maxsearch]:
         # maxbuilds in all categories, don't make any more queries
         full = len(builds) > 0 and all(
             len(builds[platform][locale]) >= maxbuilds
             for platform in builds for locale in builds[platform])
         if full:
             break
-        history = get_release_builds(release)
+        history = get_release_builds(release, branch)
 
         for platform in history['platforms']:
             if 'alias' in history['platforms'][platform]:
                 continue
             if platform not in builds:
                 builds[platform] = dict()
             for locale in history['platforms'][platform]['locales']:
                 if locale not in builds[platform]:
@@ -238,17 +243,17 @@ def _populate_nightly_history(product, b
 
 def _populate_release_history(product, branch, partial_updates):
     builds = dict()
     for version, release in partial_updates.iteritems():
         prev_release_blob = '{product}-{version}-build{build_number}'.format(
             product=product, version=version, build_number=release['buildNumber']
         )
         partial_mar_key = 'target-{version}.partial.mar'.format(version=version)
-        history = get_release_builds(prev_release_blob)
+        history = get_release_builds(prev_release_blob, branch)
         # use one of the localtest channels to avoid relying on bouncer
         localtest = find_localtest(history['fileUrls'])
         url_pattern = history['fileUrls'][localtest]['completes']['*']
 
         for platform in history['platforms']:
             if 'alias' in history['platforms'][platform]:
                 continue
             if platform not in builds: