nova/nova/compute
Stephen Finucane 58782403cd api: Align availability zone info with forced host
Users can create a server like so:

  $ openstack server create --availability-zone az:host ...

This is a historical way to request that an instance be scheduled to a
specific host and it causes the scheduler to be bypassed. However, no
validation of this availability zone-host combo takes place. The host
could in fact belong to a different availability zone. If it does, we'll
end up in a very odd situation whereby the RequestSpec record for the
instance will record the availability zone requested by the user at
create time, but the Instance record itself will record the availability
zone of the host on which the instance was scheduled. This leads to even
more confusing behavior when we attempt to do something like live
migrate the instance since the RequestSpec record, with its original and
possibly invalid availability zone information, is used. The
'AvailabilityZoneFilter' will fail an error message like the following:

  Availability Zone 'foo' requested. ... has AZs: bar

but the 'openstack server list --long' command will show a non-foo value
for the availability zone column.

The solution is simple: when given an availability zone-host combo, make
sure the availability zone requested matches that of the host (or, more
specifically, the host is a member of the host aggregates that form the
availability zone [1]). If not, simply ignore the requested availability
zone information in favour of using the availability zone of the host,
logging a warning just for record keeping purposes. This is deemed
preferable to failing with HTTP 400 (Bad Request) since what users are
really requesting by using this was to schedule to a specific host: the
availability zone portion of the request is really irrelevant and just
an artifact of this legacy mechanism to request hosts. If users wish to
truly validate a host-availability zone combo, they can use the 'host'
field introduced in microversion 2.74 along with the 'availability_zone'
field:

  $ openstack server create --availability-zone az --host host ...

Conflicts:
  nova/compute/api.py

NOTE(stephenfin): Conflicts are trivial and due to the absence of change
I81fec10535034f3a81d46713a6eda813f90561cf ("Remove references to
'instance_type'") which we don't want to backport here.

[1] https://docs.openstack.org/nova/latest/admin/aggregates.html

Change-Id: Iac0e634e66cd4e150a50935cf635f626fc11b70e
Signed-off-by: Stephen Finucane <stephenfin@redhat.com>
Closes-Bug: #1934770
(cherry picked from commit 8f21ee42bd)
2021-07-26 09:26:59 +01:00
..
monitors Remove six.add_metaclass 2020-08-15 07:45:39 +00:00
__init__.py Remove nova.compute.*API() shims 2019-06-12 16:09:46 +01:00
api.py api: Align availability zone info with forced host 2021-07-26 09:26:59 +01:00
build_results.py
claims.py objects: Add MigrationTypeField 2020-05-08 14:45:54 +01:00
flavors.py Remove six.text_type (1/2) 2020-12-13 11:25:31 +00:00
instance_actions.py api: Log os-resetState as an instance action 2021-01-18 09:19:58 +00:00
instance_list.py Plumbing for ignoring list_records_by_skipping_down_cells 2019-02-08 16:28:28 -05:00
manager.py Merge "Update SRIOV port pci_slot when unshelving" into stable/wallaby 2021-07-03 05:08:00 +00:00
migration_list.py Refactor scatter-gather utility to return exception objects 2018-10-31 15:18:07 -04:00
multi_cell_list.py Remove six.add_metaclass 2020-08-15 07:45:39 +00:00
power_state.py Removed enum duplication from nova.compute 2016-09-02 07:30:44 +00:00
provider_config.py Provider Config File: Coding style and test cases improvement 2020-09-01 01:05:34 +00:00
provider_tree.py Remove six.iteritems/itervalues/iterkeys 2020-11-07 03:25:26 +00:00
resource_tracker.py pci manager: replace node_id parameter with compute_node 2021-03-08 15:18:46 -05:00
rpcapi.py Bump the Compute RPC API to version 6.0 2021-03-25 11:23:07 +01:00
stats.py Change consecutive build failure limit to a weigher 2018-06-06 15:18:50 -07:00
task_states.py Fix resource tracker updates during instance evacuation 2018-09-12 13:05:29 +03:00
utils.py Merge "Refactor update_pci_request_spec_with_allocated_interface_name" 2021-01-28 22:20:03 +00:00
vm_states.py Removed enum duplication from nova.compute 2016-09-02 07:30:44 +00:00