From f8cdcb30ba9512d606b1f0c14f4c344f2ed4c53b Mon Sep 17 00:00:00 2001 From: "Joshua M. Boniface" Date: Wed, 18 May 2022 03:47:16 -0400 Subject: [PATCH] Add migration selector via free memory Closes #152 --- daemon-common/common.py | 22 +++++++++++++++++++++- node-daemon/pvcnoded.sample.yaml | 2 +- 2 files changed, 22 insertions(+), 2 deletions(-) diff --git a/daemon-common/common.py b/daemon-common/common.py index 13a2bb50..6b8aa6b0 100644 --- a/daemon-common/common.py +++ b/daemon-common/common.py @@ -639,6 +639,8 @@ def findTargetNode(zkhandler, dom_uuid): # Execute the search if search_field == "mem": return findTargetNodeMem(zkhandler, node_limit, dom_uuid) + if search_field == "memfree": + return findTargetNodeMemFree(zkhandler, node_limit, dom_uuid) if search_field == "load": return findTargetNodeLoad(zkhandler, node_limit, dom_uuid) if search_field == "vcpus": @@ -677,7 +679,7 @@ def getNodes(zkhandler, node_limit, dom_uuid): # -# via free memory (relative to allocated memory) +# via allocated memory # def findTargetNodeMem(zkhandler, node_limit, dom_uuid): most_provfree = 0 @@ -698,6 +700,24 @@ def findTargetNodeMem(zkhandler, node_limit, dom_uuid): return target_node +# +# via free memory +# +def findTargetNodeMemFree(zkhandler, node_limit, dom_uuid): + most_memfree = 0 + target_node = None + + node_list = getNodes(zkhandler, node_limit, dom_uuid) + for node in node_list: + memfree = int(zkhandler.read(("node.memory.free", node))) + + if memfree > most_memfree: + most_memfree = memfree + target_node = node + + return target_node + + # # via load average # diff --git a/node-daemon/pvcnoded.sample.yaml b/node-daemon/pvcnoded.sample.yaml index 4b08206a..6024af40 100644 --- a/node-daemon/pvcnoded.sample.yaml +++ b/node-daemon/pvcnoded.sample.yaml @@ -122,7 +122,7 @@ pvc: pass: Passw0rd # migration: Migration option configuration migration: - # target_selector: Criteria to select the ideal migration target, options: mem, load, vcpus, vms + # target_selector: Criteria to select the ideal migration target, options: mem, memfree, load, vcpus, vms target_selector: mem # configuration: Local system configurations configuration: