Fix max concurrent builds's unlimited semaphore

When booting an instance with the config paramter
max_concurrent_builds set to 0, a TypeError is logged in the compute
log. This doesn't prevent the instance from booting, but could be
confusing to someone debugging a different issue. This patch fixes
this issue by fixing the method signature of the __exit__ method of
compute utils's UnlimitedSemaphore. UnlimitedSemaphore was bypassed
entirely in unit tests because the default value for
max_concurrent_builds is 10.

Closes-bug: 1520633
Change-Id: I15825eb3fb1bccb12f4a9148809495ce3e83e3c8
This commit is contained in:
Artom Lifshitz
2015-10-23 18:09:04 +00:00
parent db851200d3
commit 9989a75384
2 changed files with 10 additions and 2 deletions

View File

@@ -528,7 +528,7 @@ class UnlimitedSemaphore(object):
def __enter__(self):
pass
def __exit__(self):
def __exit__(self, exc_type, exc_val, exc_tb):
pass
@property

View File

@@ -3208,8 +3208,16 @@ class ComputeManagerBuildInstanceTestCase(test.NoDBTestCase):
mock_hooks.setdefault().run_post.assert_called_once_with(
'build_instance', result, mock.ANY, mock.ANY, f=None)
def test_build_and_run_instance_called_with_proper_args(self):
self._test_build_and_run_instance()
def test_build_and_run_instance_with_unlimited_max_concurrent_builds(self):
self.flags(max_concurrent_builds=0)
self.compute = importutils.import_object(CONF.compute_manager)
self._test_build_and_run_instance()
@mock.patch('nova.hooks._HOOKS')
def test_build_and_run_instance_called_with_proper_args(self, mock_hooks):
def _test_build_and_run_instance(self, mock_hooks):
self.mox.StubOutWithMock(self.compute, '_build_and_run_instance')
self._do_build_instance_update()
self.compute._build_and_run_instance(self.context, self.instance,