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.
This commit is contained in:
Joshua Boniface 2022-11-15 15:45:59 -05:00
parent 095bcb2373
commit 38d63d9837
5 changed files with 40 additions and 40 deletions

View File

@ -1253,7 +1253,7 @@ class API_VM_Root(Resource):
{"name": "node"}, {"name": "node"},
{ {
"name": "selector", "name": "selector",
"choices": ("mem", "memfree", "vcpus", "load", "vms", "none"), "choices": ("mem", "memprov", "vcpus", "load", "vms", "none"),
"helptext": "A valid selector must be specified", "helptext": "A valid selector must be specified",
}, },
{"name": "autostart"}, {"name": "autostart"},
@ -1302,7 +1302,7 @@ class API_VM_Root(Resource):
default: none default: none
enum: enum:
- mem - mem
- memfree - memprov
- vcpus - vcpus
- load - load
- vms - vms
@ -1400,7 +1400,7 @@ class API_VM_Element(Resource):
{"name": "node"}, {"name": "node"},
{ {
"name": "selector", "name": "selector",
"choices": ("mem", "memfree", "vcpus", "load", "vms", "none"), "choices": ("mem", "memprov", "vcpus", "load", "vms", "none"),
"helptext": "A valid selector must be specified", "helptext": "A valid selector must be specified",
}, },
{"name": "autostart"}, {"name": "autostart"},
@ -1451,7 +1451,7 @@ class API_VM_Element(Resource):
default: none default: none
enum: enum:
- mem - mem
- memfree - memprov
- vcpus - vcpus
- load - load
- vms - vms
@ -1650,7 +1650,7 @@ class API_VM_Metadata(Resource):
{"name": "limit"}, {"name": "limit"},
{ {
"name": "selector", "name": "selector",
"choices": ("mem", "memfree", "vcpus", "load", "vms", "none"), "choices": ("mem", "memprov", "vcpus", "load", "vms", "none"),
"helptext": "A valid selector must be specified", "helptext": "A valid selector must be specified",
}, },
{"name": "autostart"}, {"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 description: The selector used to determine candidate nodes during migration; see 'target_selector' in the node daemon configuration reference
enum: enum:
- mem - mem
- memfree - memprov
- vcpus - vcpus
- load - load
- vms - vms

View File

@ -807,7 +807,7 @@ def cli_vm():
"node_selector", "node_selector",
default="none", default="none",
show_default=True, 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.', help='Method to determine optimal target node during autoselect; "none" will use the default for the cluster.',
) )
@click.option( @click.option(
@ -859,15 +859,15 @@ def vm_define(
Define a new virtual machine from Libvirt XML configuration file VMCONFIG. 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: 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 * "mem": choose the node with the most (real) free memory
* "memfree": 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 * "vcpus": choose the node with the least allocated VM vCPUs
* "load": choose the node with the lowest current load average * "load": choose the node with the lowest current load average
* "vms": choose the node with the least number of provisioned VMs * "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: 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. * "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.
* "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. * "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. * "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", "node_selector",
default=None, default=None,
show_default=False, 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.', help='Method to determine optimal target node during autoselect; "none" will use the default for the cluster.',
) )
@click.option( @click.option(
@ -4134,7 +4134,7 @@ def provisioner_template_system_list(limit):
"--node-selector", "--node-selector",
"node_selector", "node_selector",
type=click.Choice( type=click.Choice(
["mem", "memfree", "vcpus", "vms", "load", "none"], case_sensitive=False ["mem", "memprov", "vcpus", "vms", "load", "none"], case_sensitive=False
), ),
default="none", default="none",
help='Method to determine optimal target node during autoselect; "none" will use the default for the cluster.', 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",
"node_selector", "node_selector",
type=click.Choice( 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.', help='Method to determine optimal target node during autoselect; "none" will use the default for the cluster.',
) )

View File

@ -638,9 +638,9 @@ def findTargetNode(zkhandler, dom_uuid):
# Execute the search # Execute the search
if search_field == "mem": if search_field == "mem":
return findTargetNodeMem(zkhandler, node_limit, dom_uuid)
if search_field == "memfree":
return findTargetNodeMemFree(zkhandler, node_limit, dom_uuid) return findTargetNodeMemFree(zkhandler, node_limit, dom_uuid)
if search_field == "memprov":
return findTargetNodeMemProv(zkhandler, node_limit, dom_uuid)
if search_field == "load": if search_field == "load":
return findTargetNodeLoad(zkhandler, node_limit, dom_uuid) return findTargetNodeLoad(zkhandler, node_limit, dom_uuid)
if search_field == "vcpus": if search_field == "vcpus":
@ -678,10 +678,28 @@ def getNodes(zkhandler, node_limit, dom_uuid):
return valid_node_list 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 # via provisioned memory
# #
def findTargetNodeMem(zkhandler, node_limit, dom_uuid): def findTargetNodeMemProv(zkhandler, node_limit, dom_uuid):
most_provfree = 0 most_provfree = 0
target_node = None target_node = None
@ -700,24 +718,6 @@ def findTargetNodeMem(zkhandler, node_limit, dom_uuid):
return target_node 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 # via load average
# #

View File

@ -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. The default selector algorithm to use when migrating VMs away from a node; individual VMs can override this default.
Valid `target_selector` values are: Valid `target_selector` values are:
* `mem`: choose the node with the least provisioned VM memory * `mem`: choose the node with the most (real) free memory
* `memfree`: 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 * `vcpus`: choose the node with the least allocated VM vCPUs
* `load`: choose the node with the lowest current load average * `load`: choose the node with the lowest current load average
* `vms`: choose the node with the least number of provisioned VMs * `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: 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. * `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.
* `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. * `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. * `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` #### `system``configuration``directories``dynamic_directory`

View File

@ -122,7 +122,7 @@ pvc:
pass: Passw0rd pass: Passw0rd
# migration: Migration option configuration # migration: Migration option configuration
migration: 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 target_selector: mem
# configuration: Local system configurations # configuration: Local system configurations
configuration: configuration: