Handle API limit exception in nova_utils.refresh_server

novaclient raises an OverLimit exception when a 413 response code (API
limit) is returned from the Nova API.  Previously, this would cause the
stack action to fail.  Log a warning instead.

Change-Id: I52c9dc96b34d0645662d98aaeebb7dabe6956e25
Implements: blueprint improve-api-polling
This commit is contained in:
Jason Dunsmore 2014-02-06 15:30:36 -06:00 committed by Randall Burt
parent 593fe2ec05
commit 047e533fb1
2 changed files with 13 additions and 0 deletions

View File

@ -54,6 +54,12 @@ def refresh_server(server):
'''
try:
server.get()
except clients.novaclient.exceptions.OverLimit as exc:
msg = _("Server %(name)s (%(id)s) received an OverLimit "
"response during server.get(): %(exception)s")
logger.warning(msg % {'name': server.name,
'id': server.id,
'exception': str(exc)})
except clients.novaclient.exceptions.ClientException as exc:
if exc.code == 500:
msg = _('Server "%(name)s" (%(id)s) received the following '

View File

@ -14,6 +14,7 @@
# under the License.
"""Tests for :module:'heat.engine.resources.nova_utls'."""
import mock
import uuid
from heat.common import exception
@ -118,6 +119,12 @@ class NovaUtilsRefreshServerTests(HeatTestCase):
self.assertIsNone(nova_utils.refresh_server(server))
self.m.VerifyAll()
def test_overlimit_error(self):
server = mock.Mock()
server.get.side_effect = clients.novaclient.exceptions.OverLimit(
413, "limit reached")
self.assertIsNone(nova_utils.refresh_server(server))
def test_500_error(self):
server = self.m.CreateMockAnything()
msg = ("ClientException: The server has either erred or is "