Bug 1473288 - Retry fetch {action,decision} task r=rail
authorJohan Lorenzo <jlorenzo@mozilla.com>
Fri, 06 Jul 2018 16:01:10 +0000
changeset 8445 1b273d683d4e
parent 8444 6e5999e94aae
child 8446 cadaac874297
push id6168
push userjlorenzo@mozilla.com
push dateThu, 19 Jul 2018 13:23:47 +0000
reviewersrail
bugs1473288
Bug 1473288 - Retry fetch {action,decision} task r=rail Retry fetch {action,decision} task Differential Revision: https://phabricator.services.mozilla.com/D2003
lib/python/kickoff/actions.py
--- a/lib/python/kickoff/actions.py
+++ b/lib/python/kickoff/actions.py
@@ -1,42 +1,53 @@
 import copy
 import json
 import jsone
 import logging
 import requests
 import slugid
 import taskcluster
 
+from util.retry import retry
+
 log = logging.getLogger(__name__)
 
 
 def find_action(name, actions):
     for action in actions["actions"]:
         if action["name"] == name:
             return copy.deepcopy(action)
     else:
         return None
 
 
 def fetch_actions_json(task_id):
     queue = taskcluster.Queue()
     actions_url = queue.buildUrl("getLatestArtifact", task_id, 'public/actions.json')
-    q = requests.get(actions_url)
-    q.raise_for_status()
-    return q.json()
+
+    def _get():
+        q = requests.get(actions_url)
+        q.raise_for_status()
+        return q.json()
+
+    return retry(_get)
+
 
 def find_decision_task_id(trust_domain, project, revision):
     decision_task_route = "{trust_domain}.v2.{project}.revision.{revision}.taskgraph.decision".format(
         trust_domain=trust_domain,
         project=project,
         revision=revision,
     )
     index = taskcluster.Index()
-    return index.findTask(decision_task_route)["taskId"]
+
+    def _get():
+        return index.findTask(decision_task_route)["taskId"]
+
+    return retry(_get)
 
 
 def generate_action_task(decision_task_id, action_task_input):
     actions = fetch_actions_json(decision_task_id)
     relpro = find_action("release-promotion", actions)
     context = copy.deepcopy(actions["variables"])  # parameters
     action_task_id = slugid.nice()
     context.update({