File: aggregates.rst

package info (click to toggle)
nova 2%3A32.1.0-7
  • links: PTS, VCS
  • area: main
  • in suites: forky, sid
  • size: 51,500 kB
  • sloc: python: 418,899; pascal: 1,848; sh: 991; makefile: 163; xml: 83
file content (402 lines) | stat: -rw-r--r-- 18,931 bytes parent folder | download | duplicates (3)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
===============
Host aggregates
===============

Host aggregates are a mechanism for partitioning hosts in an OpenStack cloud,
or a region of an OpenStack cloud, based on arbitrary characteristics.
Examples where an administrator may want to do this include where a group of
hosts have additional hardware or performance characteristics.

Host aggregates started out as a way to use Xen hypervisor resource pools, but
have been generalized to provide a mechanism to allow administrators to assign
key-value pairs to groups of machines. Each node can have multiple aggregates,
each aggregate can have multiple key-value pairs, and the same key-value pair
can be assigned to multiple aggregates. This information can be used in the
scheduler to enable advanced scheduling, to set up Xen hypervisor resource
pools or to define logical groups for migration.

Host aggregates are not explicitly exposed to users. Instead administrators map
flavors to host aggregates. Administrators do this by setting metadata on a
host aggregate, and matching flavor extra specifications. The scheduler then
endeavors to match user requests for instances of the given flavor to a host
aggregate with the same key-value pair in its metadata. Compute nodes can be in
more than one host aggregate. Weight multipliers can be controlled on a
per-aggregate basis by setting the desired ``xxx_weight_multiplier`` aggregate
metadata.

Administrators are able to optionally expose a host aggregate as an
:term:`Availability Zone`. Availability zones are different from host
aggregates in that they are explicitly exposed to the user, and hosts can only
be in a single availability zone. Administrators can configure a default
availability zone where instances will be scheduled when the user fails to
specify one. For more information on how to do this, refer to
:doc:`/admin/availability-zones`.

.. note::

    It is not allowed to move instances between Availability Zones.
    If adding a host to an aggregate or removing a host from an aggregate would
    cause an instance to move between Availability Zones, including moving
    from or moving to the default AZ, then the operation will be rejected. The
    administrator should drain the instances from the host first then the host
    can be moved.

.. _config-sch-for-aggs:

Configure scheduler to support host aggregates
----------------------------------------------

One common use case for host aggregates is when you want to support scheduling
instances to a subset of compute hosts because they have a specific capability.
For example, you may want to allow users to request compute hosts that have SSD
drives if they need access to faster disk I/O, or access to compute hosts that
have GPU cards to take advantage of GPU-accelerated code.

To configure the scheduler to support host aggregates, the
:oslo.config:option:`filter_scheduler.enabled_filters` configuration option
must contain the ``AggregateInstanceExtraSpecsFilter`` in addition to the other
filters used by the scheduler. Add the following line to ``nova.conf`` on the
host that runs the ``nova-scheduler`` service to enable host aggregates
filtering, as well as the other filters that are typically enabled:

.. code-block:: ini

   [filter_scheduler]
   enabled_filters=...,AggregateInstanceExtraSpecsFilter

Example: Specify compute hosts with SSDs
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~

This example configures the Compute service to enable users to request nodes
that have solid-state drives (SSDs). You create a ``fast-io`` host aggregate in
the ``nova`` availability zone and you add the ``ssd=true`` key-value pair to
the aggregate. Then, you add the ``node1``, and ``node2`` compute nodes to it.

