nova/nova/tests/unit/policies
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
..
__init__.py Add test coverage of existing os-services policies 2019-11-25 17:27:32 +00:00
base.py Few todo fixes for API new policies 2020-08-22 09:35:29 -05:00
test_admin_actions.py virt: Remove 'reset_network' API 2020-11-23 15:55:50 +00:00
test_admin_password.py Few todo fixes for API new policies 2020-08-22 09:35:29 -05:00
test_aggregates.py Few todo fixes for API new policies 2020-08-22 09:35:29 -05:00
test_assisted_volume_snapshots.py Few todo fixes for API new policies 2020-08-22 09:35:29 -05:00
test_attach_interfaces.py [Trivial] Replace ref of policy.json to policy.yaml 2020-09-09 16:46:43 +00:00
test_availability_zone.py Few todo fixes for API new policies 2020-08-22 09:35:29 -05:00
test_baremetal_nodes.py Add new default roles in baremetal nodes policies 2020-08-17 14:36:38 +00:00
test_console_auth_tokens.py Few todo fixes for API new policies 2020-08-22 09:35:29 -05:00
test_console_output.py Few todo fixes for API new policies 2020-08-22 09:35:29 -05:00
test_create_backup.py Few todo fixes for API new policies 2020-08-22 09:35:29 -05:00
test_deferred_delete.py Few todo fixes for API new policies 2020-08-22 09:35:29 -05:00
test_evacuate.py Remove compute service level check for qos ops 2020-11-09 16:13:51 +01:00
test_extensions.py Add scope and new default roles in extensions policies 2020-08-17 09:40:02 -05:00
test_flavor_access.py Few todo fixes for API new policies 2020-08-22 09:35:29 -05:00
test_flavor_extra_specs.py Add new default roles in flavor extra specs policies 2020-04-14 00:33:38 +00:00
test_flavor_manage.py Few todo fixes for API new policies 2020-08-22 09:35:29 -05:00
test_floating_ip_pools.py Correct the check_str and pass actual target in FIP pools policy 2020-07-20 16:53:02 -05:00
test_floating_ips.py Few todo fixes for API new policies 2020-08-22 09:35:29 -05:00
test_hosts.py Add new default roles in hosts policies 2020-07-25 21:20:00 +00:00
test_hypervisors.py Few todo fixes for API new policies 2020-08-22 09:35:29 -05:00
test_instance_actions.py [Trivial] Replace ref of policy.json to policy.yaml 2020-09-09 16:46:43 +00:00
test_instance_usage_audit_log.py Few todo fixes for API new policies 2020-08-22 09:35:29 -05:00
test_keypairs.py Few todo fixes for API new policies 2020-08-22 09:35:29 -05:00
test_limits.py Few todo fixes for API new policies 2020-08-22 09:35:29 -05:00
test_lock_server.py Few todo fixes for API new policies 2020-08-22 09:35:29 -05:00
test_migrate_server.py Remove compute service level check for qos ops 2020-11-09 16:13:51 +01:00
test_migrations.py Few todo fixes for API new policies 2020-08-22 09:35:29 -05:00
test_multinic.py Few todo fixes for API new policies 2020-08-22 09:35:29 -05:00
test_networks.py Few todo fixes for API new policies 2020-08-22 09:35:29 -05:00
test_pause_server.py Few todo fixes for API new policies 2020-08-22 09:35:29 -05:00
test_quota_class_sets.py Few todo fixes for API new policies 2020-08-22 09:35:29 -05:00
test_quota_sets.py Add new default roles in quota sets policies 2020-04-13 19:25:14 -05:00
test_remote_consoles.py Few todo fixes for API new policies 2020-08-22 09:35:29 -05:00
test_rescue.py Few todo fixes for API new policies 2020-08-22 09:35:29 -05:00
test_security_groups.py Few todo fixes for API new policies 2020-08-22 09:35:29 -05:00
test_server_diagnostics.py Few todo fixes for API new policies 2020-08-22 09:35:29 -05:00
test_server_external_events.py Few todo fixes for API new policies 2020-08-22 09:35:29 -05:00
test_server_groups.py Few todo fixes for API new policies 2020-08-22 09:35:29 -05:00
test_server_ips.py Few todo fixes for API new policies 2020-08-22 09:35:29 -05:00
test_server_metadata.py Add new default roles in server metadata policies 2020-04-04 00:58:48 +00:00
test_server_migrations.py Few todo fixes for API new policies 2020-08-22 09:35:29 -05:00
test_server_password.py Add new default roles in server password policies 2020-04-08 14:46:10 +01:00
test_server_tags.py Add new default roles in server tags policies 2020-04-07 00:27:17 -05:00
test_server_topology.py objects: Introduce 'pcpuset' field for InstanceNUMACell 2020-07-14 00:38:34 +08:00
test_servers.py api: Align availability zone info with forced host 2021-07-26 09:26:59 +01:00
test_services.py [Trivial] Replace ref of policy.json to policy.yaml 2020-09-09 16:46:43 +00:00
test_shelve.py Few todo fixes for API new policies 2020-08-22 09:35:29 -05:00
test_simple_tenant_usage.py Add new default roles in tenant tenant usage policies 2020-04-08 22:21:48 -05:00
test_suspend_server.py Few todo fixes for API new policies 2020-08-22 09:35:29 -05:00
test_tenant_networks.py Add test coverage of tenant networks policies 2020-07-23 19:18:35 -05:00
test_volumes.py Few todo fixes for API new policies 2020-08-22 09:35:29 -05:00