From: hyokeun Date: Wed, 27 Jun 2018 10:36:30 +0000 (+0900) Subject: Set timeout for mic command X-Git-Tag: submit/trunk/20190927.012743~55 X-Git-Url: http://review.tizen.org/git/?a=commitdiff_plain;h=5de4093f4f50e63140d6dbee06df5cf7fcb356fc;p=services%2Fjenkins-scripts.git Set timeout for mic command Change-Id: I16b4eb98e218a0e52c5cd80c800943f270bd4c40 --- diff --git a/job_imager.py b/job_imager.py index 05ff7a9..34fd693 100755 --- a/job_imager.py +++ b/job_imager.py @@ -200,6 +200,16 @@ def run_inside_vm(vm_image, vm_memory, vm_cpus, basedir): except IOError: return -1 +def get_timeout_cmd(): + timeout_cmd = '' + if os.getenv('JOB_TIMEOUT_IN_MILLISECONDS'): + #TODO: Save 5 minutes gard time. + timeout_val = int(os.getenv('JOB_TIMEOUT_IN_MILLISECONDS'))/1000 - 300 + if timeout_val <= 300: + timeout_val = 300 + timeout_cmd = 'timeout %s ' % str(timeout_val) + return timeout_cmd + def run_inside_sign_vm(vm_image, vm_memory, vm_cpus, basedir): """ Run mic inside VM @@ -217,12 +227,14 @@ def run_inside_sign_vm(vm_image, vm_memory, vm_cpus, basedir): user = "net=%s,host=%s,dhcpstart=%s" %(os.getenv('SIGN_VM_USER_NET'), \ os.getenv('SIGN_VM_USER_HOST'), \ os.getenv('SIGN_VM_USER_DHCPSTART')) - cmd = 'qemu-system-x86_64 -machine accel=kvm:xen:tcg -name '\ + cmd = '%s qemu-system-x86_64 -machine accel=kvm:xen:tcg -name '\ 'opensuse -M pc -m %d -smp %d -vga none -drive file=%s,'\ 'snapshot=on -nographic -virtfs local,id=test_dev,'\ 'path=%s,security_model=mapped,mount_tag=share '\ + '-virtfs local,id=test_sign,path=/var/lib/jenkins/.sign/,'\ + 'security_model=mapped,mount_tag=sign '\ '-net nic,macaddr=%s -net user,%s' % \ - (vm_memory, vm_cpus, vm_image, basedir, mac_address, user) + (get_timeout_cmd(), vm_memory, vm_cpus, vm_image, basedir, mac_address, user) print "cmd=%s" %(cmd) sys.stdout.flush() subprocess.call(cmd, stdout=sys.stdout, @@ -240,8 +252,8 @@ def run_inside_sign_vm(vm_image, vm_memory, vm_cpus, basedir): def main(): """The main body""" + buildmonitor_enabled = os.getenv("BUILDMONITOR_ENABLED", "0") != "0" - print 'buildmonitor_enabled(%s)\n' % (buildmonitor_enabled) if buildmonitor_enabled: bm_start_datetime = datetime.datetime.now() @@ -325,11 +337,11 @@ def main(): if os.getenv('MIC_WORK_DIR') and os.getenv('MIC_CONF_FILE'): mic_conf_file = os.getenv('MIC_CONF_FILE') print 'Set mic conf file: %s' % mic_conf_file - mic_cmd = "sudo /usr/bin/mic cr auto -c %s %s --release %s -o %s -k %s "\ - '--logfile=%s' % (mic_conf_file, ksf, build_id, outdir, cache, log) + mic_cmd = "sudo %s /usr/bin/mic cr auto -c %s %s --release %s -o %s -k %s "\ + '--logfile=%s' % (get_timeout_cmd(), mic_conf_file, ksf, build_id, outdir, cache, log) else: - mic_cmd = "sudo /usr/bin/mic cr auto %s --release %s -o %s -k %s "\ - '--logfile=%s' % (ksf, build_id, outdir, cache, log) + mic_cmd = "sudo %s /usr/bin/mic cr auto %s --release %s -o %s -k %s "\ + '--logfile=%s' % (get_timeout_cmd(), ksf, build_id, outdir, cache, log) sys.stdout.flush() print 'starting mic to create image: %s' % mic_cmd @@ -473,3 +485,4 @@ def main(): if __name__ == "__main__": sys.exit(main()) +