From 08705345d64bdf022b91f00cc902eaacd3aabb34 Mon Sep 17 00:00:00 2001 From: Simon Sapin Date: Tue, 5 Nov 2019 11:46:17 +0100 Subject: [PATCH 1/4] Always construct TC API URLs from $TASKCLUSTER_PROXY_URL or $TASKCLUSTER_ROOT_URL --- etc/ci/update-wpt-checkout | 2 +- etc/taskcluster/decision_task.py | 3 ++- etc/taskcluster/decisionlib.py | 18 ++++++++++-------- etc/taskcluster/mock.py | 1 + python/servo/package_commands.py | 2 +- 5 files changed, 15 insertions(+), 11 deletions(-) diff --git a/etc/ci/update-wpt-checkout b/etc/ci/update-wpt-checkout index 1ab4b62ec64..5f8ef9d1a15 100755 --- a/etc/ci/update-wpt-checkout +++ b/etc/ci/update-wpt-checkout @@ -100,7 +100,7 @@ function unsafe_open_pull_request() { git checkout "${BRANCH_NAME}" || return 0 if [[ -z "${WPT_SYNC_TOKEN+set}" && "${TASKCLUSTER_PROXY_URL+set}" == "set" ]]; then - SECRET_RESPONSE=$(curl ${TASKCLUSTER_PROXY_URL}/secrets/v1/secret/project/servo/wpt-sync) + SECRET_RESPONSE=$(curl ${TASKCLUSTER_PROXY_URL}/api/secrets/v1/secret/project/servo/wpt-sync) WPT_SYNC_TOKEN=`echo "${SECRET_RESPONSE}" | jq --raw-output '.secret.token'` fi diff --git a/etc/taskcluster/decision_task.py b/etc/taskcluster/decision_task.py index 358e1af0b3b..6673a89b6ce 100644 --- a/etc/taskcluster/decision_task.py +++ b/etc/taskcluster/decision_task.py @@ -238,7 +238,8 @@ def upload_docs(): .with_scopes("secrets:get:project/servo/doc.servo.org") .with_env(PY="""if 1: import urllib, json - url = "http://taskcluster/secrets/v1/secret/project/servo/doc.servo.org" + root_url = os.environ["TASKCLUSTER_PROXY_URL"] + url = root_url + "/api/secrets/v1/secret/project/servo/doc.servo.org" token = json.load(urllib.urlopen(url))["secret"]["token"] open("/root/.git-credentials", "w").write("https://git:%s@github.com/" % token) """) diff --git a/etc/taskcluster/decisionlib.py b/etc/taskcluster/decisionlib.py index 0436612dafa..6b9d69f89d4 100644 --- a/etc/taskcluster/decisionlib.py +++ b/etc/taskcluster/decisionlib.py @@ -57,8 +57,8 @@ class Config: self.git_ref = os.environ.get("GIT_REF") self.git_sha = os.environ.get("GIT_SHA") - root_url = os.environ.get("TASKCLUSTER_ROOT_URL") - self.legacy_tc_deployment = root_url == "https://taskcluster.net" + self.tc_root_url = os.environ.get("TASKCLUSTER_ROOT_URL") + self.legacy_tc_deployment = self.tc_root_url == "https://taskcluster.net" if self.legacy_tc_deployment: self.default_provisioner_id = "aws-provisioner-v1" @@ -99,10 +99,9 @@ class Shared: self.now = datetime.datetime.utcnow() self.found_or_created_indexed_tasks = {} - # taskclusterProxy URLs: - # https://docs.taskcluster.net/docs/reference/workers/docker-worker/docs/features - self.queue_service = taskcluster.Queue(options={"baseUrl": "http://taskcluster/queue/v1/"}) - self.index_service = taskcluster.Index(options={"baseUrl": "http://taskcluster/index/v1/"}) + options = {"rootUrl": os.environ["TASKCLUSTER_PROXY_URL"]} + self.queue_service = taskcluster.Queue(options) + self.index_service = taskcluster.Index(options) def from_now_json(self, offset): """ @@ -621,11 +620,14 @@ class UnixTaskMixin(Task): """.format(n=n)) def with_curl_artifact_script(self, task_id, artifact_name, out_directory=""): + if CONFIG.legacy_tc_deployment: + queue_service = "https://queue.taskcluster.net" + else: # pragma: no cover + queue_service = CONFIG.tc_root_url + "/api/queue" return self \ .with_dependencies(task_id) \ .with_curl_script( - "https://queue.taskcluster.net/v1/task/%s/artifacts/public/%s" - % (task_id, artifact_name), + queue_service + "/v1/task/%s/artifacts/public/%s" % (task_id, artifact_name), os.path.join(out_directory, url_basename(artifact_name)), ) diff --git a/etc/taskcluster/mock.py b/etc/taskcluster/mock.py index 10fe23b22a1..c0b45e6a1f4 100755 --- a/etc/taskcluster/mock.py +++ b/etc/taskcluster/mock.py @@ -45,6 +45,7 @@ sys.dont_write_bytecode = True os.environ.update(**{k: k for k in "TASK_ID TASK_OWNER TASK_SOURCE GIT_URL GIT_SHA".split()}) os.environ["GIT_REF"] = "refs/heads/auto" os.environ["TASKCLUSTER_ROOT_URL"] = "https://taskcluster.net" +os.environ["TASKCLUSTER_PROXY_URL"] = "http://taskcluster" import decision_task print("\n# Push:") diff --git a/python/servo/package_commands.py b/python/servo/package_commands.py index 40bbd61b92c..a663763a398 100644 --- a/python/servo/package_commands.py +++ b/python/servo/package_commands.py @@ -591,7 +591,7 @@ class PackageCommands(CommandBase): def get_taskcluster_secret(name): url = ( os.environ.get("TASKCLUSTER_PROXY_URL", "http://taskcluster") + - "/secrets/v1/secret/project/servo/" + + "/api/secrets/v1/secret/project/servo/" + name ) return json.load(urllib.request.urlopen(url))["secret"] From 7cf489c1f86d4f39838ec56e84920fbcdb2ae7e0 Mon Sep 17 00:00:00 2001 From: Simon Sapin Date: Tue, 5 Nov 2019 12:38:03 +0100 Subject: [PATCH 2/4] =?UTF-8?q?Don=E2=80=99t=20fail=20tasks=20if=20a=20bra?= =?UTF-8?q?nch=20was=20fast-forward-pushed=20since=20the=20triggering=20pu?= =?UTF-8?q?sh=20event?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- etc/taskcluster/decisionlib.py | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/etc/taskcluster/decisionlib.py b/etc/taskcluster/decisionlib.py index 6b9d69f89d4..685634d94e5 100644 --- a/etc/taskcluster/decisionlib.py +++ b/etc/taskcluster/decisionlib.py @@ -482,7 +482,7 @@ class WindowsGenericWorkerTask(GenericWorkerTask): git += """ git fetch {depth} %GIT_URL% %GIT_REF% git reset --hard %GIT_SHA% - """.format(depth="--depth 1" if shallow else "") + """.format(depth="--depth 100" if shallow else "") return self \ .with_git() \ .with_script(git) \ @@ -604,7 +604,7 @@ class UnixTaskMixin(Task): cd repo git fetch {depth} "$GIT_URL" "$GIT_REF" git reset --hard "$GIT_SHA" - """.format(depth="--depth 1" if shallow else "")) + """.format(depth="--depth 100" if shallow else "")) def with_curl_script(self, url, file_path): self.curl_scripts_count += 1 From 694e38e163cb023f372bf13480257b5703c216bc Mon Sep 17 00:00:00 2001 From: Simon Sapin Date: Tue, 5 Nov 2019 13:10:03 +0100 Subject: [PATCH 3/4] =?UTF-8?q?Update=20the=20decision=20task=E2=80=99s=20?= =?UTF-8?q?Docker=20image?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit https://github.com/servo/taskcluster-bootstrap-docker-images/compare/47b7864da...5a2588ef1 --- .taskcluster.yml | 3 ++- etc/taskcluster/decisionlib.py | 2 +- 2 files changed, 3 insertions(+), 2 deletions(-) diff --git a/.taskcluster.yml b/.taskcluster.yml index 1aba72b9aa6..7eebe65eec3 100644 --- a/.taskcluster.yml +++ b/.taskcluster.yml @@ -22,7 +22,8 @@ tasks: payload: maxRunTime: {$eval: '20 * 60'} # https://github.com/servo/taskcluster-bootstrap-docker-images#decision-task - image: "servobrowser/taskcluster-bootstrap:decision-task@sha256:28045b7ec0485ef363f8cb14f194008b47e9ede99f2ea40a1e945e921fce976e" + image: "servobrowser/taskcluster-bootstrap:decision-task@\ + sha256:7471a998e4462638c8d3e2cf0b4a99c9a5c8ca9f2ec0ae01cc069473b35cde10" features: taskclusterProxy: true env: diff --git a/etc/taskcluster/decisionlib.py b/etc/taskcluster/decisionlib.py index 685634d94e5..976e5cd99d2 100644 --- a/etc/taskcluster/decisionlib.py +++ b/etc/taskcluster/decisionlib.py @@ -255,7 +255,7 @@ class Task: extra=self.extra, ) - task_id = taskcluster.slugId().decode("utf8") + task_id = taskcluster.slugId() SHARED.queue_service.createTask(task_id, queue_payload) print("Scheduled %s: %s" % (task_id, self.name)) return task_id From 6125fe88c36c0181c07c5a4633132fdeb13563e1 Mon Sep 17 00:00:00 2001 From: Simon Sapin Date: Tue, 5 Nov 2019 17:06:48 +0100 Subject: [PATCH 4/4] Run a decision task on both deployments for push events --- .taskcluster.yml | 13 +------------ etc/taskcluster/decision_task.py | 4 ++++ 2 files changed, 5 insertions(+), 12 deletions(-) diff --git a/.taskcluster.yml b/.taskcluster.yml index 7eebe65eec3..0b427e1795d 100644 --- a/.taskcluster.yml +++ b/.taskcluster.yml @@ -48,18 +48,7 @@ tasks: $if: "event.ref[:11] == 'refs/heads/'" then: "${event.ref[11:]}" in: - $if: >- - ( - taskcluster_root_url == 'https://community-tc.services.mozilla.com' && - branch == 'try-communitytc' - ) || ( - taskcluster_root_url == 'https://taskcluster.net' && - branch != 'try-communitytc' && - ( - branch in ['auto', 'try', 'master'] || - branch[:4] == 'try-' - ) - ) + $if: "branch in ['auto', 'try', 'master'] || branch[:4] == 'try-'" then: $mergeDeep: - {$eval: "task_common"} diff --git a/etc/taskcluster/decision_task.py b/etc/taskcluster/decision_task.py index 6673a89b6ce..148ee81cc0c 100644 --- a/etc/taskcluster/decision_task.py +++ b/etc/taskcluster/decision_task.py @@ -24,6 +24,10 @@ def main(task_for): magicleap_nightly = lambda: None if task_for == "github-push": + if not CONFIG.legacy_tc_deployment: # pragma: no cover + # Do nothing (other than the decision task itsef) on community-tc by default for now + return + # FIXME https://github.com/servo/servo/issues/22187 # In-emulator testing is disabled for now. (Instead we only compile.) # This local variable shadows the module-level function of the same name.