Raise TemporaryFailure if no conductors are online

Return 503 Service Unavailable error in case no conductors
are online. This indicate to the caller that it can retry
the operation. (Previously a 400 error was returned,
which is confusing because it is not a user error.)

Story: 2002600
Task:  22214
Change-Id: I2c21baaec2e35c0a63f3f4a95990b12c6a836065
This commit is contained in:
Harald Jensås 2018-06-19 17:35:52 +02:00
parent fbc74b7924
commit 82fe2cb853
3 changed files with 11 additions and 1 deletions

View File

@ -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'),

View File

@ -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)

View File

@ -0,0 +1,6 @@
---
fixes:
- |
Ironic API now returns ``503 Service Unavailable`` for action requiring a
conductor when no conductors are online.
`Bug: 2002600 <https://storyboard.openstack.org/#!/story/2002600>`_.