Remove 'agent_last_heartbeat' from node.driver_internal_info
node.driver_internal_info['agent_last_heartbeat'] was not being used by ironic, and Ic198f6a952ed135099bcc525ef548a4aea005056 removed the code that sets that value. However, for existing nodes, driver_internal_info['agent_last_heartbeat'] may already exist, so we need to delete it. This patch does that. In addition, a LOG line was moved (and a nit addressed) to make the code a bit easier to read. This is a followup to Ic198f6a952ed135099bcc525ef548a4aea005056. Change-Id: I194d22c0e605b187823ceebae94d3ef895fb91f5 Related-Bug: #1602410
This commit is contained in:
parent
e05e060964
commit
128c025fc1
@ -450,10 +450,17 @@ class AgentDeployMixin(object):
|
||||
task.upgrade_lock()
|
||||
|
||||
node = task.node
|
||||
LOG.debug('Heartbeat from node %s', node.uuid)
|
||||
|
||||
driver_internal_info = node.driver_internal_info
|
||||
LOG.debug('Heartbeat from node %s' % node.uuid)
|
||||
driver_internal_info['agent_url'] = callback_url
|
||||
|
||||
# TODO(rloo): 'agent_last_heartbeat' was deprecated since it wasn't
|
||||
# being used so remove that entry if it exists.
|
||||
# Hopefully all nodes will have been updated by Pike, so
|
||||
# we can delete this code then.
|
||||
driver_internal_info.pop('agent_last_heartbeat', None)
|
||||
|
||||
node.driver_internal_info = driver_internal_info
|
||||
node.save()
|
||||
|
||||
|
@ -551,6 +551,31 @@ class TestHeartbeat(AgentDeployMixinBaseTest):
|
||||
mock_continue.assert_called_once_with(mock.ANY, task)
|
||||
self.assertFalse(mock_handler.called)
|
||||
|
||||
@mock.patch.object(agent_base_vendor.AgentDeployMixin, 'continue_deploy',
|
||||
autospec=True)
|
||||
@mock.patch.object(agent_base_vendor.AgentDeployMixin,
|
||||
'reboot_to_instance', autospec=True)
|
||||
@mock.patch.object(agent_base_vendor, '_notify_conductor_resume_clean',
|
||||
autospec=True)
|
||||
def test_heartbeat_no_agent_last_heartbeat(self, ncrc_mock, rti_mock,
|
||||
cd_mock):
|
||||
"""node.driver_internal_info doesn't have 'agent_last_heartbeat'."""
|
||||
node = self.node
|
||||
node.maintenance = True
|
||||
node.provision_state = states.AVAILABLE
|
||||
driver_internal_info = {'agent_last_heartbeat': 'time'}
|
||||
node.driver_internal_info = driver_internal_info
|
||||
node.save()
|
||||
with task_manager.acquire(
|
||||
self.context, node['uuid'], shared=False) as task:
|
||||
self.deploy.heartbeat(task, 'http://127.0.0.1:8080')
|
||||
|
||||
self.assertEqual(0, ncrc_mock.call_count)
|
||||
self.assertEqual(0, rti_mock.call_count)
|
||||
self.assertEqual(0, cd_mock.call_count)
|
||||
node.refresh()
|
||||
self.assertNotIn('agent_last_heartbeat', node.driver_internal_info)
|
||||
|
||||
@mock.patch.object(agent_base_vendor.AgentDeployMixin, 'continue_deploy',
|
||||
autospec=True)
|
||||
@mock.patch.object(agent_base_vendor.AgentDeployMixin,
|
||||
|
Loading…
x
Reference in New Issue
Block a user