Fix anaconda boot interface

Change I45ee1c8a73ed13511bc47a69130105f16d34be1e inadvertently broke
the anaconda deploy interface because it sends an empty callback url.

Seems valid enough in that case, it is now handled.

Change-Id: Ife6fa3469ee6eb0663b4af63197deab96ed6aa1e
This commit is contained in:
Julia Kreger 2024-07-08 21:08:21 -07:00
parent 111466f782
commit 74113c41e4
2 changed files with 21 additions and 4 deletions
ironic
api/controllers/v1
tests/unit/api/controllers/v1

@ -236,10 +236,12 @@ class HeartbeatController(rest.RestController):
raise ValueError
callback_url = parsed_url.geturl()
except ValueError:
raise exception.InvalidParameterValue(
_('An issue with the supplied "callback_url" has been '
'detected.'))
if callback_url != "":
# Anaconda deploy interface sends a empty callback url, since
# it is a one way heartbeat.
raise exception.InvalidParameterValue(
_('An issue with the supplied "callback_url" has been '
'detected.'))
# If we have an agent_url on file, and we get something different
# we should fail because this is unexpected behavior of the agent.
if agent_url is not None and agent_url != callback_url:

@ -246,6 +246,21 @@ class TestHeartbeat(test_api_base.BaseApiTest):
'x', None, None, None,
topic='test-topic')
@mock.patch.object(rpcapi.ConductorAPI, 'heartbeat', autospec=True)
def test_ok_for_anaconda(self, mock_heartbeat):
node = obj_utils.create_test_node(self.context)
response = self.post_json(
'/heartbeat/%s' % node.uuid,
{'callback_url': '',
'agent_token': 'x'},
headers={api_base.Version.string: str(api_v1.max_version())})
self.assertEqual(http_client.ACCEPTED, response.status_int)
self.assertEqual(b'', response.body)
mock_heartbeat.assert_called_once_with(mock.ANY, mock.ANY,
node.uuid, '', None,
'x', None, None, None,
topic='test-topic')
@mock.patch.object(rpcapi.ConductorAPI, 'heartbeat', autospec=True)
def test_ok_with_json(self, mock_heartbeat):
headers = {api_base.Version.string: '1.90'}