Ensure ResourceProvider/Inventory created before add Allocations record

In the startup of compute node, the first available resource update
will fail to add Allocations record. This is due to ResourceProvider
will be created at the end of available resource update.

This patch ensure the ResourceProvider and Inventory created in the
beginning of available resource update.

Closes-Bug: #1621437
Change-Id: I91fa7b8354a7613848225429ac9d38c6305b03c6
This commit is contained in:
He Jie Xu 2016-09-08 19:46:24 +08:00
parent b028b25391
commit b6edbce9b3
2 changed files with 6 additions and 0 deletions

View File

@ -419,6 +419,7 @@ class ResourceTracker(object):
if self.compute_node:
self._copy_resources(resources)
self._setup_pci_tracker(context, resources)
self.scheduler_client.update_resource_stats(self.compute_node)
return
# now try to get the compute node record from the
@ -427,6 +428,7 @@ class ResourceTracker(object):
if self.compute_node:
self._copy_resources(resources)
self._setup_pci_tracker(context, resources)
self.scheduler_client.update_resource_stats(self.compute_node)
return
# there was no local copy and none in the database
@ -441,6 +443,7 @@ class ResourceTracker(object):
{'host': self.host, 'node': self.nodename})
self._setup_pci_tracker(context, resources)
self.scheduler_client.update_resource_stats(self.compute_node)
def _setup_pci_tracker(self, context, resources):
if not self.pci_tracker:

View File

@ -1035,6 +1035,7 @@ class TestInitComputeNode(BaseTestCase):
self.assertFalse(create_mock.called)
self.assertTrue(pci_mock.called)
self.assertFalse(self.rt.disabled)
self.assertTrue(self.sched_client_mock.update_resource_stats.called)
@mock.patch('nova.objects.PciDeviceList.get_by_compute_node',
return_value=objects.PciDeviceList())
@ -1057,6 +1058,7 @@ class TestInitComputeNode(BaseTestCase):
_NODENAME)
self.assertFalse(create_mock.called)
self.assertFalse(self.rt.disabled)
self.assertTrue(self.sched_client_mock.update_resource_stats.called)
@mock.patch('nova.objects.PciDeviceList.get_by_compute_node',
return_value=objects.PciDeviceList(objects=[]))
@ -1134,6 +1136,7 @@ class TestInitComputeNode(BaseTestCase):
self.rt.compute_node))
pci_tracker_mock.assert_called_once_with(mock.sentinel.ctx,
42)
self.assertTrue(self.sched_client_mock.update_resource_stats.called)
class TestUpdateComputeNode(BaseTestCase):