TPE-167 Bugfix: Retry failed prerelease creation 09/143909/1
authorhyokeun <hyokeun.jeon@samsung.com>
Mon, 14 Aug 2017 01:26:38 +0000 (10:26 +0900)
committerhyokeun <hyokeun.jeon@samsung.com>
Mon, 14 Aug 2017 01:26:41 +0000 (10:26 +0900)
Retry routine was missing when submit job merge.

Change-Id: Ib49c57523d9711ffe1ce418c50dc923758eae165

job_submit.py

index 9be7a47..012c04e 100644 (file)
@@ -148,7 +148,6 @@ def enqueue_request(url, gerrit_project, git_tag, gerrit_newrev,
     print 'QUEUED... %s\n' % enqueue_item
 
 def process_requests(build, request_q):
-    fail_count = 0
 
     for x in request_q['requests']:
         args = x[x.keys()[0]]
@@ -158,14 +157,16 @@ def process_requests(build, request_q):
                 a['url'] = request_q['url']
                 a['obs_target_prj'] = request_q['obs_target_prj']
         retry_count = 3
-        while retry_count > 0:
-            create_project(build, x.keys()[0], args, mode=request_q['reason'])
-            break
-        if not retry_count:
-            print 'retrying failed'
-            fail_count += 1
-
-    return fail_count
+        while retry_count >= 0:
+            try:
+                create_project(build, x.keys()[0], args, mode=request_q['reason'])
+                break
+            except Exception as err:
+                print 'create_project error: %s' % repr(err)
+                retry_count -= 1
+    if retry_count < 0:
+        return -1
+    return 0
 
 def entry(option):
     print option
@@ -187,8 +188,7 @@ def entry(option):
     # Split obs creation job
     if len(option) > 2 and option[2] == 'request':
         content = trigger_info(os.getenv('TRIGGER_INFO'))
-        process_requests(build, content)
-        return
+        return process_requests(build, content)
 
     # First store current build and all the rest queued builds
     build_queue = []