diff options
author | Matt Riedemann <mriedem.os@gmail.com> | 2018-08-31 18:14:25 -0400 |
---|---|---|
committer | Matt Riedemann <mriedem.os@gmail.com> | 2018-09-28 14:25:19 -0400 |
commit | de7e5ae4e4786d3275e2ada688032a4a1cbc055a (patch) | |
tree | a52f988c1ac3bdc50fed18b6dbaeed5a35dba893 | |
parent | 88a8db4fa207dfdf6e09eec7cde397262fd573f2 (diff) | |
download | nova-de7e5ae4e4786d3275e2ada688032a4a1cbc055a.tar.gz |
Null out instance.availability_zone on shelve offload
When a user shelve offloads a server, the compute manager
nulls out the instance host and node attributes. However
the availability_zone attribute is left set on the instance
so the API will show the instance as in an AZ when really
it's not, because an instance that is not on a host is not
in a host aggregate so it can't be in an AZ.
Keep in mind that there are two ways an instance can be in
an AZ:
1. The user specifically requests to create the server in
the AZ.
2. The user does not request an AZ and one is assigned via
the selected host during server create (or resize, etc).
For the first case, the server will always remain in the
user-requested AZ even after shelve/unshelve. But in the
second case, unshelving the server can result in the server
being spawned on a new host in a different AZ - the scheduler
does not restrict the AZ in that second case.
This change nulls out the instance.availability_zone just like
the host and node fields on shelve offload since it's
confusing to show a shelved offloaded server in an AZ that
doesn't have a host.
Final note: the _nil_out_instance_obj_host_and_node method
is also called during server create if the build fails and
is aborted or rescheduled to another host, and in the case
that unshelve fails. In the case of a server build reschedule,
conductor will set the instance.availability_zone appropriately
based on the alternate host for the reschedule. In the other
failure cases, leaving the instance AZ null is appropriate.
Change-Id: I25a4f36027390def83cfe25f4f3b4af9660da502
Closes-Bug: #1790221
(cherry picked from commit 771b9eaa71742b7a158c2e7759a3046ea5a6fc3a)
(cherry picked from commit b3060a9d3103fb8ade6ebeaa53cb4dd39308f8af)
(cherry picked from commit 437211bf37aacb6bc9490e2443984a4428c70779)
-rw-r--r-- | doc/notification_samples/instance-shelve_offload-end.json | 2 | ||||
-rw-r--r-- | nova/compute/manager.py | 3 | ||||
-rw-r--r-- | nova/tests/functional/test_servers.py | 3 |
3 files changed, 6 insertions, 2 deletions
diff --git a/doc/notification_samples/instance-shelve_offload-end.json b/doc/notification_samples/instance-shelve_offload-end.json index b82bf47474..8967539753 100644 --- a/doc/notification_samples/instance-shelve_offload-end.json +++ b/doc/notification_samples/instance-shelve_offload-end.json @@ -3,7 +3,7 @@ "payload":{ "nova_object.data":{ "architecture":"x86_64", - "availability_zone": "nova", + "availability_zone": null, "block_devices": [{ "nova_object.data": { "boot_index": null, diff --git a/nova/compute/manager.py b/nova/compute/manager.py index 104aff1725..7d85bfc275 100644 --- a/nova/compute/manager.py +++ b/nova/compute/manager.py @@ -576,6 +576,9 @@ class ComputeManager(manager.Manager): # to the database layer. instance.host = None instance.node = None + # If the instance is not on a host, it's not in an aggregate and + # therefore is not in an availability zone. + instance.availability_zone = None def _set_instance_obj_error_state(self, context, instance, clean_task_state=False): diff --git a/nova/tests/functional/test_servers.py b/nova/tests/functional/test_servers.py index f4830f9e6f..0809b689dd 100644 --- a/nova/tests/functional/test_servers.py +++ b/nova/tests/functional/test_servers.py @@ -2248,7 +2248,8 @@ class ServerMovingTests(ProviderUsageBaseTestCase): self.api.post_server_action(server['id'], req) self._wait_for_server_parameter( self.api, server, {'status': 'SHELVED_OFFLOADED', - 'OS-EXT-SRV-ATTR:host': None}) + 'OS-EXT-SRV-ATTR:host': None, + 'OS-EXT-AZ:availability_zone': ''}) source_usages = self._get_provider_usages(source_rp_uuid) self.assertEqual({'VCPU': 0, 'MEMORY_MB': 0, |