Merge "Exclude on maintenance reserved_hosts for host_failure recovery"

This commit is contained in:
Jenkins 2017-06-21 07:25:57 +00:00 committed by Gerrit Code Review
commit 44553b5005
3 changed files with 27 additions and 1 deletions

View File

@ -154,7 +154,9 @@ class MasakariManager(manager.Manager):
reserved_host_list = objects.HostList.get_all(
context, filters={
'failover_segment_id': host_obj.failover_segment_id,
'reserved': True})
'reserved': True,
'on_maintenance': False
})
try:
self.driver.execute_host_failure(

View File

@ -296,6 +296,27 @@ class HostsTestCase(test.TestCase, ModelsObjectComparatorMixin):
sort_dirs=['asc'])
self._assertEqualListsOfObjects([hosts[1]], real_host, ignored_keys)
def test_host_get_all_by_filter_on_maintenance(self):
for p in self._get_fake_values_list():
# create temporary reserved_hosts, all are on maintenance
self._create_host(p)
# create one more reserved_host which is not on maintenance
temp_host = self._get_fake_values()
temp_host['on_maintenance'] = False
self._create_host(temp_host)
ignored_keys = ['deleted', 'created_at', 'updated_at', 'deleted_at',
'id', 'failover_segment']
real_host = db.host_get_all_by_filters(
context=self.ctxt,
filters={'on_maintenance': False},
marker=1,
limit=1,
sort_keys=['id'],
sort_dirs=['asc'])
self._assertEqualListsOfObjects([temp_host], real_host, ignored_keys)
def test_host_not_found(self):
self._create_host(self._get_fake_values())
self.assertRaises(exception.HostNotFound,

View File

@ -303,6 +303,9 @@ class EngineManagerUnitTestCase(test.NoDBTestCase):
fake_host.name, fake_host.failover_segment.recovery_method,
notification.notification_uuid,
reserved_host_list=reserved_host_list)
mock_get_all.assert_called_once_with(self.context, filters={
'failover_segment_id': fake_host.failover_segment.uuid,
'reserved': True, 'on_maintenance': False})
@mock.patch.object(host_obj.Host, "get_by_uuid")
@mock.patch.object(host_obj.Host, "save")