From af797be5c6a552e5dc28063eae0f44bc6c099f6c Mon Sep 17 00:00:00 2001 From: Michael Hanselmann <hansmi@google.com> Date: Mon, 17 Dec 2012 16:51:27 +0100 Subject: [PATCH] _DeclareLocksForMigration: Fix non-DRBD locking issue MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit When non-DRBD disks are used for an instance, βlu.needed_locks[locking.LEVEL_NODE]β is set to βlocking.ALL_SETβ (which is None). The assertion will then fail as None evaluates to False. Reported by Constantinos Venetsanopoulos. Signed-off-by: Michael Hanselmann <hansmi@google.com> Reviewed-by: Guido Trotter <ultrotter@google.com> --- lib/cmdlib.py | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/lib/cmdlib.py b/lib/cmdlib.py index d84e41f8d..49617fd6e 100644 --- a/lib/cmdlib.py +++ b/lib/cmdlib.py @@ -7874,6 +7874,8 @@ def _DeclareLocksForMigration(lu, level): instance = lu.cfg.GetInstanceInfo(lu.op.instance_name) + # Node locks are already declared here rather than at LEVEL_NODE as we need + # the instance object anyway to declare the node allocation lock. if instance.disk_template in constants.DTS_EXT_MIRROR: if lu.op.target_node is None: lu.needed_locks[locking.LEVEL_NODE] = locking.ALL_SET @@ -7887,7 +7889,8 @@ def _DeclareLocksForMigration(lu, level): elif level == locking.LEVEL_NODE: # Node locks are declared together with the node allocation lock - assert lu.needed_locks[locking.LEVEL_NODE] + assert (lu.needed_locks[locking.LEVEL_NODE] or + lu.needed_locks[locking.LEVEL_NODE] is locking.ALL_SET) elif level == locking.LEVEL_NODE_RES: # Copy node locks -- GitLab