Workaround missing RequestSpec.instance_group.uuid
It's clear that we could have a RequestSpec.instance_group without a uuid field if the InstanceGroup is set from the _populate_group_info method which should only be used for legacy translation of request specs using legacy filter properties dicts. To workaround the issue, we look for the group scheduler hint to get the group uuid before loading it from the DB. The related functional regression recreate test is updated to show this solves the issue. Conflicts: nova/objects/request_spec.py NOTE(mriedem): The conflict is due to not having change Ib33719a4b9599d86848c618a6e142c71ece79ca5 in Queens. Change-Id: I20981c987549eec40ad9762e74b0db16e54f4e63 Closes-Bug: #1830747 (cherry picked from commitda453c2bfe
) (cherry picked from commit8569eb9b4f
) (cherry picked from commit9fed1803b4
)
This commit is contained in:
parent
581df2c986
commit
20b90f2e26
|
@ -205,6 +205,8 @@ class RequestSpec(base.NovaObject):
|
||||||
policies = list(filter_properties.get('group_policies'))
|
policies = list(filter_properties.get('group_policies'))
|
||||||
hosts = list(filter_properties.get('group_hosts'))
|
hosts = list(filter_properties.get('group_hosts'))
|
||||||
members = list(filter_properties.get('group_members'))
|
members = list(filter_properties.get('group_members'))
|
||||||
|
# TODO(mriedem): We could try to get the group uuid from the
|
||||||
|
# group hint in the filter_properties.
|
||||||
self.instance_group = objects.InstanceGroup(policies=policies,
|
self.instance_group = objects.InstanceGroup(policies=policies,
|
||||||
hosts=hosts,
|
hosts=hosts,
|
||||||
members=members)
|
members=members)
|
||||||
|
@ -461,6 +463,12 @@ class RequestSpec(base.NovaObject):
|
||||||
spec._context = context
|
spec._context = context
|
||||||
|
|
||||||
if 'instance_group' in spec and spec.instance_group:
|
if 'instance_group' in spec and spec.instance_group:
|
||||||
|
# NOTE(mriedem): We could have a half-baked instance group with no
|
||||||
|
# uuid if some legacy translation was performed on this spec in the
|
||||||
|
# past. In that case, try to workaround the issue by getting the
|
||||||
|
# group uuid from the scheduler hint.
|
||||||
|
if 'uuid' not in spec.instance_group:
|
||||||
|
spec.instance_group.uuid = spec.get_scheduler_hint('group')
|
||||||
# NOTE(danms): We don't store the full instance group in
|
# NOTE(danms): We don't store the full instance group in
|
||||||
# the reqspec since it would be stale almost immediately.
|
# the reqspec since it would be stale almost immediately.
|
||||||
# Instead, load it by uuid here so it's up-to-date.
|
# Instead, load it by uuid here so it's up-to-date.
|
||||||
|
|
|
@ -11,10 +11,8 @@
|
||||||
# under the License.
|
# under the License.
|
||||||
|
|
||||||
import mock
|
import mock
|
||||||
import six
|
|
||||||
|
|
||||||
from nova import context as nova_context
|
from nova import context as nova_context
|
||||||
from nova import exception
|
|
||||||
from nova import objects
|
from nova import objects
|
||||||
from nova.scheduler import weights
|
from nova.scheduler import weights
|
||||||
from nova import test
|
from nova import test
|
||||||
|
@ -124,17 +122,10 @@ class MissingReqSpecInstanceGroupUUIDTestCase(
|
||||||
with mock.patch.dict(host1_driver.capabilities,
|
with mock.patch.dict(host1_driver.capabilities,
|
||||||
supports_migrate_to_same_host=False):
|
supports_migrate_to_same_host=False):
|
||||||
self.api.post_server_action(server['id'], {'migrate': None})
|
self.api.post_server_action(server['id'], {'migrate': None})
|
||||||
# FIXME(mriedem): Due to bug 1830747 we don't go to VERIFY_RESIZE
|
|
||||||
# because the reschedule fails and the instance is put into
|
|
||||||
# ERROR status. When the bug is fixed the status should be
|
|
||||||
# VERIFY_RESIZE and the server should be on host2.
|
|
||||||
server = self._wait_for_state_change(
|
server = self._wait_for_state_change(
|
||||||
self.api, server, 'ERROR')
|
self.api, server, 'VERIFY_RESIZE')
|
||||||
self.assertEqual('host1', server['OS-EXT-SRV-ATTR:host'])
|
self.assertEqual('host2', server['OS-EXT-SRV-ATTR:host'])
|
||||||
|
|
||||||
# And the RequestSpec.instance_group.uuid should be missing which
|
# The RequestSpec.instance_group.uuid should still be set.
|
||||||
# leads to us failing to load the RequestSpec.
|
reqspec = objects.RequestSpec.get_by_instance_uuid(ctxt, server['id'])
|
||||||
ex = self.assertRaises(exception.ObjectActionError,
|
self.assertEqual(group_id, reqspec.instance_group.uuid)
|
||||||
objects.RequestSpec.get_by_instance_uuid,
|
|
||||||
ctxt, server['id'])
|
|
||||||
self.assertIn('unable to load uuid', six.text_type(ex))
|
|
||||||
|
|
Loading…
Reference in New Issue