Skip to content

Commit da453c2

Browse files
committed
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. Change-Id: I20981c987549eec40ad9762e74b0db16e54f4e63 Closes-Bug: #1830747
1 parent c96c7c5 commit da453c2

File tree

2 files changed

+14
-15
lines changed

2 files changed

+14
-15
lines changed

nova/objects/request_spec.py

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -242,6 +242,8 @@ def _populate_group_info(self, filter_properties):
242242
policies = list(filter_properties.get('group_policies'))
243243
hosts = list(filter_properties.get('group_hosts'))
244244
members = list(filter_properties.get('group_members'))
245+
# TODO(mriedem): We could try to get the group uuid from the
246+
# group hint in the filter_properties.
245247
self.instance_group = objects.InstanceGroup(policy=policies[0],
246248
hosts=hosts,
247249
members=members)
@@ -545,6 +547,12 @@ def _from_db_object(context, spec, db_spec):
545547
spec._context = context
546548

547549
if 'instance_group' in spec and spec.instance_group:
550+
# NOTE(mriedem): We could have a half-baked instance group with no
551+
# uuid if some legacy translation was performed on this spec in the
552+
# past. In that case, try to workaround the issue by getting the
553+
# group uuid from the scheduler hint.
554+
if 'uuid' not in spec.instance_group:
555+
spec.instance_group.uuid = spec.get_scheduler_hint('group')
548556
# NOTE(danms): We don't store the full instance group in
549557
# the reqspec since it would be stale almost immediately.
550558
# Instead, load it by uuid here so it's up-to-date.

nova/tests/functional/regressions/test_bug_1830747.py

Lines changed: 6 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -11,11 +11,9 @@
1111
# under the License.
1212

1313
import mock
14-
import six
1514

1615
from nova.conductor import api as conductor_api
1716
from nova import context as nova_context
18-
from nova import exception
1917
from nova import objects
2018
from nova.scheduler import weights
2119
from nova import test
@@ -142,17 +140,10 @@ def stub_resize_instance(_self, context, instance,
142140
with mock.patch.dict(host1_driver.capabilities,
143141
supports_migrate_to_same_host=False):
144142
self.api.post_server_action(server['id'], {'migrate': None})
145-
# FIXME(mriedem): Due to bug 1830747 we don't go to VERIFY_RESIZE
146-
# because the reschedule fails and the instance is put into
147-
# ERROR status. When the bug is fixed the status should be
148-
# VERIFY_RESIZE and the server should be on host2.
149143
server = self._wait_for_state_change(
150-
self.api, server, 'ERROR')
151-
self.assertEqual('host1', server['OS-EXT-SRV-ATTR:host'])
152-
153-
# And the RequestSpec.instance_group.uuid should be missing which
154-
# leads to us failing to load the RequestSpec.
155-
ex = self.assertRaises(exception.ObjectActionError,
156-
objects.RequestSpec.get_by_instance_uuid,
157-
ctxt, server['id'])
158-
self.assertIn('unable to load uuid', six.text_type(ex))
144+
self.api, server, 'VERIFY_RESIZE')
145+
self.assertEqual('host2', server['OS-EXT-SRV-ATTR:host'])
146+
147+
# The RequestSpec.instance_group.uuid should still be set.
148+
reqspec = objects.RequestSpec.get_by_instance_uuid(ctxt, server['id'])
149+
self.assertEqual(group_id, reqspec.instance_group.uuid)

0 commit comments

Comments
 (0)