Add minimum value in max_concurrent_live_migrations

Add minimum value 0 in the max_concurrent_live_migrations option.

Change-Id: I52ead0154e311a0ebdfd6d7413704fa350020587
This commit is contained in:
Takashi NATSUME 2019-03-28 11:13:38 +09:00
parent 03322bb517
commit 37c42c97e2
4 changed files with 12 additions and 23 deletions

View File

@ -518,15 +518,11 @@ class ComputeManager(manager.Manager):
CONF.max_concurrent_builds)
else:
self._build_semaphore = compute_utils.UnlimitedSemaphore()
if max(CONF.max_concurrent_live_migrations, 0) != 0:
if CONF.max_concurrent_live_migrations > 0:
self._live_migration_executor = futurist.GreenThreadPoolExecutor(
max_workers=CONF.max_concurrent_live_migrations)
else:
if CONF.max_concurrent_live_migrations < 0:
LOG.warning('The value of the max_concurrent_live_migrations '
'config option is less than 0. '
'It is treated as 0 and will raise ValueError '
'in a future release.')
# CONF.max_concurrent_live_migrations is 0 (unlimited)
self._live_migration_executor = futurist.GreenThreadPoolExecutor()
# This is a dict, keyed by instance uuid, to a two-item tuple of
# migration object and Future for the queued live migration.

View File

@ -621,9 +621,9 @@ Possible Values:
* 0 : treated as unlimited.
* Any positive integer representing maximum concurrent builds.
"""),
# TODO(sfinucan): Add min parameter
cfg.IntOpt('max_concurrent_live_migrations',
default=1,
min=0,
help="""
Maximum number of live migrations to run concurrently. This limit is enforced
to avoid outbound live migrations overwhelming the host/network and causing
@ -633,7 +633,6 @@ that doing so is safe and stable in your environment.
Possible values:
* 0 : treated as unlimited.
* Negative value defaults to 0.
* Any positive integer representing maximum number of live migrations
to run concurrently.
"""),

View File

@ -7437,22 +7437,11 @@ class ComputeManagerMigrationTestCase(test.NoDBTestCase,
manager.ComputeManager()
mock_executor.assert_called_once_with(max_workers=123)
@ddt.data(0, -2)
def test_max_concurrent_live_semaphore_unlimited(self, max_concurrent):
self.flags(max_concurrent_live_migrations=max_concurrent)
with test.nested(
mock.patch('futurist.GreenThreadPoolExecutor'),
mock.patch('nova.compute.manager.LOG'),
) as (mock_executor, mock_log):
manager.ComputeManager()
@mock.patch('futurist.GreenThreadPoolExecutor')
def test_max_concurrent_live_semaphore_unlimited(self, mock_executor):
self.flags(max_concurrent_live_migrations=0)
manager.ComputeManager()
mock_executor.assert_called_once_with()
if max_concurrent < 0:
mock_log.warning.assert_called_once_with(
'The value of the max_concurrent_live_migrations config '
'option is less than 0. It is treated as 0 and will raise '
'ValueError in a future release.')
else:
mock_log.warning.assert_not_called()
def test_pre_live_migration_cinder_v3_api(self):
# This tests that pre_live_migration with a bdm with an

View File

@ -0,0 +1,5 @@
---
upgrade:
- The ``max_concurrent_live_migrations`` configuration option has been
restricted by the minimum value and now raises a ValueError
if the value is less than 0.