From a2fd9afc7fa2c48e0e659a814054de75e06fd819 Mon Sep 17 00:00:00 2001 From: Guido Trotter Date: Tue, 8 Jul 2008 08:49:51 +0000 Subject: [PATCH] Add and remove instance/node locks Whenever we add an instance or node to the cluster (i.e. to the config and whenever we remove them we should add/remove locks as well). In the future we may want to optimize this so that the configwriter does it, or it's handled at the context level, but till we're adding/removing instances and nodes with the BGL held it doesn't matter too much. Reviewed-by: iustinp --- lib/cmdlib.py | 10 ++++++++++ 1 file changed, 10 insertions(+) diff --git a/lib/cmdlib.py b/lib/cmdlib.py index 9859c85..c339933 100644 --- a/lib/cmdlib.py +++ b/lib/cmdlib.py @@ -1246,6 +1246,8 @@ class LURemoveNode(LogicalUnit): logger.Info("Removing node %s from config" % node.name) self.cfg.RemoveNode(node.name) + # Remove the node from the Ganeti Lock Manager + self.context.glm.remove(locking.LEVEL_NODE, node.name) utils.RemoveHostFromEtcHosts(node.name) @@ -1624,6 +1626,8 @@ class LUAddNode(LogicalUnit): if not self.op.readd: logger.Info("adding node %s to cluster.conf" % node) self.cfg.AddNode(new_node) + # Add the new node to the Ganeti Lock Manager + self.context.glm.add(locking.LEVEL_NODE, node) class LUMasterFailover(LogicalUnit): @@ -2366,6 +2370,8 @@ class LURemoveInstance(LogicalUnit): logger.Info("removing instance %s out of cluster config" % instance.name) self.cfg.RemoveInstance(instance.name) + # Remove the new instance from the Ganeti Lock Manager + self.context.glm.remove(locking.LEVEL_INSTANCE, instance.name) class LUQueryInstances(NoHooksLU): @@ -3224,6 +3230,8 @@ class LUCreateInstance(LogicalUnit): feedback_fn("adding instance %s to cluster config" % instance) self.cfg.AddInstance(iobj) + # Add the new instance to the Ganeti Lock Manager + self.context.glm.add(locking.LEVEL_INSTANCE, instance) if self.op.wait_for_sync: disk_abort = not _WaitForSync(self.cfg, iobj, self.proc) @@ -3238,6 +3246,8 @@ class LUCreateInstance(LogicalUnit): if disk_abort: _RemoveDisks(iobj, self.cfg) self.cfg.RemoveInstance(iobj.name) + # Remove the new instance from the Ganeti Lock Manager + self.context.glm.remove(locking.LEVEL_INSTANCE, iobj.name) raise errors.OpExecError("There are some degraded disks for" " this instance") -- 1.7.10.4