Guest User

Untitled

a guest
Oct 20th, 2017
89
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 6.65 KB | None | 0 0
  1. diff --git a/buildfarm/release/release-runner3.py b/buildfarm/release/release-runner3.py
  2. --- a/buildfarm/release/release-runner3.py
  3. +++ b/buildfarm/release/release-runner3.py
  4. @@ -1,14 +1,15 @@
  5. #!/usr/bin/env python
  6. """
  7. Release runner to schedule action tasks (in-tree scheduling)
  8. """
  9.  
  10. import argparse
  11. +import copy
  12. import logging
  13. import os
  14. import re
  15. import site
  16. import sys
  17. import taskcluster
  18. import time
  19. import yaml
  20. @@ -109,17 +110,16 @@ def main(options):
  21. rr = ReleaseRunner(api_root=api_root, username=username, password=password)
  22. tc_config = {
  23. "credentials": {
  24. "clientId": config["taskcluster"].get("client_id"),
  25. "accessToken": config["taskcluster"].get("access_token"),
  26. },
  27. "maxRetries": 12,
  28. }
  29. - queue = taskcluster.Queue(tc_config)
  30.  
  31. while True:
  32. try:
  33. log.debug('Fetching release requests')
  34. rr.get_release_requests([r['pattern'] for r in config['releases']])
  35. if rr.new_releases:
  36. new_releases = run_prebuild_sanity_checks(
  37. rr, config['releases'])
  38. @@ -131,23 +131,26 @@ def main(options):
  39. except:
  40. log.error("Caught exception when polling:", exc_info=True)
  41. sys.exit(5)
  42.  
  43. rc = 0
  44. for release in new_releases:
  45. try:
  46. next_version = bump_version(release["version"].replace("esr", ""))
  47. - action_task_id, action_task = generate_action_task(
  48. + action_task_id, action_task, scopes = generate_action_task(
  49. project=release["branchShortName"],
  50. revision=release["mozillaRevision"],
  51. next_version=next_version,
  52. build_number=release["buildNumber"],
  53. release_promotion_flavor="promote_{}".format(release["product"])
  54. )
  55. + options = copy.deepcopy(tc_config)
  56. + options["authorizedScopes"] = scopes
  57. + queue = taskcluster.Queue(tc_config)
  58. submit_action_task(queue=queue, action_task_id=action_task_id,
  59. action_task=action_task)
  60. rr.mark_as_completed(release)
  61. l10n_url = rr.release_l10n_api.getL10nFullUrl(release['name'])
  62. email_release_drivers(smtp_server=smtp_server, from_=notify_from,
  63. to=notify_to, release=release,
  64. task_group_id=action_task_id, l10n_url=l10n_url)
  65. except Exception as exception:
  66. diff --git a/buildfarm/release/trigger_action.py b/buildfarm/release/trigger_action.py
  67. --- a/buildfarm/release/trigger_action.py
  68. +++ b/buildfarm/release/trigger_action.py
  69. @@ -30,36 +30,38 @@ def main():
  70. )
  71. parser.add_argument("--release-runner-config", required=True, type=argparse.FileType('r'),
  72. help="Release runner config")
  73. parser.add_argument("--action-flavor", required=True, choices=SUPPORTED_ACTIONS)
  74. parser.add_argument("--force", action="store_true", default=False,
  75. help="Submit action task without asking")
  76. args = parser.parse_args()
  77. release_runner_config = yaml.safe_load(args.release_runner_config)
  78. +
  79. + task = get_task(args.action_task_id)
  80. + action_input = task["extra"]["action"]["context"]["input"]
  81. + parameters = task["extra"]["action"]["context"]["parameters"]
  82. + action_task_id, action_task, scopes = generate_action_task(
  83. + project=parameters["project"],
  84. + revision=parameters["head_rev"],
  85. + next_version=action_input["next_version"],
  86. + build_number=action_input["build_number"],
  87. + release_promotion_flavor=args.action_flavor
  88. + )
  89. +
  90. tc_config = {
  91. "credentials": {
  92. "clientId": release_runner_config["taskcluster"].get("client_id"),
  93. "accessToken": release_runner_config["taskcluster"].get("access_token"),
  94. },
  95. "maxRetries": 12,
  96. + "authorizedScopes": scopes,
  97. }
  98. queue = taskcluster.Queue(tc_config)
  99.  
  100. - task = get_task(args.action_task_id)
  101. - action_input = task["extra"]["action"]["context"]["input"]
  102. - parameters = task["extra"]["action"]["context"]["parameters"]
  103. - action_task_id, action_task = generate_action_task(
  104. - project=parameters["project"],
  105. - revision=parameters["head_rev"],
  106. - next_version=action_input["next_version"],
  107. - build_number=action_input["build_number"],
  108. - release_promotion_flavor=args.action_flavor
  109. - )
  110. -
  111. log.info("Submitting action task %s for %s", action_task_id, args.action_flavor)
  112. log.info("Project: %s", parameters["project"])
  113. log.info("Revision: %s", parameters["head_rev"])
  114. log.info("Next version: %s", action_input["next_version"])
  115. log.info("Build number: %s", action_input["build_number"])
  116. log.info("Task definition:\n%s", json.dumps(action_task, sort_keys=True, indent=2))
  117. if not args.force:
  118. yes_no = raw_input("Submit the task? [y/N]: ")
  119. diff --git a/lib/python/kickoff/actions.py b/lib/python/kickoff/actions.py
  120. --- a/lib/python/kickoff/actions.py
  121. +++ b/lib/python/kickoff/actions.py
  122. @@ -24,16 +24,19 @@ def fetch_actions_json(task_id):
  123. return q.json()
  124.  
  125.  
  126. def generate_action_task(project, revision, next_version, build_number, release_promotion_flavor):
  127. decision_task_route = "gecko.v2.{project}.revision.{revision}.firefox.decision".format(
  128. project=project, revision=revision)
  129. index = taskcluster.Index()
  130. decision_task_id = index.findTask(decision_task_route)["taskId"]
  131. + queue = taskcluster.Queue()
  132. + decision_task = queue.task(decision_task_id)
  133. + decision_task_scopes = decision_task["scopes"]
  134. actions = fetch_actions_json(decision_task_id)
  135.  
  136. relpro = find_action("release-promotion", actions)
  137. context = copy.deepcopy(actions["variables"]) # parameters
  138. action_task_id = slugid.nice()
  139. context.update({
  140. "input": {
  141. "build_number": build_number,
  142. @@ -42,16 +45,16 @@ def generate_action_task(project, revisi
  143. },
  144. "ownTaskId": action_task_id,
  145. "taskId": None,
  146. "task": None,
  147. })
  148. action_task = jsone.render(relpro["task"], context)
  149. # override ACTION_TASK_GROUP_ID, so we know the new ID in advance
  150. action_task["payload"]["env"]["ACTION_TASK_GROUP_ID"] = action_task_id
  151. - return action_task_id, action_task
  152. + return action_task_id, action_task, decision_task_scopes
  153.  
  154.  
  155. def submit_action_task(queue, action_task_id, action_task):
  156. result = queue.createTask(action_task_id, action_task)
  157. log.info("Submitted action task %s", action_task_id)
  158. log.info("Action task:\n%s", action_task)
  159. log.info("Result:\n%s", result)
Add Comment
Please, Sign In to add comment