Adds the ability to automatically issue a hard reboot to instances that have been stuck in a 'rebooting' state for longer than a specified window.
Fixes bug 873099. Change-Id: Ife2c64326fdb3ec849242583d1bd1d96f9f4be0f
This commit is contained in:
parent
7106eb8f5c
commit
f60d3eff5c
@ -585,6 +585,12 @@ def instance_get_project_vpn(context, project_id):
|
||||
return IMPL.instance_get_project_vpn(context, project_id)
|
||||
|
||||
|
||||
def instance_get_all_hung_in_rebooting(context, reboot_window, session=None):
|
||||
"""Get all instances stuck in a rebooting state."""
|
||||
return IMPL.instance_get_all_hung_in_rebooting(context, reboot_window,
|
||||
session)
|
||||
|
||||
|
||||
def instance_set_state(context, instance_id, state, description=None):
|
||||
"""Set the state of an instance."""
|
||||
return IMPL.instance_set_state(context, instance_id, state, description)
|
||||
|
@ -1529,6 +1529,21 @@ def instance_get_floating_address(context, instance_id):
|
||||
return fixed_ip_refs[0].floating_ips[0]['address']
|
||||
|
||||
|
||||
@require_admin_context
|
||||
def instance_get_all_hung_in_rebooting(context, reboot_window, session=None):
|
||||
reboot_window = datetime.datetime.utcnow() - datetime.timedelta(
|
||||
seconds=reboot_window)
|
||||
|
||||
if not session:
|
||||
session = get_session()
|
||||
|
||||
results = session.query(models.Instance).\
|
||||
filter(models.Instance.updated_at <= reboot_window).\
|
||||
filter_by(task_state="rebooting").all()
|
||||
|
||||
return results
|
||||
|
||||
|
||||
@require_context
|
||||
def instance_update(context, instance_id, values):
|
||||
session = get_session()
|
||||
|
Loading…
x
Reference in New Issue
Block a user