Expose instance reservation affinity support
For instance reservation, blazar has checked the affinity policy and raised an exception if it is None or True. Since we are now ready to support affinity=None/True, this patch deletes the check and adds a migration script to accept a NULL value for the affinity column in the database. This patch also updates the CLI usage document of the instance reservation and adds the release note for the instance reservation affinity policy. Change-Id: Icf26d1b7dffe64f82d7084dcebb5df1c7c9f106d Closes-Bug: #1737676 Blueprint: no-affinity-instance-reservation
This commit is contained in:
parent
49f78f2ab4
commit
122c61ad88
|
@ -0,0 +1,44 @@
|
|||
# Copyright 2018 OpenStack Foundation.
|
||||
#
|
||||
# Licensed under the Apache License, Version 2.0 (the "License");
|
||||
# you may not use this file except in compliance with the License.
|
||||
# You may obtain a copy of the License at
|
||||
#
|
||||
# http://www.apache.org/licenses/LICENSE-2.0
|
||||
#
|
||||
# Unless required by applicable law or agreed to in writing, software
|
||||
# distributed under the License is distributed on an "AS IS" BASIS,
|
||||
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or
|
||||
# implied.
|
||||
# See the License for the specific language governing permissions and
|
||||
# limitations under the License.
|
||||
|
||||
"""no affinity instance reservation
|
||||
|
||||
Revision ID: 9593f3656974
|
||||
Revises: 35b314cd39ee
|
||||
Create Date: 2018-12-26 15:55:29.950250
|
||||
|
||||
"""
|
||||
|
||||
# revision identifiers, used by Alembic.
|
||||
revision = '9593f3656974'
|
||||
down_revision = '35b314cd39ee'
|
||||
|
||||
from alembic import op
|
||||
from sqlalchemy.dialects import mysql
|
||||
|
||||
|
||||
def upgrade():
|
||||
op.alter_column('instance_reservations', 'affinity',
|
||||
existing_type=mysql.TINYINT(display_width=1),
|
||||
nullable=True)
|
||||
|
||||
|
||||
def downgrade():
|
||||
# TODO(tetsuro): Since the Kilo release, OpenStack doesn't support
|
||||
# database downgrades, we should delete this, update the related
|
||||
# Blazar documents, and issue a reno in a followup.
|
||||
op.alter_column('instance_reservations', 'affinity',
|
||||
existing_type=mysql.TINYINT(display_width=1),
|
||||
nullable=False)
|
|
@ -61,15 +61,6 @@ class VirtualInstancePlugin(base.BasePlugin, nova.NovaClientWrapper):
|
|||
self.monitor.register_healing_handler(self.heal_reservations)
|
||||
self.placement_client = placement.BlazarPlacementClient()
|
||||
|
||||
# TODO(tetsuro) Remove this with a release note when all the support
|
||||
# for True/None affinity is ready
|
||||
def _check_affinity(self, affinity):
|
||||
# TODO(masahito) the instance reservation plugin only supports
|
||||
# anti-affinity rule in short-term goal.
|
||||
if bool_from_string(affinity):
|
||||
raise mgr_exceptions.MalformedParameter(
|
||||
param='affinity (only affinity = False is supported)')
|
||||
|
||||
def filter_hosts_by_reservation(self, hosts, start_date, end_date,
|
||||
excludes):
|
||||
free = []
|
||||
|
@ -401,8 +392,6 @@ class VirtualInstancePlugin(base.BasePlugin, nova.NovaClientWrapper):
|
|||
def reserve_resource(self, reservation_id, values):
|
||||
self.validate_reservation_param(values)
|
||||
|
||||
self._check_affinity(values['affinity'])
|
||||
|
||||
hosts = self.pickup_hosts(reservation_id, values)
|
||||
|
||||
instance_reservation_val = {
|
||||
|
@ -468,8 +457,6 @@ class VirtualInstancePlugin(base.BasePlugin, nova.NovaClientWrapper):
|
|||
- If an instance reservation has already started
|
||||
- only amount is increasable.
|
||||
"""
|
||||
affinity = new_values.get('affinity', None)
|
||||
self._check_affinity(affinity)
|
||||
|
||||
reservation = db_api.reservation_get(reservation_id)
|
||||
lease = db_api.lease_get(reservation['lease_id'])
|
||||
|
|
|
@ -139,16 +139,6 @@ class TestVirtualInstancePlugin(tests.TestCase):
|
|||
'server_group_id': 2,
|
||||
'aggregate_id': 3})
|
||||
|
||||
def test_error_with_affinity(self):
|
||||
plugin = instance_plugin.VirtualInstancePlugin()
|
||||
inputs = self.get_input_values(2, 4018, 10, 1, True,
|
||||
'2030-01-01 08:00', '2030-01-01 08:00',
|
||||
'lease-1', '')
|
||||
self.assertRaises(mgr_exceptions.MalformedParameter,
|
||||
plugin.reserve_resource, 'reservation_id', inputs)
|
||||
self.assertRaises(mgr_exceptions.MalformedParameter,
|
||||
plugin.update_reservation, 'reservation_id', inputs)
|
||||
|
||||
def test_filter_hosts_by_reservation_with_exclude(self):
|
||||
def fake_get_reservation_by_host(host_id, start, end):
|
||||
if host_id == 'host-1':
|
||||
|
|
|
@ -13,9 +13,6 @@ The following packages should be installed:
|
|||
|
||||
The following four scheduler filters should be configured in nova.conf:
|
||||
|
||||
* AggregateInstanceExtraSpecsFilter
|
||||
* AggregateMultiTenancyIsolation
|
||||
* ServerGroupAffinityFilter
|
||||
* BlazarFilter
|
||||
|
||||
1. Add hosts into the freepool
|
||||
|
@ -56,7 +53,7 @@ Result:
|
|||
|
||||
.. sourcecode:: console
|
||||
|
||||
blazar lease-create --reservation resource_type=virtual:instance,vcpus=1,memory_mb=1024,disk_gb=20,amount=1,affinity=False --start-date "2020-07-24 20:00" --end-date "2020-08-09 21:00" lease-1
|
||||
blazar lease-create --reservation resource_type=virtual:instance,vcpus=1,memory_mb=1024,disk_gb=20,amount=1 --start-date "2020-07-24 20:00" --end-date "2020-08-09 21:00" lease-1
|
||||
|
||||
..
|
||||
|
||||
|
@ -84,7 +81,7 @@ Result:
|
|||
| project_id | 6f6f9b596d47441294eb40f565063833 |
|
||||
| reservations | {"status": "pending", "memory_mb": 1024, "lease_id": "becf2f3b-0177-4c0f-a7e7-0123370849a3", "disk_gb": 20, |
|
||||
| | "resource_id": "061198b0-53e4-4545-9d85-405ca93a7bdf", "created_at": "2017-07-31 07:55:59", "updated_at": "2017-07-31 |
|
||||
| | 07:55:59", "aggregate_id": 3, "server_group_id": "ba03ebb4-e55c-4da4-9d39-87e13354f3b7", "amount": 1, "affinity": false, |
|
||||
| | 07:55:59", "aggregate_id": 3, "server_group_id": "ba03ebb4-e55c-4da4-9d39-87e13354f3b7", "amount": 1, "affinity": null, |
|
||||
| | "flavor_id": "db83d6fd-c69c-4259-92cf-012db2e55a58", "id": "db83d6fd-c69c-4259-92cf-012db2e55a58", "vcpus": 1, |
|
||||
| | "resource_type": "virtual:instance"} |
|
||||
| start_date | 2020-07-24T20:00:00.000000 |
|
||||
|
@ -150,10 +147,10 @@ Result:
|
|||
|
||||
..
|
||||
|
||||
1. Create a server: Please specify the flavor of the reservation and group_id as a scheduler hint.
|
||||
1. Create a server: Please specify the flavor of the reservation.
|
||||
|
||||
.. sourcecode:: console
|
||||
|
||||
openstack server create --flavor db83d6fd-c69c-4259-92cf-012db2e55a58 --image <image> --network <network> --hint group=ba03ebb4-e55c-4da4-9d39-87e13354f3b7 <server-name>
|
||||
openstack server create --flavor db83d6fd-c69c-4259-92cf-012db2e55a58 --image <image> --network <network> <server-name>
|
||||
|
||||
..
|
||||
|
|
|
@ -0,0 +1,24 @@
|
|||
features:
|
||||
- |
|
||||
For instance reservation, the reservation parameter ``affinity`` now
|
||||
supports ``True`` and ``None`` and defaults to ``None``
|
||||
|
||||
- ``affinity = True``
|
||||
|
||||
* Blazar picks up the same host for the instances for the reservation.
|
||||
Using the reservation flavor, users don't need to set additional
|
||||
specs such as "server_group" to schedule the instances to the host.
|
||||
|
||||
- ``affinity = False``
|
||||
|
||||
* Blazar picks up different hosts for the instances for the
|
||||
reservation. Using the reservation flavor, users don't need to set
|
||||
additional specs such as "server_group" to schedule to the hosts.
|
||||
|
||||
- ``affinity = None`` (default)
|
||||
|
||||
* The picked up hosts can be different or same.
|
||||
|
||||
``AggregateInstanceExtraSpecsFilter``, ``AggregateMultiTenancyIsolation``,
|
||||
or ``ServerGroupAffinityFilte`` is not needed any more for blazar's
|
||||
instance reservation.
|
Loading…
Reference in New Issue