Merge "Improve Filter Scheduler doc clarity"
This commit is contained in:
commit
a1ae9997b6
@ -3,33 +3,35 @@ Filter Scheduler
|
|||||||
|
|
||||||
The **Filter Scheduler** supports `filtering` and `weighting` to make informed
|
The **Filter Scheduler** supports `filtering` and `weighting` to make informed
|
||||||
decisions on where a new instance should be created. This Scheduler supports
|
decisions on where a new instance should be created. This Scheduler supports
|
||||||
only working with Compute Nodes.
|
working with Compute Nodes only.
|
||||||
|
|
||||||
Filtering
|
Filtering
|
||||||
---------
|
---------
|
||||||
|
|
||||||
.. image:: ./images/filteringWorkflow1.png
|
.. image:: ./images/filteringWorkflow1.png
|
||||||
|
|
||||||
During its work Filter Scheduler firstly makes dictionary of unfiltered hosts,
|
During its work Filter Scheduler iterates over all found compute nodes,
|
||||||
then filters them using filter properties and finally chooses hosts for the
|
evaluating each against a set of filters. The list of resulting hosts is
|
||||||
requested number of instances (each time it chooses the most weighed host and
|
ordered by weighers. The Scheduler then chooses hosts for the requested
|
||||||
appends it to the list of selected hosts).
|
number of instances, choosing the most weighted hosts. For a specific
|
||||||
|
filter to succeed for a specific host, the filter matches the user
|
||||||
|
request against the state of the host plus some extra magic as defined
|
||||||
|
by each filter (described in more detail below).
|
||||||
|
|
||||||
If it turns up, that it can't find candidates for the next instance, it means
|
If the Scheduler cannot find candidates for the next instance, it means that
|
||||||
that there are no more appropriate hosts where the instance could be scheduled.
|
there are no appropriate hosts where that instance can be scheduled.
|
||||||
|
|
||||||
If we speak about `filtering` and `weighting`, their work is quite flexible
|
The Filter Scheduler has to be quite flexible to support the required variety
|
||||||
in the Filter Scheduler. There are a lot of filtering strategies for the
|
of `filtering` and `weighting` strategies. If this flexibility is insufficient
|
||||||
Scheduler to support. Also you can even implement `your own algorithm of
|
you can implement `your own filtering algorithm`.
|
||||||
filtering`.
|
|
||||||
|
|
||||||
There are some standard filter classes to use (:mod:`nova.scheduler.filters`):
|
There are many standard filter classes which may be used
|
||||||
|
(:mod:`nova.scheduler.filters`):
|
||||||
|
|
||||||
* |AllHostsFilter| - frankly speaking, this filter does no operation. It
|
* |AllHostsFilter| - does no filtering. It passes all the available hosts.
|
||||||
passes all the available hosts.
|
|
||||||
* |ImagePropertiesFilter| - filters hosts based on properties defined
|
* |ImagePropertiesFilter| - filters hosts based on properties defined
|
||||||
on the instance's image. It passes hosts that can support the specified
|
on the instance's image. It passes hosts that can support the properties
|
||||||
image properties contained in the instance.
|
specified on the image used by the instance.
|
||||||
* |AvailabilityZoneFilter| - filters hosts by availability zone. It passes
|
* |AvailabilityZoneFilter| - filters hosts by availability zone. It passes
|
||||||
hosts matching the availability zone specified in the instance properties.
|
hosts matching the availability zone specified in the instance properties.
|
||||||
Use a comma to specify multiple zones. The filter will then ensure it matches
|
Use a comma to specify multiple zones. The filter will then ensure it matches
|
||||||
@ -41,10 +43,10 @@ There are some standard filter classes to use (:mod:`nova.scheduler.filters`):
|
|||||||
If an extra specs key contains a colon (:), anything before the colon is
|
If an extra specs key contains a colon (:), anything before the colon is
|
||||||
treated as a namespace and anything after the colon is treated as the key to
|
treated as a namespace and anything after the colon is treated as the key to
|
||||||
be matched. If a namespace is present and is not ``capabilities``, the filter
|
be matched. If a namespace is present and is not ``capabilities``, the filter
|
||||||
ignores the namespace. Example like ``capabilities:cpu_info:features`` is
|
ignores the namespace. For example ``capabilities:cpu_info:features`` is
|
||||||
a valid scope format. For backward compatibility, also treats the extra
|
a valid scope format. For backward compatibility, the filter also treats the
|
||||||
specs key as the key to be matched if no namespace is present; this action
|
extra specs key as the key to be matched if no namespace is present; this
|
||||||
is highly discouraged because it conflicts with
|
action is highly discouraged because it conflicts with
|
||||||
AggregateInstanceExtraSpecsFilter filter when you enable both filters
|
AggregateInstanceExtraSpecsFilter filter when you enable both filters
|
||||||
|
|
||||||
The extra specifications can have an operator at the beginning of the value
|
The extra specifications can have an operator at the beginning of the value
|
||||||
@ -83,7 +85,7 @@ There are some standard filter classes to use (:mod:`nova.scheduler.filters`):
|
|||||||
* |AggregateCoreFilter| - filters hosts by CPU core number with per-aggregate
|
* |AggregateCoreFilter| - filters hosts by CPU core number with per-aggregate
|
||||||
``cpu_allocation_ratio`` setting. If no per-aggregate value is found, it will
|
``cpu_allocation_ratio`` setting. If no per-aggregate value is found, it will
|
||||||
fall back to the global default ``cpu_allocation_ratio``. If more than one value
|
fall back to the global default ``cpu_allocation_ratio``. If more than one value
|
||||||
is found for a host (meaning the host is in two different aggregate with
|
is found for a host (meaning the host is in two different aggregates with
|
||||||
different ratio settings), the minimum value will be used.
|
different ratio settings), the minimum value will be used.
|
||||||
* |IsolatedHostsFilter| - filter based on ``image_isolated``, ``host_isolated``
|
* |IsolatedHostsFilter| - filter based on ``image_isolated``, ``host_isolated``
|
||||||
and ``restrict_isolated_hosts_to_isolated_images`` flags.
|
and ``restrict_isolated_hosts_to_isolated_images`` flags.
|
||||||
@ -93,23 +95,23 @@ There are some standard filter classes to use (:mod:`nova.scheduler.filters`):
|
|||||||
* |AggregateRamFilter| - filters hosts by RAM with per-aggregate
|
* |AggregateRamFilter| - filters hosts by RAM with per-aggregate
|
||||||
``ram_allocation_ratio`` setting. If no per-aggregate value is found, it will
|
``ram_allocation_ratio`` setting. If no per-aggregate value is found, it will
|
||||||
fall back to the global default ``ram_allocation_ratio``. If more than one value
|
fall back to the global default ``ram_allocation_ratio``. If more than one value
|
||||||
is found for a host (meaning the host is in two different aggregate with
|
is found for a host (meaning the host is in two different aggregates with
|
||||||
different ratio settings), the minimum value will be used.
|
different ratio settings), the minimum value will be used.
|
||||||
* |DiskFilter| - filters hosts by their disk allocation. Only hosts with sufficient
|
* |DiskFilter| - filters hosts by their disk allocation. Only hosts with sufficient
|
||||||
disk space to host the instance are passed.
|
disk space to host the instance are passed.
|
||||||
``disk_allocation_ratio`` setting. It's virtual disk to physical disk
|
``disk_allocation_ratio`` setting. The virtual disk to physical disk
|
||||||
allocation ratio and it's 1.0 by default. The total allow allocated disk size will
|
allocation ratio, 1.0 by default. The total allowed allocated disk size will
|
||||||
be physical disk multiplied this ratio.
|
be physical disk multiplied this ratio.
|
||||||
* |AggregateDiskFilter| - filters hosts by disk allocation with per-aggregate
|
* |AggregateDiskFilter| - filters hosts by disk allocation with per-aggregate
|
||||||
``disk_allocation_ratio`` setting. If no per-aggregate value is found, it will
|
``disk_allocation_ratio`` setting. If no per-aggregate value is found, it will
|
||||||
fall back to the global default ``disk_allocation_ratio``. If more than one value
|
fall back to the global default ``disk_allocation_ratio``. If more than one value
|
||||||
is found for a host (meaning the host is in two or more different aggregates with
|
is found for a host (meaning the host is in two or more different aggregates with
|
||||||
different ratio settings), the minimum value will be used.
|
different ratio settings), the minimum value will be used.
|
||||||
* |NumInstancesFilter| - filters hosts by number of running instances on it.
|
* |NumInstancesFilter| - filters compute nodes by number of running instances. Nodes
|
||||||
hosts with too many instances will be filtered.
|
with too many instances will be filtered.
|
||||||
``max_instances_per_host`` setting. Maximum number of instances allowed to run on
|
``max_instances_per_host`` setting. Maximum number of instances allowed to run on
|
||||||
this host, the host will be ignored by scheduler if more than ``max_instances_per_host``
|
this host. The host will be ignored by the scheduler if more than ``max_instances_per_host``
|
||||||
are already existing on the host.
|
already exist on the host.
|
||||||
* |AggregateNumInstancesFilter| - filters hosts by number of instances with
|
* |AggregateNumInstancesFilter| - filters hosts by number of instances with
|
||||||
per-aggregate ``max_instances_per_host`` setting. If no per-aggregate value
|
per-aggregate ``max_instances_per_host`` setting. If no per-aggregate value
|
||||||
is found, it will fall back to the global default ``max_instances_per_host``.
|
is found, it will fall back to the global default ``max_instances_per_host``.
|
||||||
@ -129,9 +131,9 @@ There are some standard filter classes to use (:mod:`nova.scheduler.filters`):
|
|||||||
will be used.
|
will be used.
|
||||||
* |PciPassthroughFilter| - Filter that schedules instances on a host if the host
|
* |PciPassthroughFilter| - Filter that schedules instances on a host if the host
|
||||||
has devices to meet the device requests in the 'extra_specs' for the flavor.
|
has devices to meet the device requests in the 'extra_specs' for the flavor.
|
||||||
* |SimpleCIDRAffinityFilter| - allows to put a new instance on a host within
|
* |SimpleCIDRAffinityFilter| - allows a new instance on a host within
|
||||||
the same IP block.
|
the same IP block.
|
||||||
* |DifferentHostFilter| - allows to put the instance on a different host from a
|
* |DifferentHostFilter| - allows the instance on a different host from a
|
||||||
set of instances.
|
set of instances.
|
||||||
* |SameHostFilter| - puts the instance on the same host as another instance in
|
* |SameHostFilter| - puts the instance on the same host as another instance in
|
||||||
a set of instances.
|
a set of instances.
|
||||||
@ -167,9 +169,9 @@ There are some standard filter classes to use (:mod:`nova.scheduler.filters`):
|
|||||||
* |NUMATopologyFilter| - filters hosts based on the NUMA topology requested by the
|
* |NUMATopologyFilter| - filters hosts based on the NUMA topology requested by the
|
||||||
instance, if any.
|
instance, if any.
|
||||||
|
|
||||||
Now we can focus on these standard filter classes in details. I will pass the
|
Now we can focus on these standard filter classes in some detail. We'll skip the
|
||||||
simplest ones, such as |AllHostsFilter|, |CoreFilter| and |RamFilter| are,
|
simplest ones, such as |AllHostsFilter|, |CoreFilter| and |RamFilter|,
|
||||||
because their functionality is quite simple and can be understood just from the
|
because their functionality is relatively simple and can be understood from the
|
||||||
code. For example class |RamFilter| has the next realization:
|
code. For example class |RamFilter| has the next realization:
|
||||||
|
|
||||||
::
|
::
|
||||||
@ -187,22 +189,21 @@ code. For example class |RamFilter| has the next realization:
|
|||||||
return total_usable_ram_mb * FLAGS.ram_allocation_ratio - used_ram_mb >= requested_ram
|
return total_usable_ram_mb * FLAGS.ram_allocation_ratio - used_ram_mb >= requested_ram
|
||||||
|
|
||||||
Here ``ram_allocation_ratio`` means the virtual RAM to physical RAM allocation
|
Here ``ram_allocation_ratio`` means the virtual RAM to physical RAM allocation
|
||||||
ratio (it is ``1.5`` by default). Really, nice and simple.
|
ratio (it is ``1.5`` by default).
|
||||||
|
|
||||||
Next standard filter to describe is |AvailabilityZoneFilter| and it isn't
|
The |AvailabilityZoneFilter| looks at the availability zone of compute node
|
||||||
difficult too. This filter just looks at the availability zone of compute node
|
|
||||||
and availability zone from the properties of the request. Each compute service
|
and availability zone from the properties of the request. Each compute service
|
||||||
has its own availability zone. So deployment engineers have an option to run
|
has its own availability zone. So deployment engineers have an option to run
|
||||||
scheduler with availability zones support and can configure availability zones
|
scheduler with availability zones support and can configure availability zones
|
||||||
on each compute host. This classes method ``host_passes`` returns ``True`` if
|
on each compute host. This class's method ``host_passes`` returns ``True`` if
|
||||||
availability zone mentioned in request is the same on the current compute host.
|
availability zone mentioned in request is the same on the current compute host.
|
||||||
|
|
||||||
The |ImagePropertiesFilter| filters hosts based on the architecture,
|
The |ImagePropertiesFilter| filters hosts based on the architecture,
|
||||||
hypervisor type, and virtual machine mode specified in the
|
hypervisor type and virtual machine mode specified in the
|
||||||
instance. E.g., an instance might require a host that supports the arm
|
instance. For example, an instance might require a host that supports the ARM
|
||||||
architecture on a qemu compute host. The |ImagePropertiesFilter| will only
|
architecture on a qemu compute host. The |ImagePropertiesFilter| will only
|
||||||
pass hosts that can satisfy this request. These instance
|
pass hosts that can satisfy this request. These instance
|
||||||
properties are populated from properties define on the instance's image.
|
properties are populated from properties defined on the instance's image.
|
||||||
E.g. an image can be decorated with these properties using
|
E.g. an image can be decorated with these properties using
|
||||||
``glance image-update img-uuid --property architecture=arm --property
|
``glance image-update img-uuid --property architecture=arm --property
|
||||||
hypervisor_type=qemu``
|
hypervisor_type=qemu``
|
||||||
@ -223,17 +224,17 @@ enabled and operational.
|
|||||||
|
|
||||||
Now we are going to |IsolatedHostsFilter|. There can be some special hosts
|
Now we are going to |IsolatedHostsFilter|. There can be some special hosts
|
||||||
reserved for specific images. These hosts are called **isolated**. So the
|
reserved for specific images. These hosts are called **isolated**. So the
|
||||||
images to run on the isolated hosts are also called isolated. This Scheduler
|
images to run on the isolated hosts are also called isolated. The filter
|
||||||
checks if ``image_isolated`` flag named in instance specifications is the same
|
checks if ``image_isolated`` flag named in instance specifications is the same
|
||||||
that the host has. Isolated hosts can run non isolated images if the flag
|
as the host. Isolated hosts can run non isolated images if the flag
|
||||||
``restrict_isolated_hosts_to_isolated_images`` is set to false.
|
``restrict_isolated_hosts_to_isolated_images`` is set to false.
|
||||||
|
|
||||||
|DifferentHostFilter| - its method ``host_passes`` returns ``True`` if host to
|
|DifferentHostFilter| - method ``host_passes`` returns ``True`` if the host to
|
||||||
place instance on is different from all the hosts used by set of instances.
|
place an instance on is different from all the hosts used by a set of instances.
|
||||||
|
|
||||||
|SameHostFilter| does the opposite to what |DifferentHostFilter| does. So its
|
|SameHostFilter| does the opposite to what |DifferentHostFilter| does.
|
||||||
``host_passes`` returns ``True`` if the host we want to place instance on is
|
``host_passes`` returns ``True`` if the host we want to place an instance on is
|
||||||
one of the set of instances uses.
|
one of the hosts used by a set of instances.
|
||||||
|
|
||||||
|SimpleCIDRAffinityFilter| looks at the subnet mask and investigates if
|
|SimpleCIDRAffinityFilter| looks at the subnet mask and investigates if
|
||||||
the network address of the current host is in the same sub network as it was
|
the network address of the current host is in the same sub network as it was
|
||||||
@ -243,8 +244,8 @@ defined in the request.
|
|||||||
queries for the hosts capabilities filtering, based on simple JSON-like syntax.
|
queries for the hosts capabilities filtering, based on simple JSON-like syntax.
|
||||||
There can be used the following operations for the host states properties:
|
There can be used the following operations for the host states properties:
|
||||||
``=``, ``<``, ``>``, ``in``, ``<=``, ``>=``, that can be combined with the following
|
``=``, ``<``, ``>``, ``in``, ``<=``, ``>=``, that can be combined with the following
|
||||||
logical operations: ``not``, ``or``, ``and``. For example, there is the query you can
|
logical operations: ``not``, ``or``, ``and``. For example, the following query can be
|
||||||
find in tests:
|
found in tests:
|
||||||
|
|
||||||
::
|
::
|
||||||
|
|
||||||
@ -298,7 +299,7 @@ filtering is done in the following manner:
|
|||||||
* If instance has a topology defined, it will be considered only for NUMA
|
* If instance has a topology defined, it will be considered only for NUMA
|
||||||
capable hosts.
|
capable hosts.
|
||||||
|
|
||||||
To use filters you specify next two settings:
|
To use filters you specify two settings:
|
||||||
|
|
||||||
* ``scheduler_available_filters`` - Defines filter classes made available to the
|
* ``scheduler_available_filters`` - Defines filter classes made available to the
|
||||||
scheduler. This setting can be used multiple times.
|
scheduler. This setting can be used multiple times.
|
||||||
@ -318,10 +319,10 @@ would be available, and by default the |RamFilter|, |ComputeFilter|,
|
|||||||
|ImagePropertiesFilter|, |ServerGroupAntiAffinityFilter|,
|
|ImagePropertiesFilter|, |ServerGroupAntiAffinityFilter|,
|
||||||
and |ServerGroupAffinityFilter| would be used.
|
and |ServerGroupAffinityFilter| would be used.
|
||||||
|
|
||||||
If you want to create **your own filter** you just need to inherit from
|
To create **your own filter** you must inherit from
|
||||||
|BaseHostFilter| and implement one method:
|
|BaseHostFilter| and implement one method:
|
||||||
``host_passes``. This method should return ``True`` if host passes the filter. It
|
``host_passes``. This method should return ``True`` if a host passes the filter. It
|
||||||
takes ``host_state`` (describes host) and ``filter_properties`` dictionary as the
|
takes ``host_state`` (describing the host) and ``filter_properties`` dictionary as the
|
||||||
parameters.
|
parameters.
|
||||||
|
|
||||||
As an example, nova.conf could contain the following scheduler-related
|
As an example, nova.conf could contain the following scheduler-related
|
||||||
@ -342,7 +343,7 @@ default when no filters are specified in the request.
|
|||||||
Weights
|
Weights
|
||||||
-------
|
-------
|
||||||
|
|
||||||
Filter Scheduler uses the so called **weights** during its work. A weigher is a
|
Filter Scheduler uses the so-called **weights** during its work. A weigher is a
|
||||||
way to select the best suitable host from a group of valid hosts by giving
|
way to select the best suitable host from a group of valid hosts by giving
|
||||||
weights to all the hosts in the list.
|
weights to all the hosts in the list.
|
||||||
|
|
||||||
@ -354,7 +355,7 @@ easily. Therefore the final weight for the object will be::
|
|||||||
weight = w1_multiplier * norm(w1) + w2_multiplier * norm(w2) + ...
|
weight = w1_multiplier * norm(w1) + w2_multiplier * norm(w2) + ...
|
||||||
|
|
||||||
A weigher should be a subclass of ``weights.BaseHostWeigher`` and they must
|
A weigher should be a subclass of ``weights.BaseHostWeigher`` and they must
|
||||||
implement the ``weight_multiplier`` and ``weight_object`` methods. If the
|
implement the ``weight_multiplier`` and ``weight_objects`` methods. If the
|
||||||
``weight_objects`` method is overridden it just return a list of weights, and not
|
``weight_objects`` method is overridden it just return a list of weights, and not
|
||||||
modify the weight of the object directly, since final weights are normalized and
|
modify the weight of the object directly, since final weights are normalized and
|
||||||
computed by ``weight.BaseWeightHandler``.
|
computed by ``weight.BaseWeightHandler``.
|
||||||
@ -363,9 +364,10 @@ The Filter Scheduler weighs hosts based on the config option
|
|||||||
`scheduler_weight_classes`, this defaults to
|
`scheduler_weight_classes`, this defaults to
|
||||||
`nova.scheduler.weights.all_weighers`, which selects the following weighers:
|
`nova.scheduler.weights.all_weighers`, which selects the following weighers:
|
||||||
|
|
||||||
* |RAMWeigher| Hosts are then weighted and sorted with the largest weight winning.
|
* |RAMWeigher| Compute weight based on available RAM on the compute node.
|
||||||
If the multiplier is negative, the host with less RAM available will win (useful
|
Sort with the largest weight winning. If the multiplier is negative, the
|
||||||
for stacking hosts, instead of spreading).
|
host with least RAM available will win (useful for stacking hosts, instead
|
||||||
|
of spreading).
|
||||||
* |MetricsWeigher| This weigher can compute the weight based on the compute node
|
* |MetricsWeigher| This weigher can compute the weight based on the compute node
|
||||||
host's various metrics. The to-be weighed metrics and their weighing ratio
|
host's various metrics. The to-be weighed metrics and their weighing ratio
|
||||||
are specified in the configuration file as the followings::
|
are specified in the configuration file as the followings::
|
||||||
@ -377,19 +379,19 @@ The Filter Scheduler weighs hosts based on the config option
|
|||||||
hosts. If the multiplier is positive, the weigher prefer choosing heavy
|
hosts. If the multiplier is positive, the weigher prefer choosing heavy
|
||||||
workload compute hosts, the weighing has the opposite effect of the default.
|
workload compute hosts, the weighing has the opposite effect of the default.
|
||||||
|
|
||||||
Filter Scheduler finds local list of acceptable hosts by repeated filtering and
|
Filter Scheduler makes a local list of acceptable hosts by repeated filtering and
|
||||||
weighing. Each time it chooses a host, it virtually consumes resources on it,
|
weighing. Each time it chooses a host, it virtually consumes resources on it,
|
||||||
so subsequent selections can adjust accordingly. It is useful if the customer
|
so subsequent selections can adjust accordingly. It is useful if the customer
|
||||||
asks for the some large amount of instances, because weight is computed for
|
asks for a large block of instances, because weight is computed for
|
||||||
each instance requested.
|
each instance requested.
|
||||||
|
|
||||||
.. image:: ./images/filteringWorkflow2.png
|
.. image:: ./images/filteringWorkflow2.png
|
||||||
|
|
||||||
In the end Filter Scheduler sorts selected hosts by their weight and provisions
|
At the end Filter Scheduler sorts selected hosts by their weight and attempts
|
||||||
instances on them.
|
to provision instances on the chosen hosts.
|
||||||
|
|
||||||
P.S.: you can find more examples of using Filter Scheduler and standard filters
|
P.S.: you can find more examples of using Filter Scheduler and standard filters
|
||||||
in :mod:``nova.tests.scheduler``.
|
in :mod:`nova.tests.scheduler`.
|
||||||
|
|
||||||
.. |AllHostsFilter| replace:: :class:`AllHostsFilter <nova.scheduler.filters.all_hosts_filter.AllHostsFilter>`
|
.. |AllHostsFilter| replace:: :class:`AllHostsFilter <nova.scheduler.filters.all_hosts_filter.AllHostsFilter>`
|
||||||
.. |ImagePropertiesFilter| replace:: :class:`ImagePropertiesFilter <nova.scheduler.filters.image_props_filter.ImagePropertiesFilter>`
|
.. |ImagePropertiesFilter| replace:: :class:`ImagePropertiesFilter <nova.scheduler.filters.image_props_filter.ImagePropertiesFilter>`
|
||||||
|
Loading…
x
Reference in New Issue
Block a user