Files
nova/nova/conf/availability_zone.py
Matt Riedemann 07a24dcef7 Default AZ for instance if cross_az_attach=False and checking from API
If we're booting from an existing volume but the instance is not being
created in a requested availability zone, and cross_az_attach=False,
we'll fail with a 400 since by default the volume is in the 'nova'
AZ and the instance does not have an AZ set - because one wasn't requested
and because it's not in a host aggregate yet.

This refactors that AZ validation during server create in the API to
do it before calling _validate_bdm so we get the pre-existing volumes
early and if cross_az_attach=False, we validate the volume zone(s) against
the instance AZ. If the [DEFAULT]/default_schedule_zone (for instances) is
not set and the volume AZ does not match the
[DEFAULT]/default_availability_zone then we put the volume AZ in the request
spec as if the user requested that AZ when creating the server.

Since this is a change in how cross_az_attach is used and how the instance
default AZ works when using BDMs for pre-existing volumes, the docs are
updated and a release note is added.

Note that not all of the API code paths are unit tested because the
functional test coverage does most of the heavy lifting for coverage.
Given the amount of unit tests that are impacted by this change, it is
pretty obvious that (1) many unit tests are mocking at too low a level and
(2) functional tests are better for validating these flows.

Closes-Bug: #1694844

Change-Id: Ib31ba2cbff0ebb22503172d8801b6e0c3d2aa68a
2019-10-31 10:08:46 -04:00

72 lines
2.2 KiB
Python

# Copyright (c) 2013 Intel, Inc.
# Copyright (c) 2013 OpenStack Foundation
# All Rights Reserved.
#
# 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.
from oslo_config import cfg
availability_zone_opts = [
cfg.StrOpt('internal_service_availability_zone',
default='internal',
help="""
Availability zone for internal services.
This option determines the availability zone for the various internal nova
services, such as 'nova-scheduler', 'nova-conductor', etc.
Possible values:
* Any string representing an existing availability zone name.
"""),
cfg.StrOpt('default_availability_zone',
default='nova',
help="""
Default availability zone for compute services.
This option determines the default availability zone for 'nova-compute'
services, which will be used if the service(s) do not belong to aggregates with
availability zone metadata.
Possible values:
* Any string representing an existing availability zone name.
"""),
cfg.StrOpt('default_schedule_zone',
help="""
Default availability zone for instances.
This option determines the default availability zone for instances, which will
be used when a user does not specify one when creating an instance. The
instance(s) will be bound to this availability zone for their lifetime.
Possible values:
* Any string representing an existing availability zone name.
* None, which means that the instance can move from one availability zone to
another during its lifetime if it is moved from one compute node to another.
Related options:
* ``[cinder]/cross_az_attach``
"""),
]
def register_opts(conf):
conf.register_opts(availability_zone_opts)
def list_opts():
return {'DEFAULT': availability_zone_opts}