.. code-block:: console

   $ openstack aggregate create --zone nova fast-io
   +-------------------+----------------------------+
   | Field             | Value                      |
   +-------------------+----------------------------+
   | availability_zone | nova                       |
   | created_at        | 2016-12-22T07:31:13.013466 |
   | deleted           | False                      |
   | deleted_at        | None                       |
   | id                | 1                          |
   | name              | fast-io                    |
   | updated_at        | None                       |
   +-------------------+----------------------------+

   $ openstack aggregate set --property ssd=true 1
   +-------------------+----------------------------+
   | Field             | Value                      |
   +-------------------+----------------------------+
   | availability_zone | nova                       |
   | created_at        | 2016-12-22T07:31:13.000000 |
   | deleted           | False                      |
   | deleted_at        | None                       |
   | hosts             | []                         |
   | id                | 1                          |
   | name              | fast-io                    |
   | properties        | ssd='true'                 |
   | updated_at        | None                       |
   +-------------------+----------------------------+

   $ openstack aggregate add host 1 node1
   +-------------------+--------------------------------------------------+
   | Field             | Value                                            |
   +-------------------+--------------------------------------------------+
   | availability_zone | nova                                             |
   | created_at        | 2016-12-22T07:31:13.000000                       |
   | deleted           | False                                            |
   | deleted_at        | None                                             |
   | hosts             | [u'node1']                                       |
   | id                | 1                                                |
   | metadata          | {u'ssd': u'true', u'availability_zone': u'nova'} |
   | name              | fast-io                                          |
   | updated_at        | None                                             |
   +-------------------+--------------------------------------------------+

   $ openstack aggregate add host 1 node2
   +-------------------+--------------------------------------------------+
   | Field             | Value                                            |
   +-------------------+--------------------------------------------------+
   | availability_zone | nova                                             |
   | created_at        | 2016-12-22T07:31:13.000000                       |
   | deleted           | False                                            |
   | deleted_at        | None                                             |
   | hosts             | [u'node1', u'node2']                             |
   | id                | 1                                                |
   | metadata          | {u'ssd': u'true', u'availability_zone': u'nova'} |
   | name              | fast-io                                          |
   | updated_at        | None                                             |
   +-------------------+--------------------------------------------------+

Use the :command:`openstack flavor create` command to create the ``ssd.large``
flavor called with an ID of 6, 8 GB of RAM, 80 GB root disk, and 4 vCPUs.

.. code-block:: console

   $ openstack flavor create --id 6 --ram 8192 --disk 80 --vcpus 4 ssd.large
   +----------------------------+-----------+
   | Field                      | Value     |
   +----------------------------+-----------+
   | OS-FLV-DISABLED:disabled   | False     |
   | OS-FLV-EXT-DATA:ephemeral  | 0         |
   | disk                       | 80        |
   | id                         | 6         |
   | name                       | ssd.large |
   | os-flavor-access:is_public | True      |
   | ram                        | 8192      |
   | rxtx_factor                | 1.0       |
   | swap                       |           |
   | vcpus                      | 4         |
   +----------------------------+-----------+

Once the flavor is created, specify one or more key-value pairs that match the
key-value pairs on the host aggregates with scope
``aggregate_instance_extra_specs``. In this case, that is the
``aggregate_instance_extra_specs:ssd=true`` key-value pair.  Setting a
key-value pair on a flavor is done using the :command:`openstack flavor set`
command.

.. code-block:: console

   $ openstack flavor set \
       --property aggregate_instance_extra_specs:ssd=true ssd.large

Once it is set, you should see the ``extra_specs`` property of the
``ssd.large`` flavor populated with a key of ``ssd`` and a corresponding value
of ``true``.

.. code-block:: console

   $ openstack flavor show ssd.large
   +----------------------------+-------------------------------------------+
   | Field                      | Value                                     |
   +----------------------------+-------------------------------------------+
   | OS-FLV-DISABLED:disabled   | False                                     |
   | OS-FLV-EXT-DATA:ephemeral  | 0                                         |
   | disk                       | 80                                        |
   | id                         | 6                                         |
   | name                       | ssd.large                                 |
   | os-flavor-access:is_public | True                                      |
   | properties                 | aggregate_instance_extra_specs:ssd='true' |
   | ram                        | 8192                                      |
   | rxtx_factor                | 1.0                                       |
   | swap                       |                                           |
   | vcpus                      | 4                                         |
   +----------------------------+-------------------------------------------+

