Skip to content
Snippets Groups Projects
Commit f28ec899 authored by Guido Trotter's avatar Guido Trotter
Browse files

Add CleanupInstance hypervisor call


Currently some hypervisors (namely kvm) need to do some cleanup after
making sure an instance is stopped. With the moving of the retry cycle
in backend those cleanups were never done. In order to solve this we add
a new optional hypervisor function, CleanupInstance, which gets called
at the end of the shutdown procedure, and which interested hypervisors
can implement to be sure not to miss cleanup operations.

Signed-off-by: default avatarGuido Trotter <ultrotter@google.com>
Reviewed-by: default avatarIustin Pop <iustin@google.com>
parent d8aab233
No related branches found
No related tags found
No related merge requests found
...@@ -1099,6 +1099,11 @@ def InstanceShutdown(instance, timeout): ...@@ -1099,6 +1099,11 @@ def InstanceShutdown(instance, timeout):
if iname in hyper.ListInstances(): if iname in hyper.ListInstances():
_Fail("Could not shutdown instance %s even by destroy", iname) _Fail("Could not shutdown instance %s even by destroy", iname)
try:
hyper.CleanupInstance(instance.name)
except errors.HypervisorError, err:
logging.warning("Failed to execute post-shutdown cleanup step: %s", err)
_RemoveBlockDevLinks(iname, instance.disks) _RemoveBlockDevLinks(iname, instance.disks)
......
...@@ -130,6 +130,18 @@ class BaseHypervisor(object): ...@@ -130,6 +130,18 @@ class BaseHypervisor(object):
""" """
raise NotImplementedError raise NotImplementedError
def CleanupInstance(self, instance_name):
"""Cleanup after a stopped instance
This is an optional method, used by hypervisors that need to cleanup after
an instance has been stopped.
@type instance_name: string
@param instance_name: instance name to cleanup after
"""
pass
def RebootInstance(self, instance): def RebootInstance(self, instance):
"""Reboot an instance.""" """Reboot an instance."""
raise NotImplementedError raise NotImplementedError
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment