Use ThreadPoolExecutor for max_concurrent_live_migrations
This changes the max_concurrent_live_migrations handling to use a ThreadPoolExecutor so that we can control a bounded pool of Futures in order to cancel queued live migrations later in this series. There is a slight functional difference in the unlimited case since starting in python 3.5, ThreadPoolExecutor will default to ncpu * 5 concurrently running threads. However, max_concurrent_live_migrations defaults to 1 and assuming compute hosts run with 32 physical CPUs on average, you'd be looking at a maximum of 160 concurrently running live migrations, which is probably way above what anyone would consider sane. Co-Authored-By: Matt Riedemann <mriedem.os@gmail.com> Part of blueprint abort-live-migration-in-queued-status Change-Id: Ia9ea1e164fb3b4a386405538eed58d94ad115172
This commit is contained in:
parent
93d3811e5d
commit
fd0dba4c9d
|
@ -33,6 +33,7 @@ fixtures==3.0.0
|
|||
flake8==2.5.5
|
||||
future==0.16.0
|
||||
futurist==1.6.0
|
||||
futures==3.0.0
|
||||
gabbi==1.35.0
|
||||
gitdb2==2.0.3
|
||||
GitPython==2.1.8
|
||||
|
|
|
@ -1010,6 +1010,26 @@ class SpawnIsSynchronousFixture(fixtures.Fixture):
|
|||
'nova.utils.spawn', _FakeGreenThread))
|
||||
|
||||
|
||||
class SynchronousThreadPoolExecutorFixture(fixtures.Fixture):
|
||||
"""Make ThreadPoolExecutor.submit() synchronous.
|
||||
|
||||
The function passed to submit() will be executed and a mock.Mock
|
||||
object will be returned as the Future where Future.result() will
|
||||
return the result of the call to the submitted function.
|
||||
"""
|
||||
def setUp(self):
|
||||
super(SynchronousThreadPoolExecutorFixture, self).setUp()
|
||||
|
||||
def fake_submit(_self, fn, *args, **kwargs):
|
||||
result = fn(*args, **kwargs)
|
||||
future = mock.Mock(spec='concurrent.futures.Future')
|
||||
future.return_value.result.return_value = result
|
||||
return future
|
||||
self.useFixture(fixtures.MonkeyPatch(
|
||||
'concurrent.futures.ThreadPoolExecutor.submit',
|
||||
fake_submit))
|
||||
|
||||
|
||||
class BannedDBSchemaOperations(fixtures.Fixture):
|
||||
"""Ban some operations for migrations"""
|
||||
def __init__(self, banned_resources=None):
|
||||
|
|
|
@ -67,3 +67,4 @@ os-service-types>=1.2.0 # Apache-2.0
|
|||
taskflow>=2.16.0 # Apache-2.0
|
||||
python-dateutil>=2.5.3 # BSD
|
||||
zVMCloudConnector>=1.1.1;sys_platform!='win32' # Apache 2.0 License
|
||||
futures>=3.0.0;python_version=='2.7' or python_version=='2.6' # PSF
|
||||
|
|
Loading…
Reference in New Issue