Commit 140aa4a8 authored by Iustin Pop's avatar Iustin Pop
Browse files

Fix cluster destroy

With the recent startup/shutdown changes (and with the master daemon in
place), the cluster destroy needs some fixing.

This patch moves the finalization of the destroy out from cmdlib into
bootstrap, so we can nicely shutdown the rapi and master daemons.

Reviewed-by: ultrotter
parent 97efde45
......@@ -230,6 +230,19 @@ def InitCluster(cluster_name, hypervisor_type, mac_prefix, def_bridge,
rpc.call_node_start_master(hostname.name, True)
def FinalizeClusterDestroy(master):
"""Execute the last steps of cluster destroy
This function shuts down all the daemons, completing the destroy
begun in cmdlib.LUDestroyOpcode.
"""
if not rpc.call_node_stop_master(master, True):
logging.warning("Could not disable the master role")
if not rpc.call_node_leave_cluster(master):
logging.warning("Could not shutdown the node daemon and cleanup the node")
def SetupNodeDaemon(node):
"""Add a node to the cluster.
......
......@@ -481,7 +481,7 @@ class LUDestroyCluster(NoHooksLU):
priv_key, pub_key, _ = ssh.GetUserFiles(constants.GANETI_RUNAS)
utils.CreateBackup(priv_key)
utils.CreateBackup(pub_key)
rpc.call_node_leave_cluster(master)
return master
class LUVerifyCluster(LogicalUnit):
......
......@@ -74,7 +74,10 @@ def DestroyCluster(opts, args):
return 1
op = opcodes.OpDestroyCluster()
SubmitOpCode(op)
master = SubmitOpCode(op)
# if we reached this, the opcode didn't fail; we can proceed to
# shutdown all the daemons
bootstrap.FinalizeClusterDestroy(master)
return 0
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment