Merge "Fix bug preventing forbidden traits from working" into stable/stein
This commit is contained in:
commit
353985210b
|
@ -243,8 +243,8 @@ class ResourceRequest(object):
|
||||||
def _clean_empties(self):
|
def _clean_empties(self):
|
||||||
"""Get rid of any empty ResourceGroup instances."""
|
"""Get rid of any empty ResourceGroup instances."""
|
||||||
for ident, rg in list(self._rg_by_id.items()):
|
for ident, rg in list(self._rg_by_id.items()):
|
||||||
# TODO(magnusbe) Fix bug #1821824
|
if not any((rg.resources, rg.required_traits,
|
||||||
if not any((rg.resources, rg.required_traits)):
|
rg.forbidden_traits)):
|
||||||
self._rg_by_id.pop(ident)
|
self._rg_by_id.pop(ident)
|
||||||
|
|
||||||
def strip_zeros(self):
|
def strip_zeros(self):
|
||||||
|
|
|
@ -4579,11 +4579,9 @@ class TraitsBasedSchedulingTest(integrated_helpers.ProviderUsageBaseTestCase):
|
||||||
|
|
||||||
server = self._wait_for_state_change(self.admin_api, server, 'ACTIVE')
|
server = self._wait_for_state_change(self.admin_api, server, 'ACTIVE')
|
||||||
|
|
||||||
# Temporarily pass until bug #1821824 is fixed
|
|
||||||
# Assert the server ended up on the expected compute host that doesn't
|
# Assert the server ended up on the expected compute host that doesn't
|
||||||
# have the forbidden trait.
|
# have the forbidden trait.
|
||||||
# TODO(magnusbe) Uncomment when commiting fix for bug #1821824
|
self.assertEqual(self.compute2.host, server['OS-EXT-SRV-ATTR:host'])
|
||||||
# self.assertEqual(self.compute2.host, server['OS-EXT-SRV-ATTR:host'])
|
|
||||||
|
|
||||||
# Disable the compute node that doesn't have the forbidden trait
|
# Disable the compute node that doesn't have the forbidden trait
|
||||||
compute2_service_id = self.admin_api.get_services(
|
compute2_service_id = self.admin_api.get_services(
|
||||||
|
@ -4596,20 +4594,12 @@ class TraitsBasedSchedulingTest(integrated_helpers.ProviderUsageBaseTestCase):
|
||||||
self.image_id_without_trait
|
self.image_id_without_trait
|
||||||
)
|
)
|
||||||
|
|
||||||
# Temporarily pass if server goes to ACTIVE STATE until bug #1821824
|
|
||||||
# is fixed.
|
|
||||||
# TODO(magnusbe) Remove when commiting fix for bug #1821824
|
|
||||||
server = self._wait_for_state_change(self.admin_api, server, 'ACTIVE')
|
|
||||||
|
|
||||||
# The server should go to ERROR state because there is no valid host.
|
# The server should go to ERROR state because there is no valid host.
|
||||||
# This is the expected behaviour. However, at this time bug #1821824
|
server = self._wait_for_state_change(self.admin_api, server, 'ERROR')
|
||||||
# prevents this from working.
|
self.assertIsNone(server['OS-EXT-SRV-ATTR:host'])
|
||||||
# TODO(magnusbe) Uncomment when commiting fix for bug #1821824
|
|
||||||
# server = self._wait_for_state_change(self.admin_api, server, 'ERROR')
|
|
||||||
# self.assertIsNone(server['OS-EXT-SRV-ATTR:host'])
|
|
||||||
# Make sure the failure was due to NoValidHost by checking the fault.
|
# Make sure the failure was due to NoValidHost by checking the fault.
|
||||||
# self.assertIn('fault', server)
|
self.assertIn('fault', server)
|
||||||
# self.assertIn('No valid host', server['fault']['message'])
|
self.assertIn('No valid host', server['fault']['message'])
|
||||||
|
|
||||||
def test_image_traits_based_scheduling(self):
|
def test_image_traits_based_scheduling(self):
|
||||||
"""Tests that a server create request using a required trait on image
|
"""Tests that a server create request using a required trait on image
|
||||||
|
|
|
@ -103,6 +103,28 @@ class TestUtils(test.NoDBTestCase):
|
||||||
self._test_resources_from_request_spec(expected_resources, flavor,
|
self._test_resources_from_request_spec(expected_resources, flavor,
|
||||||
image)
|
image)
|
||||||
|
|
||||||
|
def test_resources_from_request_spec_flavor_forbidden_trait(self):
|
||||||
|
flavor = objects.Flavor(vcpus=1,
|
||||||
|
memory_mb=1024,
|
||||||
|
root_gb=10,
|
||||||
|
ephemeral_gb=5,
|
||||||
|
swap=0,
|
||||||
|
extra_specs={
|
||||||
|
'trait:CUSTOM_FLAVOR_TRAIT': 'forbidden'})
|
||||||
|
expected_resources = utils.ResourceRequest()
|
||||||
|
expected_resources._rg_by_id[None] = objects.RequestGroup(
|
||||||
|
use_same_provider=False,
|
||||||
|
resources={
|
||||||
|
'VCPU': 1,
|
||||||
|
'MEMORY_MB': 1024,
|
||||||
|
'DISK_GB': 15,
|
||||||
|
},
|
||||||
|
forbidden_traits={
|
||||||
|
'CUSTOM_FLAVOR_TRAIT',
|
||||||
|
}
|
||||||
|
)
|
||||||
|
self._test_resources_from_request_spec(expected_resources, flavor)
|
||||||
|
|
||||||
def test_resources_from_request_spec_with_no_disk(self):
|
def test_resources_from_request_spec_with_no_disk(self):
|
||||||
flavor = objects.Flavor(vcpus=1,
|
flavor = objects.Flavor(vcpus=1,
|
||||||
memory_mb=1024,
|
memory_mb=1024,
|
||||||
|
|
Loading…
Reference in New Issue