From cab30ba295faa24ef80e8dfd56c6bf3dd48c9b5c Mon Sep 17 00:00:00 2001 From: hyokeun Date: Tue, 7 Aug 2018 11:33:43 +0900 Subject: [PATCH] Retry image create job if networking inside mic-appliance faild. Problem: Sometimes PYCURL ERROR 7 happened. Workaround: Catch error string and retry the job. Change-Id: I1a504419351f2eb431a266a4356854eb8cd01980 --- job_imager.py | 21 ++++++++++++++++++++- 1 file changed, 20 insertions(+), 1 deletion(-) diff --git a/job_imager.py b/job_imager.py index 34fd693..33071eb 100755 --- a/job_imager.py +++ b/job_imager.py @@ -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()) - -- 2.7.4