Now, when a user requests an instance with the ``ssd.large`` flavor,
the scheduler only considers hosts with the ``ssd=true`` key-value pair.
In this example, these are ``node1`` and ``node2``.


Aggregates in Placement
-----------------------

Aggregates also exist in placement and are not the same thing as host
aggregates in nova. These aggregates are defined (purely) as groupings of
related resource providers. Since compute nodes in nova are represented in
placement as resource providers, they can be added to a placement aggregate as
well. For example, get the UUID of the compute node using :command:`openstack
hypervisor list` and add it to an aggregate in placement using
:command:`openstack resource provider aggregate set`.

.. code-block:: console

  $ openstack --os-compute-api-version=2.53 hypervisor list
  +--------------------------------------+---------------------+-----------------+-----------------+-------+
  | ID                                   | Hypervisor Hostname | Hypervisor Type | Host IP         | State |
  +--------------------------------------+---------------------+-----------------+-----------------+-------+
  | 815a5634-86fb-4e1e-8824-8a631fee3e06 | node1               | QEMU            | 192.168.1.123   | up    |
  +--------------------------------------+---------------------+-----------------+-----------------+-------+

  $ openstack --os-placement-api-version=1.2 resource provider aggregate set \
      --aggregate df4c74f3-d2c4-4991-b461-f1a678e1d161 \
      815a5634-86fb-4e1e-8824-8a631fee3e06

Some scheduling filter operations can be performed by placement for increased
speed and efficiency.

.. note::

    The nova-api service attempts (as of nova 18.0.0) to automatically mirror
    the association of a compute host with an aggregate when an administrator
    adds or removes a host to/from a nova host aggregate. This should alleviate
    the need to manually create those association records in the placement API
    using the ``openstack resource provider aggregate set`` CLI invocation.


.. _tenant-isolation-with-placement:

Tenant Isolation with Placement
-------------------------------

In order to use placement to isolate tenants, there must be placement
aggregates that match the membership and UUID of nova host aggregates that you
want to use for isolation. The same key pattern in aggregate metadata used by
the :ref:`AggregateMultiTenancyIsolation` filter controls this function, and is
enabled by setting
:oslo.config:option:`scheduler.limit_tenants_to_placement_aggregate` to
``True``.

.. code-block:: console

    $ openstack --os-compute-api-version=2.53 aggregate create myagg
    +-------------------+--------------------------------------+
    | Field             | Value                                |
    +-------------------+--------------------------------------+
    | availability_zone | None                                 |
    | created_at        | 2018-03-29T16:22:23.175884           |
    | deleted           | False                                |
    | deleted_at        | None                                 |
    | id                | 4                                    |
    | name              | myagg                                |
    | updated_at        | None                                 |
    | uuid              | 019e2189-31b3-49e1-aff2-b220ebd91c24 |
    +-------------------+--------------------------------------+

    $ openstack --os-compute-api-version=2.53 aggregate add host myagg node1
    +-------------------+--------------------------------------+
    | Field             | Value                                |
    +-------------------+--------------------------------------+
    | availability_zone | None                                 |
    | created_at        | 2018-03-29T16:22:23.175884           |
    | deleted           | False                                |
    | deleted_at        | None                                 |
    | hosts             | [u'node1']                           |
    | id                | 4                                    |
    | name              | myagg                                |
    | updated_at        | None                                 |
    | uuid              | 019e2189-31b3-49e1-aff2-b220ebd91c24 |
    +-------------------+--------------------------------------+

    $ openstack project list -f value | grep 'demo'
    9691591f913949818a514f95286a6b90 demo

    $ openstack aggregate set \
        --property filter_tenant_id=9691591f913949818a514f95286a6b90 myagg

    $ openstack --os-placement-api-version=1.2 resource provider aggregate set \
        --aggregate 019e2189-31b3-49e1-aff2-b220ebd91c24 \
        815a5634-86fb-4e1e-8824-8a631fee3e06

