Bug 1256063 - Add update bouncer aliases builder. r=rail a=release DONTBUILD
authorMihai Tabara <mtabara@mozilla.com>
Thu, 24 Mar 2016 14:43:34 +0000
changeset 323623 7be13fe2f509a824b4983f93d1228a4cf643e7a9
parent 323622 30de9ac21a783228a1bb6b3d5920050824cbc58f
child 323624 809b0f59b556235fbf7c51a4f3c45783bc68c347
push id5913
push userjlund@mozilla.com
push dateMon, 25 Apr 2016 16:57:49 +0000
treeherdermozilla-beta@dcaf0a6fa115 [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewersrail, release
bugs1256063
milestone47.0a2
Bug 1256063 - Add update bouncer aliases builder. r=rail a=release DONTBUILD MozReview-Commit-ID: IdUXP3b2MOp
testing/mozharness/configs/releases/bouncer_fennec.py
testing/mozharness/configs/releases/bouncer_firefox_beta.py
testing/mozharness/configs/releases/bouncer_firefox_esr.py
testing/mozharness/configs/releases/bouncer_firefox_release.py
testing/mozharness/configs/releases/bouncer_thunderbird.py
testing/mozharness/scripts/release/postrelease_bouncer_aliases.py
--- a/testing/mozharness/configs/releases/bouncer_fennec.py
+++ b/testing/mozharness/configs/releases/bouncer_fennec.py
@@ -1,13 +1,14 @@
 # lint_ignore=E501
 config = {
     "products": {
         "apk": {
             "product-name": "Fennec-%(version)s",
+            "alias": "fennec-latest",
             "ssl-only": False,
             "add-locales": False,  # Do not add locales to let "multi" work
             "paths": {
                 "android-api-15": {
                     "path": "/mobile/releases/%(version)s/android-api-15/:lang/fennec-%(version)s.:lang.android-arm.apk",
                     "bouncer-platform": "android",
                 },
                 "android-api-9": {
--- a/testing/mozharness/configs/releases/bouncer_firefox_beta.py
+++ b/testing/mozharness/configs/releases/bouncer_firefox_beta.py
@@ -1,14 +1,15 @@
 # lint_ignore=E501
 config = {
     "shipped-locales-url": "https://hg.mozilla.org/%(repo)s/raw-file/%(revision)s/browser/locales/shipped-locales",
     "products": {
         "installer": {
             "product-name": "Firefox-%(version)s",
+            "alias": "firefox-beta-latest",
             "ssl-only": False,
             "add-locales": True,
             "paths": {
                 "linux": {
                     "path": "/firefox/releases/%(version)s/linux-i686/:lang/firefox-%(version)s.tar.bz2",
                     "bouncer-platform": "linux",
                 },
                 "linux64": {
@@ -53,16 +54,17 @@ config = {
                 "win64": {
                     "path": "/firefox/releases/%(version)s/win64/:lang/Firefox%%20Setup%%20%(version)s.exe",
                     "bouncer-platform": "win64",
                 },
             },
         },
         "stub-installer": {
             "product-name": "Firefox-%(version)s-stub",
+            "alias": "firefox-beta-stub",
             "ssl-only": True,
             "add-locales": True,
             "paths": {
                 "win32": {
                     "path": "/firefox/releases/%(version)s/win32/:lang/Firefox%%20Setup%%20Stub%%20%(version)s.exe",
                     "bouncer-platform": "win",
                 },
                 "win64": {
--- a/testing/mozharness/configs/releases/bouncer_firefox_esr.py
+++ b/testing/mozharness/configs/releases/bouncer_firefox_esr.py
@@ -1,14 +1,15 @@
 # lint_ignore=E501
 config = {
     "shipped-locales-url": "https://hg.mozilla.org/%(repo)s/raw-file/%(revision)s/browser/locales/shipped-locales",
     "products": {
         "installer": {
             "product-name": "Firefox-%(version)s",
+            "alias": "firefox-esr-latest",
             "ssl-only": True,
             "add-locales": True,
             "paths": {
                 "linux": {
                     "path": "/firefox/releases/%(version)s/linux-i686/:lang/firefox-%(version)s.tar.bz2",
                     "bouncer-platform": "linux",
                 },
                 "linux64": {
--- a/testing/mozharness/configs/releases/bouncer_firefox_release.py
+++ b/testing/mozharness/configs/releases/bouncer_firefox_release.py
@@ -1,14 +1,15 @@
 # lint_ignore=E501
 config = {
     "shipped-locales-url": "https://hg.mozilla.org/%(repo)s/raw-file/%(revision)s/browser/locales/shipped-locales",
     "products": {
         "installer": {
             "product-name": "Firefox-%(version)s",
+            "alias": "firefox-latest",
             "ssl-only": False,
             "add-locales": True,
             "paths": {
                 "linux": {
                     "path": "/firefox/releases/%(version)s/linux-i686/:lang/firefox-%(version)s.tar.bz2",
                     "bouncer-platform": "linux",
                 },
                 "linux64": {
@@ -85,16 +86,17 @@ config = {
                 "solaris-sparc": {
                     "path": "/firefox/releases/%(version)s/contrib/solaris_tarball/firefox-%(version)s.en-US.solaris-sparc.tar.bz2",
                     "bouncer-platform": "solaris-sparc",
                 },
             },
         },
         "stub-installer": {
             "product-name": "Firefox-%(version)s-stub",
+            "alias": "firefox-stub",
             "ssl-only": True,
             "add-locales": True,
             "paths": {
                 "win32": {
                     "path": "/firefox/releases/%(version)s/win32/:lang/Firefox%%20Setup%%20Stub%%20%(version)s.exe",
                     "bouncer-platform": "win",
                 },
                 "win64": {
--- a/testing/mozharness/configs/releases/bouncer_thunderbird.py
+++ b/testing/mozharness/configs/releases/bouncer_thunderbird.py
@@ -1,14 +1,15 @@
 # lint_ignore=E501
 config = {
     "shipped-locales-url": "https://hg.mozilla.org/%(repo)s/raw-file/%(revision)s/mail/locales/shipped-locales",
     "products": {
         "installer": {
             "product-name": "Thunderbird-%(version)s",
+            "alias": "thunderbird-latest",
             "ssl-only": False,
             "add-locales": True,
             "paths": {
                 "linux": {
                     "path": "/thunderbird/releases/%(version)s/linux-i686/:lang/thunderbird-%(version)s.tar.bz2",
                     "bouncer-platform": "linux",
                 },
                 "linux64": {
new file mode 100644
--- /dev/null
+++ b/testing/mozharness/scripts/release/postrelease_bouncer_aliases.py
@@ -0,0 +1,107 @@
+#!/usr/bin/env python
+# lint_ignore=E501
+# ***** BEGIN LICENSE BLOCK *****
+# This Source Code Form is subject to the terms of the Mozilla Public
+# License, v. 2.0. If a copy of the MPL was not distributed with this file,
+# You can obtain one at http://mozilla.org/MPL/2.0/.
+# ***** END LICENSE BLOCK *****
+""" postrelease_bouncer_aliases.py
+
+A script to replace the old-fashion way of updating the bouncer aliaes through
+tools script.
+"""
+
+import os
+import sys
+
+sys.path.insert(1, os.path.dirname(os.path.dirname(sys.path[0])))
+
+from mozharness.base.python import VirtualenvMixin, virtualenv_config_options
+from mozharness.base.script import BaseScript
+from mozharness.mozilla.buildbot import BuildbotMixin
+
+
+# PostReleaseBouncerAliases {{{1
+class PostReleaseBouncerAliases(BaseScript, VirtualenvMixin, BuildbotMixin):
+    config_options = virtualenv_config_options
+
+    def __init__(self, require_config_file=True):
+        super(PostReleaseBouncerAliases, self).__init__(
+            config_options=self.config_options,
+            require_config_file=require_config_file,
+            config={
+                "virtualenv_modules": [
+                    "redo",
+                    "requests",
+                ],
+                "virtualenv_path": "venv",
+                'credentials_file': 'oauth.txt',
+                'buildbot_json_path': 'buildprops.json',
+            },
+            all_actions=[
+                "create-virtualenv",
+                "activate-virtualenv",
+                "update-bouncer-aliases",
+            ],
+            default_actions=[
+                "create-virtualenv",
+                "activate-virtualenv",
+                "update-bouncer-aliases",
+            ],
+        )
+
+    def _pre_config_lock(self, rw_config):
+        super(PostReleaseBouncerAliases, self)._pre_config_lock(rw_config)
+        # override properties from buildbot properties here as defined by
+        # taskcluster properties
+        self.read_buildbot_config()
+        if not self.buildbot_config:
+            self.warning("Skipping buildbot properties overrides")
+            return
+        props = self.buildbot_config["properties"]
+        for prop in ['tuxedo_server_url', 'version']:
+            if props.get(prop):
+                self.info("Overriding %s with %s" % (prop, props[prop]))
+                self.config[prop] = props.get(prop)
+            else:
+                self.warning("%s could not be found within buildprops" % prop)
+                return
+
+    def _update_bouncer_alias(self, tuxedo_server_url, auth,
+                              related_product, alias):
+        from redo import retry
+        import requests
+
+        url = "%s/create_update_alias" % tuxedo_server_url
+        data = {"alias": alias, "related_product": related_product}
+        self.log("Updating {} to point to {} using {}".format(alias,
+                                                              related_product,
+                                                              url))
+
+        # Wrap the real call to hide credentials from retry's logging
+        def do_update_bouncer_alias():
+            r = requests.post(url, data=data, auth=auth,
+                              verify=False, timeout=60)
+            r.raise_for_status()
+
+        retry(do_update_bouncer_alias)
+
+    def update_bouncer_aliases(self):
+        tuxedo_server_url = self.config['tuxedo_server_url']
+        credentials_file = os.path.join(os.getcwd(),
+                                        self.config['credentials_file'])
+        credentials = {}
+        execfile(credentials_file, credentials)
+        auth = (credentials['tuxedoUsername'], credentials['tuxedoPassword'])
+        version = self.config['version']
+        for product, info in self.config["products"].iteritems():
+            if "alias" in info:
+                product_template = info["product-name"]
+                related_product = product_template % {"version": version}
+                self._update_bouncer_alias(tuxedo_server_url, auth,
+                                           related_product, info["alias"])
+
+
+# __main__ {{{1
+if __name__ == '__main__':
+    PostReleaseBouncerAliases().run_and_exit()