Retry image create job if networking inside mic-appliance faild.
authorhyokeun <hyokeun.jeon@samsung.com>
Tue, 7 Aug 2018 02:33:43 +0000 (11:33 +0900)
committerYonghee Han <onstudy@samsung.com>
Thu, 31 Jan 2019 01:21:23 +0000 (10:21 +0900)
Problem: Sometimes PYCURL ERROR 7 happened.
Workaround: Catch error string and retry the job.

Change-Id: I1a504419351f2eb431a266a4356854eb8cd01980

job_imager.py

index 34fd693..33071eb 100755 (executable)
@@ -250,6 +250,23 @@ def run_inside_sign_vm(vm_image, vm_memory, vm_cpus, basedir):
     except IOError:
         return -1
 
+def vm_healty_check(output_directory=None):
+    retry_count = int(os.getenv('MIC_APPLIANCE_RETRY_COUNT')) + 1
+    if retry_count > 3:
+        return
+    sys.stdout.flush()
+    for fname in os.listdir(output_directory):
+        if fname.endswith('.log'):
+            with open(os.path.join(output_directory, fname), 'r') as lg:
+                for ln in lg.read().splitlines():
+                    if 'PYCURL ERROR 7' in ln and '/repomd.xml' in ln:
+                        trigger_next('image_creator_retry',
+                                     data=trigger_info(os.getenv('TRIGGER_INFO')),
+                                     show=False,
+                                     extra_params={'MIC_APPLIANCE_RETRY_COUNT': str(retry_count)})
+                        print 'VM NETWORKING DISABLED... RETRY %s.' % str(retry_count)
+                        sys.exit(3)
+
 def main():
     """The main body"""
 
@@ -380,6 +397,9 @@ def main():
         except Exception as err:
             print 'LOGCPERROR: %s' % err
 
+    if os.getenv('USE_VM', '0') != '0':
+        vm_healty_check(output_directory=os.path.join(sync_src, 'images', fields['repo'], name))
+
     sync_status = 'success'
 
     for loop in range(2):
@@ -485,4 +505,3 @@ def main():
 
 if __name__ == "__main__":
     sys.exit(main())
-