Add postscripts-maxruntime option to set the max run time for post scripts 11/270711/5
authorbiao716.wang <biao716.wang@samsung.com>
Tue, 8 Feb 2022 03:47:40 +0000 (12:47 +0900)
committerbiao716.wang <biao716.wang@samsung.com>
Tue, 8 Feb 2022 08:10:34 +0000 (17:10 +0900)
example: sudo mic create auto test.ks --postscripts-maxruntime=500
mean the max run time for post scripts is 500 minutes.
without this option, default max run time is 120 minutes.

Change-Id: Ib58e5200ac7c75b1708a86b58eec3c682f0d6e2e
Signed-off-by: biao716.wang <biao716.wang@samsung.com>
mic/cmd_create.py [changed mode: 0755->0644]
mic/conf.py
mic/imager/baseimager.py
tools/mic

old mode 100755 (executable)
new mode 100644 (file)
index ab353a8..ed19072
@@ -82,7 +82,6 @@ def main(parser, args, argv):
             rpm.setVerbosity(rpm.RPMLOG_DEBUG)\r
         except ImportError:\r
             pass\r
-\r
     #check the imager type\r
     createrClass = None\r
     for subcmd, klass in pluginmgr.get_plugins('imager').iteritems():\r
@@ -150,7 +149,8 @@ def main(parser, args, argv):
 \r
     if args.skip_set_hosts:\r
         configmgr.create['skip_set_hosts']=args.skip_set_hosts\r
-\r
+    if args.postscripts_maxruntime:\r
+        configmgr.create['postscripts_maxruntime']=int(args.postscripts_maxruntime)\r
     if args.runtime:\r
         configmgr.set_runtime(args.runtime)\r
 \r
index 031c1af5cebb7a0e82f49688dc6e47dc15f61aa8..9269d56a4f0723dcfa8898ba0a76d99c0393d871 100755 (executable)
@@ -80,6 +80,7 @@ class ConfigMgr(object):
                     "tpk_install": None,
                     "use_mic_in_bootstrap": False,
                     "skip_set_hosts": False,
+                    "postscripts_maxruntime": 120,
                 },
                 'chroot': {
                     "saveto": None,
index f36238557af79fd6ffa47c011db2ec85c6cc6d48..f0243f7c08a758db4c3fdd2089a5e2449f30bafd 100644 (file)
@@ -38,8 +38,6 @@ from mic.chroot import kill_proc_inchroot
 from mic.archive import get_archive_suffixes
 from mic.conf import configmgr
 from mic.utils.grabber import myurlgrab
-#post script max run time
-MAX_RUN_TIME = 120
 
 class BaseImageCreator(object):
     """Installs a system to a chroot directory.
@@ -1300,7 +1298,6 @@ class BaseImageCreator(object):
             else:
                 preexec = self._chroot
                 script = "/tmp/" + os.path.basename(path)
-
             start_time = time.time()
             try:
                 try:
@@ -1312,8 +1309,8 @@ class BaseImageCreator(object):
                     while p.poll() == None:
                        msger.info(p.stdout.readline().strip())
                         end_time = time.time()
-                        if (end_time - start_time)/60 > MAX_RUN_TIME:
-                            raise CreatorError("Your post script is executed more than "+MAX_RUN_TIME+"mins, please check it!")
+                        if (end_time - start_time)/60 > configmgr.create['postscripts_maxruntime']:
+                            raise CreatorError("Your post script is executed more than %d mins, please check it!" % configmgr.create['postscripts_maxruntime'])
                     if p.returncode != 0:
                         raise CreatorError("Failed to execute %%post script "
                                            "with '%s'" % (s.interp))
index fc4fb2c1277d9aa6a3fa46d7bca819e97aa3bb18..9b55f564f2001ee7cc167dc910de8364b9257e25 100755 (executable)
--- a/tools/mic
+++ b/tools/mic
@@ -143,6 +143,7 @@ def create_parser(parser):
                                                                        default=None, help='Copy tpk file to /usr/apps/.preload-tpk')
     parent_parser.add_argument('--rpm-debug', action='store_true', dest='rpm_debug', help='Set debug mode for rpm install')
     parent_parser.add_argument('--skip-set-hosts', action='store_true', dest='skip_set_hosts', default=False, help='choose to skip set hosts by mic')
+    parent_parser.add_argument('--postscripts-maxruntime', dest='postscripts_maxruntime', default=120, help='max run time for post scripts')
 
     parser.set_defaults(alias="cr")