Merge "Always trait the compute node RP with COMPUTE_NODE"

This commit is contained in:
Zuul 2019-11-15 23:01:32 +00:00 committed by Gerrit Code Review
commit f01fbd8cf0
7 changed files with 41 additions and 13 deletions

View File

@ -68,7 +68,7 @@ os-brick==2.6.2
os-client-config==1.29.0
os-resource-classes==0.4.0
os-service-types==1.7.0
os-traits==0.16.0
os-traits==1.1.0
os-vif==1.14.0
os-win==3.0.0
os-xenapi==0.3.3

View File

@ -1081,6 +1081,11 @@ class ResourceTracker(object):
elif trait in traits:
traits.remove(trait)
# Always mark the compute node. This lets other processes (possibly
# unrelated to nova or even OpenStack) find and distinguish these
# providers easily.
traits.add(os_traits.COMPUTE_NODE)
self._sync_compute_service_disabled_trait(context, traits)
return list(traits)

View File

@ -57,8 +57,9 @@ class LibvirtReportTraitsTests(LibvirtReportTraitsTestBase):
# Test CPU traits reported on initial node startup, these specific
# trait values are coming from fakelibvirt's baselineCPU result.
# COMPUTE_NODE is always set on the compute node provider.
traits = self._get_provider_traits(self.host_uuid)
for trait in ('HW_CPU_X86_VMX', 'HW_CPU_X86_AESNI'):
for trait in ('HW_CPU_X86_VMX', 'HW_CPU_X86_AESNI', 'COMPUTE_NODE'):
self.assertIn(trait, traits)
self._create_trait('CUSTOM_TRAITS')
@ -73,7 +74,9 @@ class LibvirtReportTraitsTests(LibvirtReportTraitsTestBase):
# and it's not in the baseline for the host.
traits = set(self._get_provider_traits(self.host_uuid))
expected_traits = self.expected_libvirt_driver_capability_traits.union(
[u'HW_CPU_X86_VMX', u'HW_CPU_X86_AESNI', u'CUSTOM_TRAITS']
[u'HW_CPU_X86_VMX', u'HW_CPU_X86_AESNI', u'CUSTOM_TRAITS',
# The periodic restored the COMPUTE_NODE trait.
u'COMPUTE_NODE']
)
self.assertItemsEqual(expected_traits, traits)

View File

