Commit 4dfd6266 authored by Iustin Pop's avatar Iustin Pop
Browse files

Improve LUQueryNodes for lockless case

In most uses of LUQueryNodes, we don't take a lock. This means that the
instance data is not protected across GetInstanceList and
GetInstanceInfo, and this can lead to instances not existing anymore.

Switching to GetAllInstanceInfo means that we get a single,
semi-consistent snapshot (since instances can still be modified, but
it's much better).
Signed-off-by: default avatarIustin Pop <>
Reviewed-by: default avatarMichael Hanselmann <>
parent 77220dd2
......@@ -2083,10 +2083,9 @@ class LUQueryNodes(NoHooksLU):
inst_fields = frozenset(("pinst_cnt", "pinst_list",
"sinst_cnt", "sinst_list"))
if inst_fields & frozenset(self.op.output_fields):
instancelist = self.cfg.GetInstanceList()
inst_data = self.cfg.GetAllInstancesInfo()
for instance_name in instancelist:
inst = self.cfg.GetInstanceInfo(instance_name)
for instance_name, inst in inst_data.items():
if inst.primary_node in node_to_primary:
for secnode in inst.secondary_nodes:
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