Orphaned accelerators after devices removed
Fixes the issue that when accelerator devices were removed from node, a re-introspection does not remove previous accelerator device information from the node. Closes-Bug: 2118958 Change-Id: Ia57902a9095b78e0128a728693c03e0a01c6421b Signed-off-by: Kaifeng Wang <kaifeng.w@gmail.com>
This commit is contained in:
@@ -78,3 +78,5 @@ class AcceleratorsHook(base.InspectionHook):
|
||||
else:
|
||||
LOG.info('No known accelerator devices found for node %s',
|
||||
task.node.uuid)
|
||||
task.node.set_property('accelerators', accelerators)
|
||||
task.node.save()
|
||||
|
@@ -78,3 +78,27 @@ class AcceleratorsTestCase(db_base.DbTestCase):
|
||||
'device_info': 'NVIDIA Corporation Tesla T4',
|
||||
'pci_address': '0000:00:01.2'}]
|
||||
self.assertEqual(result, expected)
|
||||
|
||||
def test_accelerators_cleanup(self):
|
||||
with task_manager.acquire(self.context, self.node.id) as task:
|
||||
prop = self.node.properties
|
||||
prop['accelerators'] = [
|
||||
{'vendor_id': '0de',
|
||||
'device_id': '1eb8',
|
||||
'type': 'GPU',
|
||||
'device_info': 'NVIDIA Corporation Tesla T4',
|
||||
'pci_address': '0000:00:01.2'}
|
||||
]
|
||||
self.node.properties = prop
|
||||
self.node.save()
|
||||
self.plugin_data = {'pci_devices': [{
|
||||
"vendor_id": "8086",
|
||||
"product_id": "324c",
|
||||
"class": "088000",
|
||||
"revision": "00",
|
||||
"bus": "0000:ff:00.7"
|
||||
}]}
|
||||
self.accelerators_hook.__call__(task, self.inventory,
|
||||
self.plugin_data)
|
||||
self.node.refresh()
|
||||
self.assertEqual(self.node.properties.get('accelerators'), [])
|
||||
|
@@ -0,0 +1,6 @@
|
||||
---
|
||||
fixes:
|
||||
- |
|
||||
Fixes an issue that when accelerator devices were removed from node,
|
||||
a re-introspection does not remove previous accelerator device
|
||||
information from the node.
|
Reference in New Issue
Block a user