]> git-server-git.apps.pok.os.sepia.ceph.com Git - teuthology.git/commitdiff
suite/run: add more interaction for sleep-before-teardown 1448/head
authorKyr Shatskyy <kyrylo.shatskyy@gmail.com>
Tue, 7 Apr 2020 21:43:49 +0000 (23:43 +0200)
committerKyr Shatskyy <kyrylo.shatskyy@suse.com>
Wed, 15 Apr 2020 19:08:32 +0000 (21:08 +0200)
Signed-off-by: Kyr Shatskyy <kyrylo.shatskyy@suse.com>
(cherry picked from commit c43303e8892671cec389e68f7643b10624c4b7fc)

requirements2.txt
requirements3.txt
scripts/openstack.py
scripts/suite.py
setup.py
teuthology/suite/run.py

index ff3c1dda69bfb629a1c12affd5f39369254de34c..128aaab4d4dcd1484c3095edc888a49b4caea91d 100644 (file)
@@ -38,7 +38,9 @@ futures==3.2.0            # via s3transfer
 gevent==1.4.0
 greenlet==0.4.15          # via gevent
 httplib2==0.10.3
+humanfriendly==8.1
 idna==2.5                 # via requests
+ipy==1.0
 ipaddress==1.0.18         # via cryptography
 iso8601==0.1.11           # via keystoneauth1, oslo.utils, python-neutronclient, python-novaclient
 jinja2==2.10.1            # via ansible
@@ -107,7 +109,6 @@ virtualenv==15.1.0        # via tox
 warlock==1.2.0            # via python-glanceclient
 wrapt==1.10.10            # via debtcollector, positional, python-glanceclient
 xmltodict==0.12.0
-ipy==1.0
 
 # The following packages are considered to be unsafe in a requirements file:
 # setuptools
index f1fcedd5e022a74ad559c471a89c688bd1b15833..b86dd1624d884b49f5015e09cfcc4b1655c83108 100644 (file)
@@ -34,7 +34,9 @@ docutils==0.14            # via botocore
 gevent==1.4.0
 greenlet==0.4.15          # via gevent
 httplib2==0.10.3
+humanfriendly==8.1
 idna==2.5                 # via requests
+ipy==1.0
 iso8601==0.1.11           # via keystoneauth1, oslo.utils, python-neutronclient, python-novaclient
 jinja2==2.10.1            # via ansible
 jmespath==0.9.4           # via boto3, botocore
@@ -99,7 +101,6 @@ virtualenv==15.1.0        # via tox
 warlock==1.2.0            # via python-glanceclient
 wrapt==1.10.10            # via debtcollector, positional, python-glanceclient
 xmltodict==0.12.0
-ipy==1.0
 
 # The following packages are considered to be unsafe in a requirements file:
 # setuptools
index c95f54bc5048b7e7aa09664c4f245305e942a03f..bfdcbfa8ec25c1994389917d9270981172c71a03 100644 (file)
@@ -189,7 +189,7 @@ def get_suite_parser():
     )
     parser.add_argument(
         '--sleep-before-teardown',
-        help='Number of seconds to sleep before tearing down the target VMs',
+        help='Number of seconds to sleep before the teardown',
         default=0
     )
     return parser
index 4a244678aa38376c1b1453f72840f3443c4be6f9..c8b921f01c4494482d3a6399206122a9e4a8829e 100644 (file)
@@ -80,9 +80,14 @@ Standard arguments:
                               Validate that git SHA1s passed to -S exist.
                               [default: true]
   --sleep-before-teardown <seconds>
-                              Number of seconds to sleep before tearing down
-                              the test cluster(s). Use with care, as this
-                              applies to all jobs in the run.
+                              Number of seconds to sleep before teardown.
+                              Use with care, as this applies to all jobs in the
+                              run. This option is used along with --limit one.
+                              If the --limit ommitted then it's forced to 1.
+                              If the --limit is greater than 4, then user must
+                              confirm it interactively to avoid massive lock
+                              of resources, however --non-interactive option
+                              can be used to skip user input.
                               [default: 0]
 
 Scheduler arguments:
index 3e7b9984e5d3dc1fbbbec5fc972b84b3f9c50f8d..4d562b3fc8f136d533a0876bd3b4cd9f64944c15 100644 (file)
--- a/setup.py
+++ b/setup.py
@@ -65,6 +65,7 @@ setup(
                       'ansible>=2.0',
                       'prettytable',
                       'manhole',
+                      'humanfriendly',
                       ],
     extras_require = {
         'coverage': [ 'mysqlclient == 1.4.2'],
index ab7d6f4215decd01c859f67e1515ef831e955b33..7b217352336f46aebfb7b8e753e1907325e83b4a 100644 (file)
@@ -6,6 +6,9 @@ import re
 import time
 import yaml
 
+from six.moves import input
+from humanfriendly import format_timespan
+
 from datetime import datetime
 from tempfile import NamedTemporaryFile
 
@@ -356,14 +359,13 @@ class Run(object):
         if num_jobs:
             self.write_result()
 
-    def collect_jobs(self, arch, configs, newest=False):
+    def collect_jobs(self, arch, configs, newest=False, limit=0):
         jobs_to_schedule = []
         jobs_missing_packages = []
         for description, fragment_paths in configs:
             base_frag_paths = [
                 util.strip_fragment_path(x) for x in fragment_paths
             ]
-            limit = self.args.limit or 0
             if limit > 0 and len(jobs_to_schedule) >= limit:
                 log.info(
                     'Stopped after {limit} jobs due to --limit={limit}'.format(
@@ -518,13 +520,46 @@ class Run(object):
         ).name
         self.base_yaml_paths.insert(0, base_yaml_path)
 
+        # compute job limit in respect of --sleep-before-teardown
+        job_limit = self.args.limit or 0
+        sleep_before_teardown = int(self.args.sleep_before_teardown or 0)
+        if sleep_before_teardown:
+            if job_limit == 0:
+                log.warning('The --sleep-before-teardown option was provided: '
+                            'only 1 job will be scheduled. '
+                            'Use --limit to run more jobs')
+                # give user a moment to read this warning
+                time.sleep(5)
+                job_limit = 1
+            elif self.args.non_interactive:
+                log.warning(
+                    'The --sleep-before-teardown option is active. '
+                    'There will be a maximum {} jobs running '
+                    'which will fall asleep for {}'
+                    .format(job_limit, format_timespan(sleep_before_teardown)))
+            elif job_limit > 4:
+                are_you_insane=(
+                    'There are {total} configs and {maximum} job limit is used. '
+                    'Do you really want to lock all machines needed for '
+                    'this run for {that_long}? (y/N):'
+                    .format(
+                        that_long=format_timespan(sleep_before_teardown),
+                        total=len(configs),
+                        maximum=job_limit))
+                while True:
+                    insane=(input(are_you_insane) or 'n').lower()
+                    if insane == 'y':
+                        break
+                    elif insane == 'n':
+                        exit(0)
+
         # if newest, do this until there are no missing packages
         # if not, do it once
         backtrack = 0
         limit = self.args.newest
         while backtrack <= limit:
             jobs_missing_packages, jobs_to_schedule = \
-                self.collect_jobs(arch, configs, self.args.newest)
+                self.collect_jobs(arch, configs, self.args.newest, job_limit)
             if jobs_missing_packages and self.args.newest:
                 new_sha1 = \
                     util.find_git_parent('ceph', self.base_config.sha1)