summaryrefslogtreecommitdiff
path: root/ironic/common/nova.py
diff options
context:
space:
mode:
authorEric Fried <openstack@fried.cc>2019-12-10 09:19:18 -0600
committerEric Fried <openstack@fried.cc>2019-12-10 09:28:23 -0600
commit950acaaf17cf91f037b1c6b6289d125c6b8650f5 (patch)
tree69dd57ce6c7183f4781ae4bb4b7450ab4db6ea36 /ironic/common/nova.py
parent8a0b1a39f2723363287f989ed0df70523c3e1c20 (diff)
downloadironic-950acaaf17cf91f037b1c6b6289d125c6b8650f5.tar.gz
Update nova os-server-external-events response logic
When the power update was written [1] to use nova's os-server-external-events API, the internals of that method had a bug (see the related bug). Fortunately, the code was written so it works against the nova side with or without the fix. However, for the sake of propriety, this commit refactors the code to reflect nova's behavior more accurately. Specifically: Previously, it was impossible for nova to respond 207 when the client sent a single event (as ironic does). The code path accounting for that 207 existed, but always returned True ("success") rather than returning False ("failure") if the event code was >=400. Fortunately, the return value is only ever used in unit test, not production code, so it didn't matter. With this commit, the 207 path is handled correctly, such that the method "succeeds" if the event code is <400 (which would never happen in real life) and "fails" if the event code is >=400. [1] I6d105524e1645d9a40dfeae2850c33cf2d110826 Related-Bug: #1855752 Change-Id: I13744175127e9956fb785a9efc82193c333b2bdc
Diffstat (limited to 'ironic/common/nova.py')
-rw-r--r--ironic/common/nova.py5
1 files changed, 3 insertions, 2 deletions
diff --git a/ironic/common/nova.py b/ironic/common/nova.py
index d7d04d8ac..7fe11bbc6 100644
--- a/ironic/common/nova.py
+++ b/ironic/common/nova.py
@@ -82,8 +82,9 @@ def _send_event(context, event, api_version=None):
if code >= 400:
LOG.warning('Nova event: %s returned with failed status.', resp_event)
- else:
- LOG.debug('Nova event response: %s.', resp_event)
+ return False
+
+ LOG.debug('Nova event response: %s.', resp_event)
return True