Merge "Add missing headers to the inspection callback"
This commit is contained in:
commit
3e066e3f3e
@ -133,6 +133,13 @@ def call_inspector(data, failures):
|
|||||||
data = encoder.encode(data)
|
data = encoder.encode(data)
|
||||||
verify, cert = utils.get_ssl_client_options(CONF)
|
verify, cert = utils.get_ssl_client_options(CONF)
|
||||||
|
|
||||||
|
headers = {
|
||||||
|
'Content-Type': 'application/json',
|
||||||
|
'Accept': 'application/json',
|
||||||
|
}
|
||||||
|
if CONF.global_request_id:
|
||||||
|
headers["X-OpenStack-Request-ID"] = CONF.global_request_id
|
||||||
|
|
||||||
@tenacity.retry(
|
@tenacity.retry(
|
||||||
retry=tenacity.retry_if_exception_type(
|
retry=tenacity.retry_if_exception_type(
|
||||||
(requests.exceptions.ConnectionError,
|
(requests.exceptions.ConnectionError,
|
||||||
@ -143,7 +150,7 @@ def call_inspector(data, failures):
|
|||||||
reraise=True)
|
reraise=True)
|
||||||
def _post_to_inspector():
|
def _post_to_inspector():
|
||||||
inspector_resp = requests.post(
|
inspector_resp = requests.post(
|
||||||
CONF.inspection_callback_url, data=data,
|
CONF.inspection_callback_url, data=data, headers=headers,
|
||||||
verify=verify, cert=cert, timeout=CONF.http_request_timeout)
|
verify=verify, cert=cert, timeout=CONF.http_request_timeout)
|
||||||
if inspector_resp.status_code >= 500:
|
if inspector_resp.status_code >= 500:
|
||||||
raise requests.exceptions.HTTPError(response=inspector_resp)
|
raise requests.exceptions.HTTPError(response=inspector_resp)
|
||||||
|
@ -161,9 +161,11 @@ class TestCallInspector(base.IronicAgentTest):
|
|||||||
|
|
||||||
res = inspector.call_inspector(data, failures)
|
res = inspector.call_inspector(data, failures)
|
||||||
|
|
||||||
mock_post.assert_called_once_with('url',
|
mock_post.assert_called_once_with(
|
||||||
|
'url', data='{"data": 42, "error": null}',
|
||||||
cert=None, verify=True,
|
cert=None, verify=True,
|
||||||
data='{"data": 42, "error": null}',
|
headers={'Content-Type': 'application/json',
|
||||||
|
'Accept': 'application/json'},
|
||||||
timeout=30)
|
timeout=30)
|
||||||
self.assertEqual(mock_post.return_value.json.return_value, res)
|
self.assertEqual(mock_post.return_value.json.return_value, res)
|
||||||
|
|
||||||
@ -178,6 +180,7 @@ class TestCallInspector(base.IronicAgentTest):
|
|||||||
mock_post.assert_called_once_with('url',
|
mock_post.assert_called_once_with('url',
|
||||||
cert=None, verify=True,
|
cert=None, verify=True,
|
||||||
data='{"data": 42, "error": "boom"}',
|
data='{"data": 42, "error": "boom"}',
|
||||||
|
headers=mock.ANY,
|
||||||
timeout=30)
|
timeout=30)
|
||||||
self.assertEqual(mock_post.return_value.json.return_value, res)
|
self.assertEqual(mock_post.return_value.json.return_value, res)
|
||||||
|
|
||||||
@ -191,6 +194,7 @@ class TestCallInspector(base.IronicAgentTest):
|
|||||||
mock_post.assert_called_once_with('url',
|
mock_post.assert_called_once_with('url',
|
||||||
cert=None, verify=True,
|
cert=None, verify=True,
|
||||||
data='{"data": 42, "error": null}',
|
data='{"data": 42, "error": null}',
|
||||||
|
headers=mock.ANY,
|
||||||
timeout=30)
|
timeout=30)
|
||||||
self.assertIsNone(res)
|
self.assertIsNone(res)
|
||||||
|
|
||||||
@ -233,6 +237,7 @@ class TestCallInspector(base.IronicAgentTest):
|
|||||||
mock_post.assert_called_with('url',
|
mock_post.assert_called_with('url',
|
||||||
cert=None, verify=True,
|
cert=None, verify=True,
|
||||||
data='{"data": 42, "error": null}',
|
data='{"data": 42, "error": null}',
|
||||||
|
headers=mock.ANY,
|
||||||
timeout=30)
|
timeout=30)
|
||||||
|
|
||||||
|
|
||||||
|
6
releasenotes/notes/content-type-f4d5ab15adf37252.yaml
Normal file
6
releasenotes/notes/content-type-f4d5ab15adf37252.yaml
Normal file
@ -0,0 +1,6 @@
|
|||||||
|
---
|
||||||
|
fixes:
|
||||||
|
- |
|
||||||
|
Fixes missing ``Content-Type`` header when sending inspection data back
|
||||||
|
to ironic-inspector or ironic. While ironic-inspector tolerates the
|
||||||
|
missing header, it may cause issues with the new inspection implementation.
|
Loading…
Reference in New Issue
Block a user