Handle 503 response from Nova API

The stack fails when Nova responds with a 503 during a
create/update/delete.  503 (Service Unavailable) is an intermittent,
non-critical error and should be handled the same way OverLimit and 500
errors are being handled.

Change-Id: Iadc3b39d099fcc7870764b7a42c5edee41c527dc
Closes-Bug: #1289549
This commit is contained in:
Jason Dunsmore 2014-03-07 13:38:46 -06:00
parent 0826fc311a
commit 2516c4413e
2 changed files with 12 additions and 1 deletions

View File

@ -60,7 +60,7 @@ def refresh_server(server):
'id': server.id,
'exception': str(exc)})
except clients.novaclient.exceptions.ClientException as exc:
if exc.code == 500:
if exc.code in (500, 503):
msg = _('Server "%(name)s" (%(id)s) received the following '
'exception during server.get(): %(exception)s')
logger.warning(msg % {'name': server.name,

View File

@ -135,6 +135,17 @@ class NovaUtilsRefreshServerTests(HeatTestCase):
self.assertIsNone(nova_utils.refresh_server(server))
self.m.VerifyAll()
def test_503_error(self):
server = self.m.CreateMockAnything()
msg = ("ClientException: The server has either erred or is "
"incapable of performing the requested operation.")
server.get().AndRaise(
clients.novaclient.exceptions.ClientException(503, msg))
self.m.ReplayAll()
self.assertIsNone(nova_utils.refresh_server(server))
self.m.VerifyAll()
def test_unhandled_exception(self):
server = self.m.CreateMockAnything()
msg = ("ClientException: The server has either erred or is "