Commit 18640d69 authored by Guido Trotter's avatar Guido Trotter
Browse files

IAllocator: subtract down instances from free mem

Currently free_memory just reports the amount of free ram, as seen by the
hypervisor. We adjust this amount by subtracting the memory for any instance
which is down, and the difference for any instance which is configured to have
more memory than the amount it's currently running at.

Reviewed-by: iustinp
parent 955db481
......@@ -5378,6 +5378,8 @@ class IAllocator(object):
node_data =, cfg.GetVGName(),
node_iinfo =,
for nname in node_list:
ninfo = cfg.GetNodeInfo(nname)
if nname not in node_data or not isinstance(node_data[nname], dict):
......@@ -5398,6 +5400,13 @@ class IAllocator(object):
for iinfo, beinfo in i_list:
if iinfo.primary_node == nname:
i_p_mem += beinfo[constants.BE_MEMORY]
if not in node_iinfo[nname]:
i_used_mem = 0
i_used_mem = int(node_iinfo[nname][]['memory'])
i_mem_diff = beinfo[constants.BE_MEMORY] - i_used_mem
remote_info['memory_free'] -= max(0, i_mem_diff)
if iinfo.status == "up":
i_p_up_mem += beinfo[constants.BE_MEMORY]
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