diff --git a/ironic/conductor/rpcapi.py b/ironic/conductor/rpcapi.py index 8b1262dc7b..1894690307 100644 --- a/ironic/conductor/rpcapi.py +++ b/ironic/conductor/rpcapi.py @@ -128,6 +128,10 @@ class ConductorAPI(object): """ self.ring_manager.reset() + # There are no conductors, temporary failure - 503 Service Unavailable + if not self.ring_manager.ring: + raise exception.TemporaryFailure() + try: ring = self.ring_manager[node.driver] dest = ring.get_nodes(node.uuid.encode('utf-8'), diff --git a/ironic/tests/unit/conductor/test_rpcapi.py b/ironic/tests/unit/conductor/test_rpcapi.py index 92e74313d4..d6364aa244 100644 --- a/ironic/tests/unit/conductor/test_rpcapi.py +++ b/ironic/tests/unit/conductor/test_rpcapi.py @@ -98,7 +98,7 @@ class RPCAPITestCase(db_base.DbTestCase): CONF.set_override('host', 'fake-host') rpcapi = conductor_rpcapi.ConductorAPI(topic='fake-topic') - self.assertRaises(exception.NoValidHost, + self.assertRaises(exception.TemporaryFailure, rpcapi.get_topic_for, self.fake_node_obj) diff --git a/releasenotes/notes/story-2002600-return-503-if-no-conductors-online-ead1512628182ec4.yaml b/releasenotes/notes/story-2002600-return-503-if-no-conductors-online-ead1512628182ec4.yaml new file mode 100644 index 0000000000..219a033112 --- /dev/null +++ b/releasenotes/notes/story-2002600-return-503-if-no-conductors-online-ead1512628182ec4.yaml @@ -0,0 +1,6 @@ +--- +fixes: + - | + Ironic API now returns ``503 Service Unavailable`` for action requiring a + conductor when no conductors are online. + `Bug: 2002600 `_.