Note that the ``filter_tenant_id`` metadata key can be optionally suffixed
with any string for multiple tenants, such as ``filter_tenant_id3=$tenantid``.


Usage
-----

Much of the configuration of host aggregates is driven from the API or
command-line clients. For example, to create a new aggregate and add hosts to
it using the :command:`openstack` client, run:

.. code-block:: console

    $ openstack aggregate create my-aggregate
    $ openstack aggregate add host my-aggregate my-host

To list all aggregates and show information about a specific aggregate, run:

.. code-block:: console

    $ openstack aggregate list
    $ openstack aggregate show my-aggregate

To set and unset a property on the aggregate, run:

.. code-block:: console

    $ openstack aggregate set --property pinned=true my-aggregrate
    $ openstack aggregate unset --property pinned my-aggregate

To rename the aggregate, run:

.. code-block:: console

    $ openstack aggregate set --name my-awesome-aggregate my-aggregate

To remove a host from an aggregate and delete the aggregate, run:

.. code-block:: console

    $ openstack aggregate remove host my-aggregate my-host
    $ openstack aggregate delete my-aggregate

For more information, refer to the :python-openstackclient-doc:`OpenStack
Client documentation <cli/command-objects/aggregate.html>`.


Configuration
-------------

In addition to CRUD operations enabled by the API and clients, the following
configuration options can be used to configure how host aggregates and the
related availability zones feature operate under the hood:

- :oslo.config:option:`default_schedule_zone`
- :oslo.config:option:`scheduler.limit_tenants_to_placement_aggregate`
- :oslo.config:option:`cinder.cross_az_attach`

Finally, as discussed previously, there are a number of host aggregate-specific
scheduler filters. These are:

- :ref:`AggregateImagePropertiesIsolation`
- :ref:`AggregateInstanceExtraSpecsFilter`
- :ref:`AggregateIoOpsFilter`
- :ref:`AggregateMultiTenancyIsolation`
- :ref:`AggregateNumInstancesFilter`
- :ref:`AggregateTypeAffinityFilter`

The following configuration options are applicable to the scheduler
configuration:

- :oslo.config:option:`cpu_allocation_ratio`
- :oslo.config:option:`ram_allocation_ratio`
- :oslo.config:option:`filter_scheduler.max_instances_per_host`
- :oslo.config:option:`filter_scheduler.aggregate_image_properties_isolation_separator`
- :oslo.config:option:`filter_scheduler.aggregate_image_properties_isolation_namespace`

.. _image-caching-aggregates:

Image Caching
-------------

Aggregates can be used as a way to target multiple compute nodes for the purpose of
requesting that images be pre-cached for performance reasons.

.. note::

    `Some of the virt drivers`_ provide image caching support, which improves performance
    of second-and-later boots of the same image by keeping the base image in an on-disk
    cache. This avoids the need to re-download the image from Glance, which reduces
    network utilization and time-to-boot latency. Image pre-caching is the act of priming
    that cache with images ahead of time to improve performance of the first boot.

.. _Some of the virt drivers: https://docs.openstack.org/nova/latest/user/support-matrix.html#operation_cache_images

Assuming an aggregate called ``my-aggregate`` where two images should
be pre-cached, running the following command will initiate the
request:

.. code-block:: console

    $ nova aggregate-cache-images my-aggregate image1 image2

Note that image pre-caching happens asynchronously in a best-effort
manner. The images and aggregate provided are checked by the server
when the command is run, but the compute nodes are not checked to see
if they support image caching until the process runs. Progress and
results are logged by each compute, and the process sends
``aggregate.cache_images.start``, ``aggregate.cache_images.progress``,
and ``aggregate.cache_images.end`` notifications, which may be useful
for monitoring the operation externally.

References
----------

- `Curse your bones, Availability Zones! (Openstack Summit Vancouver 2018)
  <https://www.openstack.org/videos/vancouver-2018/curse-your-bones-availability-zones-1>`__