From 38d63d9837068b37730c9e6502092e88b9c26bf0 Mon Sep 17 00:00:00 2001 From: "Joshua M. Boniface" Date: Tue, 15 Nov 2022 15:45:59 -0500 Subject: [PATCH] Flip behaviour of memory selectors It didn't make any sense to me for mem(prov) to be the default selector, since this has too many caveats versus mem(free). Switch to using mem(free) as the default (i.e. "mem") and make memprov the alternative. --- api-daemon/pvcapid/flaskapi.py | 12 ++++----- client-cli/pvc/pvc.py | 16 ++++++------ daemon-common/common.py | 42 ++++++++++++++++---------------- docs/manuals/daemon.md | 8 +++--- node-daemon/pvcnoded.sample.yaml | 2 +- 5 files changed, 40 insertions(+), 40 deletions(-) diff --git a/api-daemon/pvcapid/flaskapi.py b/api-daemon/pvcapid/flaskapi.py index d7c93225..1628a080 100755 --- a/api-daemon/pvcapid/flaskapi.py +++ b/api-daemon/pvcapid/flaskapi.py @@ -1253,7 +1253,7 @@ class API_VM_Root(Resource): {"name": "node"}, { "name": "selector", - "choices": ("mem", "memfree", "vcpus", "load", "vms", "none"), + "choices": ("mem", "memprov", "vcpus", "load", "vms", "none"), "helptext": "A valid selector must be specified", }, {"name": "autostart"}, @@ -1302,7 +1302,7 @@ class API_VM_Root(Resource): default: none enum: - mem - - memfree + - memprov - vcpus - load - vms @@ -1400,7 +1400,7 @@ class API_VM_Element(Resource): {"name": "node"}, { "name": "selector", - "choices": ("mem", "memfree", "vcpus", "load", "vms", "none"), + "choices": ("mem", "memprov", "vcpus", "load", "vms", "none"), "helptext": "A valid selector must be specified", }, {"name": "autostart"}, @@ -1451,7 +1451,7 @@ class API_VM_Element(Resource): default: none enum: - mem - - memfree + - memprov - vcpus - load - vms @@ -1650,7 +1650,7 @@ class API_VM_Metadata(Resource): {"name": "limit"}, { "name": "selector", - "choices": ("mem", "memfree", "vcpus", "load", "vms", "none"), + "choices": ("mem", "memprov", "vcpus", "load", "vms", "none"), "helptext": "A valid selector must be specified", }, {"name": "autostart"}, @@ -1682,7 +1682,7 @@ class API_VM_Metadata(Resource): description: The selector used to determine candidate nodes during migration; see 'target_selector' in the node daemon configuration reference enum: - mem - - memfree + - memprov - vcpus - load - vms diff --git a/client-cli/pvc/pvc.py b/client-cli/pvc/pvc.py index 9d9b3768..ec13fa9e 100755 --- a/client-cli/pvc/pvc.py +++ b/client-cli/pvc/pvc.py @@ -807,7 +807,7 @@ def cli_vm(): "node_selector", default="none", show_default=True, - type=click.Choice(["mem", "memfree", "load", "vcpus", "vms", "none"]), + type=click.Choice(["mem", "memprov", "load", "vcpus", "vms", "none"]), help='Method to determine optimal target node during autoselect; "none" will use the default for the cluster.', ) @click.option( @@ -859,15 +859,15 @@ def vm_define( Define a new virtual machine from Libvirt XML configuration file VMCONFIG. The target node selector ("--node-selector"/"-s") can be "none" to use the cluster default, or one of the following values: - * "mem": choose the node with the least provisioned VM memory - * "memfree": choose the node with the most (real) free memory + * "mem": choose the node with the most (real) free memory + * "memprov": choose the node with the least provisioned VM memory * "vcpus": choose the node with the least allocated VM vCPUs * "load": choose the node with the lowest current load average * "vms": choose the node with the least number of provisioned VMs For most clusters, "mem" should be sufficient, but others may be used based on the cluster workload and available resources. The following caveats should be considered: - * "mem" looks at the provisioned memory, not the allocated memory; thus, stopped or disabled VMs are counted towards a node's memory for this selector, even though their memory is not actively in use. - * "memfree" looks at the free memory of the node in general, ignoring the amount provisioned to VMs; if any VM's internal memory usage changes, this value would be affected. This might be preferable to "mem" on clusters with very high memory utilization versus total capacity or if many VMs are stopped/disabled. + * "mem" looks at the free memory of the node in general, ignoring the amount provisioned to VMs; if any VM's internal memory usage changes, this value would be affected. + * "memprov" looks at the provisioned memory, not the allocated memory; thus, stopped or disabled VMs are counted towards a node's memory for this selector, even though their memory is not actively in use. * "load" looks at the system load of the node in general, ignoring load in any particular VMs; if any VM's CPU usage changes, this value would be affected. This might be preferable on clusters with some very CPU intensive VMs. """ @@ -914,7 +914,7 @@ def vm_define( "node_selector", default=None, show_default=False, - type=click.Choice(["mem", "memfree", "load", "vcpus", "vms", "none"]), + type=click.Choice(["mem", "memprov", "load", "vcpus", "vms", "none"]), help='Method to determine optimal target node during autoselect; "none" will use the default for the cluster.', ) @click.option( @@ -4134,7 +4134,7 @@ def provisioner_template_system_list(limit): "--node-selector", "node_selector", type=click.Choice( - ["mem", "memfree", "vcpus", "vms", "load", "none"], case_sensitive=False + ["mem", "memprov", "vcpus", "vms", "load", "none"], case_sensitive=False ), default="none", help='Method to determine optimal target node during autoselect; "none" will use the default for the cluster.', @@ -4230,7 +4230,7 @@ def provisioner_template_system_add( "--node-selector", "node_selector", type=click.Choice( - ["mem", "memfree", "vcpus", "vms", "load", "none"], case_sensitive=False + ["mem", "memprov", "vcpus", "vms", "load", "none"], case_sensitive=False ), help='Method to determine optimal target node during autoselect; "none" will use the default for the cluster.', ) diff --git a/daemon-common/common.py b/daemon-common/common.py index d193871e..95d9eb92 100644 --- a/daemon-common/common.py +++ b/daemon-common/common.py @@ -638,9 +638,9 @@ 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 == "memprov": + return findTargetNodeMemProv(zkhandler, node_limit, dom_uuid) if search_field == "load": return findTargetNodeLoad(zkhandler, node_limit, dom_uuid) if search_field == "vcpus": @@ -678,10 +678,28 @@ def getNodes(zkhandler, node_limit, dom_uuid): return valid_node_list +# +# 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 provisioned memory # -def findTargetNodeMem(zkhandler, node_limit, dom_uuid): +def findTargetNodeMemProv(zkhandler, node_limit, dom_uuid): most_provfree = 0 target_node = None @@ -700,24 +718,6 @@ 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/docs/manuals/daemon.md b/docs/manuals/daemon.md index 2e439a13..69732491 100644 --- a/docs/manuals/daemon.md +++ b/docs/manuals/daemon.md @@ -356,15 +356,15 @@ The password for the PVC node daemon to log in to the IPMI interface. The default selector algorithm to use when migrating VMs away from a node; individual VMs can override this default. Valid `target_selector` values are: - * `mem`: choose the node with the least provisioned VM memory - * `memfree`: choose the node with the most (real) free memory + * `mem`: choose the node with the most (real) free memory + * `memprov`: choose the node with the least provisioned VM memory * `vcpus`: choose the node with the least allocated VM vCPUs * `load`: choose the node with the lowest current load average * `vms`: choose the node with the least number of provisioned VMs For most clusters, `mem` should be sufficient, but others may be used based on the cluster workload and available resources. The following caveats should be considered: - * `mem` looks at the provisioned memory, not the allocated memory; thus, stopped or disabled VMs are counted towards a node's memory for this selector, even though their memory is not actively in use. - * `memfree` looks at the free memory of the node in general, ignoring the amount provisioned to VMs; if any VM's internal memory usage changes, this value would be affected. This might be preferable to `mem` on clusters with very high memory utilization versus total capacity or if many VMs are stopped/disabled. + * `mem` looks at the free memory of the node in general, ignoring the amount provisioned to VMs; if any VM's internal memory usage changes, this value would be affected. + * `memprov` looks at the provisioned memory, not the allocated memory; thus, stopped or disabled VMs are counted towards a node's memory for this selector, even though their memory is not actively in use. * `load` looks at the system load of the node in general, ignoring load in any particular VMs; if any VM's CPU usage changes, this value would be affected. This might be preferable on clusters with some very CPU intensive VMs. #### `system` → `configuration` → `directories` → `dynamic_directory` diff --git a/node-daemon/pvcnoded.sample.yaml b/node-daemon/pvcnoded.sample.yaml index 6024af40..de22a69d 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, memfree, load, vcpus, vms + # target_selector: Criteria to select the ideal migration target, options: mem, memprov, load, vcpus, vms target_selector: mem # configuration: Local system configurations configuration: