From 82fe2cb853b9c1360a7817648fddaa84afec3315 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Harald=20Jens=C3=A5s?= Date: Tue, 19 Jun 2018 17:35:52 +0200 Subject: [PATCH] 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 --- ironic/conductor/rpcapi.py | 4 ++++ ironic/tests/unit/conductor/test_rpcapi.py | 2 +- ...return-503-if-no-conductors-online-ead1512628182ec4.yaml | 6 ++++++ 3 files changed, 11 insertions(+), 1 deletion(-) create mode 100644 releasenotes/notes/story-2002600-return-503-if-no-conductors-online-ead1512628182ec4.yaml 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 `_.