Catch HTTPError:bad request for submit_req
authorZhuoX Li <zhuox.li@intel.com>
Mon, 24 Mar 2014 07:55:04 +0000 (15:55 +0800)
committerZhuoX Li <zhuox.li@intel.com>
Mon, 24 Mar 2014 08:56:10 +0000 (16:56 +0800)
After upload _service, if catches 'Bad Request',
Obs service should enough time to execute.

Change-Id: Ib52d1439ea3969d3f0d2021d4f8f12e86e32f5f9

job_submitobs.py

index 4b79924..da16206 100755 (executable)
@@ -12,6 +12,7 @@ import re
 import atexit
 import ast
 from time import sleep
+from urllib2 import HTTPError
 
 # internal module
 from common import runner
@@ -508,20 +509,22 @@ def main():
                 # create SR
                 status = True
                 if obs_stg_prj != obs_dst_prj:
-                    sr_retry_count = 3
+                    sr_retry_count = 10
                     while sr_retry_count > 0:
                         try:
-                            sleep(6)
+                            sleep(30)
                             newreq = localpkg.submit_req(obs_dst_prj,
                                                     msg=commit_msg)
                             print 'New request %s is created' % newreq
                             status = True
                             break
-                        except Exception, err:
+                        except HTTPError, err:
                             print 'New request failed to be created'
                             print err
-                            sr_retry_count -= 1
                             status = False
+                            if err.msg != "Bad Request":
+                                break
+                            sr_retry_count -= 1
                 if status:
                     break
                 retry_count -= 1