Don't mark an agent as alive if rebooted
If 'agent_url' has been cleared from internal_info it indicates that the node has been powered off. Change-Id: Idba486c98e1e92d35fca2e2d156866566acb9e40 Story: 2008583 Task: 41736
This commit is contained in:
parent
4a7d50ce56
commit
4287951d71
@ -1042,6 +1042,11 @@ def agent_is_alive(node, timeout=None):
|
||||
:param node: A node object.
|
||||
:param timeout: Heartbeat timeout, defaults to `fast_track_timeout`.
|
||||
"""
|
||||
# If no agent_url is present then we have powered down since the
|
||||
# last agent heartbeat
|
||||
if not node.driver_internal_info.get('agent_url'):
|
||||
return False
|
||||
|
||||
return value_within_timeout(
|
||||
node.driver_internal_info.get('agent_last_heartbeat'),
|
||||
timeout or CONF.deploy.fast_track_timeout)
|
||||
|
@ -1934,7 +1934,8 @@ class FastTrackTestCase(db_base.DbTestCase):
|
||||
self.context, driver='fake-hardware',
|
||||
uuid=uuidutils.generate_uuid(),
|
||||
driver_internal_info={
|
||||
'agent_last_heartbeat': str(timeutils.utcnow().isoformat())})
|
||||
'agent_last_heartbeat': str(timeutils.utcnow().isoformat()),
|
||||
'agent_url': 'a_url'})
|
||||
self.config(fast_track=True, group='deploy')
|
||||
|
||||
def test_is_fast_track(self, mock_get_power):
|
||||
@ -1966,6 +1967,14 @@ class FastTrackTestCase(db_base.DbTestCase):
|
||||
self.context, self.node.uuid, shared=False) as task:
|
||||
self.assertFalse(conductor_utils.is_fast_track(task))
|
||||
|
||||
def test_is_fast_track_powered_after_heartbeat(self, mock_get_power):
|
||||
mock_get_power.return_value = states.POWER_ON
|
||||
with task_manager.acquire(
|
||||
self.context, self.node.uuid, shared=False) as task:
|
||||
conductor_utils.node_power_action(task, states.POWER_OFF)
|
||||
conductor_utils.node_power_action(task, states.POWER_ON)
|
||||
self.assertFalse(conductor_utils.is_fast_track(task))
|
||||
|
||||
def test_is_fast_track_error_blocks(self, mock_get_power):
|
||||
mock_get_power.return_value = states.POWER_ON
|
||||
self.node.last_error = "bad things happened"
|
||||
|
6
releasenotes/notes/agent-rebooted-fab20d012fe6cbe8.yaml
Normal file
6
releasenotes/notes/agent-rebooted-fab20d012fe6cbe8.yaml
Normal file
@ -0,0 +1,6 @@
|
||||
---
|
||||
fixes:
|
||||
- |
|
||||
Fixes fast-track to prevent marking the agent as alive if
|
||||
trying to rebuild a node before the fast-track timeout has
|
||||
expired.
|
Loading…
Reference in New Issue
Block a user