Skip to content

Commit f7d1df8

Browse files
committed
Handle EndpointNotFound in nova notifier
Currently if the nova endpoint do not exist exception is raised. Even the endpoint gets created notification keeps on failing until the session expires. If the endpoint not exist the session is not useful so marking it as invalid, this will ensure if endpoint is created later the notification do not fail. Closes-Bug: #2081174 Change-Id: I1f7fd1d1371ca0a3c4edb409cffd2177d44a1f23 (cherry picked from commit 7d1a20e)
1 parent a956817 commit f7d1df8

File tree

2 files changed

+13
-0
lines changed

2 files changed

+13
-0
lines changed

neutron/notifiers/nova.py

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -281,6 +281,9 @@ def send_events(self, batched_events):
281281
try:
282282
response = novaclient.server_external_events.create(
283283
batched_events)
284+
except ks_exceptions.EndpointNotFound:
285+
LOG.exception("Nova endpoint not found, invalidating the session")
286+
self.session.invalidate()
284287
except nova_exceptions.NotFound:
285288
LOG.debug("Nova returned NotFound for event: %s",
286289
batched_events)

neutron/tests/unit/notifiers/test_nova.py

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -237,6 +237,16 @@ def test_no_notification_notify_nova_on_port_data_changes_false(self):
237237
{}, {})
238238
self.assertFalse(send_events.called)
239239

240+
@mock.patch('novaclient.client.Client')
241+
def test_nova_send_events_noendpoint_invalidate_session(self, mock_client):
242+
create = mock_client().server_external_events.create
243+
create.side_effect = ks_exc.EndpointNotFound
244+
with mock.patch.object(self.nova_notifier.session,
245+
'invalidate', return_value=True) as mock_sess:
246+
self.nova_notifier.send_events([])
247+
create.assert_called()
248+
mock_sess.assert_called()
249+
240250
@mock.patch('novaclient.client.Client')
241251
def test_nova_send_events_returns_bad_list(self, mock_client):
242252
create = mock_client().server_external_events.create

0 commit comments

Comments
 (0)