Fix 'introspection bulk status' when some nodes were never introspected
Previously we did not handle exceptions from ironic_inspector_client, so nodes that were never introspected (e.g. ones in maintenance mode) caused this command to fail. Change-Id: I58756256fe70992ff5618a3f307ce34f95e71efd Closes-Bug: #1689540
This commit is contained in:
parent
dd19054206
commit
759dff71d8
@ -0,0 +1,6 @@
|
||||
---
|
||||
fixes:
|
||||
- |
|
||||
The ``introspection bulk status`` command no longer aborts if some nodes
|
||||
in the Ironic registry were never introspected. See bug `1689540
|
||||
<https://bugs.launchpad.net/tripleo/+bug/1689540>`_.
|
@ -79,7 +79,10 @@ class FakeInspectorClient(object):
|
||||
self.on_introspection.append(uuid)
|
||||
|
||||
def get_status(self, uuid):
|
||||
return self.states[uuid]
|
||||
try:
|
||||
return self.states[uuid]
|
||||
except KeyError:
|
||||
raise ironic_inspector_client.ClientError(mock.Mock())
|
||||
|
||||
def get_data(self, uuid):
|
||||
try:
|
||||
|
@ -717,6 +717,27 @@ class TestStatusBaremetalIntrospectionBulk(fakes.TestBaremetal):
|
||||
]
|
||||
))
|
||||
|
||||
def test_missing_nodes(self):
|
||||
client = self.app.client_manager.baremetal
|
||||
client.node.list.return_value = [
|
||||
mock.Mock(uuid="ABCDEFGH"),
|
||||
mock.Mock(uuid="IJKLMNOP"),
|
||||
mock.Mock(uuid="QRSTUVWX"),
|
||||
]
|
||||
inspector_client = self.app.client_manager.baremetal_introspection
|
||||
inspector_client.states['IJKLMNOP'] = {'finished': False,
|
||||
'error': None}
|
||||
|
||||
parsed_args = self.check_parser(self.cmd, [], [])
|
||||
result = self.cmd.take_action(parsed_args)
|
||||
|
||||
self.assertEqual(result, (
|
||||
('Node UUID', 'Finished', 'Error'),
|
||||
[
|
||||
('IJKLMNOP', False, None),
|
||||
]
|
||||
))
|
||||
|
||||
|
||||
class TestConfigureReadyState(fakes.TestBaremetal):
|
||||
|
||||
|
@ -21,6 +21,7 @@ import logging
|
||||
import time
|
||||
import uuid
|
||||
|
||||
import ironic_inspector_client
|
||||
from osc_lib.command import command
|
||||
from osc_lib.i18n import _
|
||||
|
||||
@ -267,8 +268,16 @@ class StatusBaremetalIntrospectionBulk(command.Lister):
|
||||
self.log.debug("Getting introspection status of Ironic node {0}"
|
||||
.format(node.uuid))
|
||||
|
||||
statuses.append((node.uuid,
|
||||
inspector_client.get_status(node.uuid)))
|
||||
try:
|
||||
status = inspector_client.get_status(node.uuid)
|
||||
except ironic_inspector_client.ClientError as exc:
|
||||
# This API returns an error when the node was never
|
||||
# introspected before. Exclude it from output in this case.
|
||||
self.log.debug('Introspection status for node %(node)s '
|
||||
'returned error %(exc)s',
|
||||
{'node': node.uuid, 'exc': exc})
|
||||
else:
|
||||
statuses.append((node.uuid, status))
|
||||
|
||||
return (
|
||||
("Node UUID", "Finished", "Error"),
|
||||
|
Loading…
Reference in New Issue
Block a user