@ -81,7 +81,11 @@ class ProviderTreeTests(integrated_helpers.ProviderUsageBaseTestCase):
'step_size': 1,
},
}, self._get_provider_inventory(self.host_uuid))
self.assertItemsEqual(self.expected_fake_driver_capability_traits,
self.expected_compute_node_traits = (
self.expected_fake_driver_capability_traits.union(
# The COMPUTE_NODE trait is always added
[os_traits.COMPUTE_NODE]))
self.assertItemsEqual(self.expected_compute_node_traits,
self._get_provider_traits(self.host_uuid))
def _run_update_available_resource(self, startup):
@ -148,7 +152,7 @@ class ProviderTreeTests(integrated_helpers.ProviderUsageBaseTestCase):
self.assertIn('CUSTOM_GOLD', self._get_all_traits())
self.assertEqual(inv, self._get_provider_inventory(self.host_uuid))
self.assertItemsEqual(
traits.union(self.expected_fake_driver_capability_traits),
traits.union(self.expected_compute_node_traits),
self._get_provider_traits(self.host_uuid)
)
self.assertEqual(aggs,
@ -369,7 +373,7 @@ class ProviderTreeTests(integrated_helpers.ProviderUsageBaseTestCase):
self._get_provider_inventory(uuids.pf2_2)['SRIOV_NET_VF']['total'])
# Compute don't have any extra traits
self.assertItemsEqual(self.expected_fake_driver_capability_traits,
self.assertItemsEqual(self.expected_compute_node_traits,
self._get_provider_traits(self.host_uuid))
# NUMAs don't have any traits
@ -591,6 +595,7 @@ class TraitsTrackingTests(integrated_helpers.ProviderUsageBaseTestCase):
self.assertNotIn(custom_trait, global_traits)
self.assertIn(os_traits.COMPUTE_NET_ATTACH_INTERFACE, global_traits)
self.assertIn(os_traits.COMPUTE_DEVICE_TAGGING, global_traits)
self.assertIn(os_traits.COMPUTE_NODE, global_traits)
self.assertEqual([], self._get_all_providers())
self._mock_upt(ptree_traits, [])
@ -599,7 +604,8 @@ class TraitsTrackingTests(integrated_helpers.ProviderUsageBaseTestCase):
rp_uuid = self._get_provider_uuid_by_host('host1')
expected_traits = set(
ptree_traits + [os_traits.COMPUTE_NET_ATTACH_INTERFACE]
ptree_traits +
[os_traits.COMPUTE_NET_ATTACH_INTERFACE, os_traits.COMPUTE_NODE]
)
self.assertItemsEqual(expected_traits,
self._get_provider_traits(rp_uuid))

View File

@ -42,6 +42,7 @@ from nova import test
from nova.tests.unit import fake_instance
from nova.tests.unit import fake_notifier
from nova.tests.unit.objects import test_pci_device as fake_pci_device
from nova.tests.unit import utils
from nova.virt import driver
_HOSTNAME = 'fake-host'
@ -1601,12 +1602,13 @@ class TestUpdateComputeNode(BaseTestCase):
self.rt._update(mock.sentinel.ctx, new_compute)
self.driver_mock.capabilities_as_traits.assert_called_once()
# We always decorate with COMPUTE_NODE
exp_traits = {mock.sentinel.trait, os_traits.COMPUTE_NODE}
# Can't predict the order of the traits list, so use ItemsMatcher
ptree.update_traits.assert_called_once_with(
new_compute.hypervisor_hostname,
[mock.sentinel.trait]
)
new_compute.hypervisor_hostname, utils.ItemsMatcher(exp_traits))
mock_sync_disabled.assert_called_once_with(
mock.sentinel.ctx, {mock.sentinel.trait})
mock.sentinel.ctx, exp_traits)
@mock.patch('nova.compute.resource_tracker.ResourceTracker.'
'_sync_compute_service_disabled_trait')
@ -1678,7 +1680,7 @@ class TestUpdateComputeNode(BaseTestCase):
mock.sentinel.ctx, ptree, allocations=None)
ptree.update_traits.assert_called_once_with(
new_compute.hypervisor_hostname,
[]
[os_traits.COMPUTE_NODE]
)
exp_inv = copy.deepcopy(fake_inv)
# These ratios and reserved amounts come from fake_upt

View File

@ -0,0 +1,12 @@
---
upgrade:
- |
Starting in the Ussuri release, compute node resource providers are
automatically marked with the ``COMPUTE_NODE`` trait. This allows them to
be distinguished easily from other providers, including sharing and nested
providers, as well as other non-compute-related providers in a deployment.
To make effective use of this trait (e.g. for scheduling purposes), all
compute nodes must be upgrade to Ussuri. Alternatively, you can manually
add the trait to pre-Ussuri compute node providers via `openstack resource
provider trait set
<https://docs.openstack.org/osc-placement/train/cli/index.html#resource-provider-trait-set>`_

View File

@ -56,7 +56,7 @@ psutil>=3.2.2 # BSD
oslo.versionedobjects>=1.35.0 # Apache-2.0
os-brick>=2.6.2 # Apache-2.0
os-resource-classes>=0.4.0 # Apache-2.0
os-traits>=0.16.0 # Apache-2.0
os-traits>=1.1.0 # Apache-2.0
os-vif>=1.14.0 # Apache-2.0
os-win>=3.0.0 # Apache-2.0
castellan>=0.16.0 # Apache-2.0