summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorZuul <zuul@review.opendev.org>2019-07-01 21:19:46 +0000
committerGerrit Code Review <review@openstack.org>2019-07-01 21:19:46 +0000
commit40920843bfc9abfc8a3e139c48bdf733e6ba4af5 (patch)
tree85ae03d33ec683d2130a318ca583704f104a1823
parentfb947ca68ce5ef6a1ba2ad6618a30d50d3e0428d (diff)
parent20b90f2e26e6a46a12c2fd943b4472c3147528fa (diff)
downloadnova-40920843bfc9abfc8a3e139c48bdf733e6ba4af5.tar.gz
Merge "Workaround missing RequestSpec.instance_group.uuid" into stable/queens
-rw-r--r--nova/objects/request_spec.py8
-rw-r--r--nova/tests/functional/regressions/test_bug_1830747.py19
2 files changed, 13 insertions, 14 deletions
diff --git a/nova/objects/request_spec.py b/nova/objects/request_spec.py
index 6cb5de1c15..62812944d1 100644
--- a/nova/objects/request_spec.py
+++ b/nova/objects/request_spec.py
@@ -205,6 +205,8 @@ class RequestSpec(base.NovaObject):
policies = list(filter_properties.get('group_policies'))
hosts = list(filter_properties.get('group_hosts'))
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,
hosts=hosts,
members=members)
@@ -461,6 +463,12 @@ class RequestSpec(base.NovaObject):
spec._context = context
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
# the reqspec since it would be stale almost immediately.
# Instead, load it by uuid here so it's up-to-date.
diff --git a/nova/tests/functional/regressions/test_bug_1830747.py b/nova/tests/functional/regressions/test_bug_1830747.py
index 37a216c4ea..b7a6bc076a 100644
--- a/nova/tests/functional/regressions/test_bug_1830747.py
+++ b/nova/tests/functional/regressions/test_bug_1830747.py
@@ -11,10 +11,8 @@
# under the License.
import mock
-import six
from nova import context as nova_context
-from nova import exception
from nova import objects
from nova.scheduler import weights
from nova import test
@@ -124,17 +122,10 @@ class MissingReqSpecInstanceGroupUUIDTestCase(
with mock.patch.dict(host1_driver.capabilities,
supports_migrate_to_same_host=False):
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(
- self.api, server, 'ERROR')
- self.assertEqual('host1', server['OS-EXT-SRV-ATTR:host'])
+ self.api, server, 'VERIFY_RESIZE')
+ self.assertEqual('host2', server['OS-EXT-SRV-ATTR:host'])
- # And the RequestSpec.instance_group.uuid should be missing which
- # leads to us failing to load the RequestSpec.
- ex = self.assertRaises(exception.ObjectActionError,
- objects.RequestSpec.get_by_instance_uuid,
- ctxt, server['id'])
- self.assertIn('unable to load uuid', six.text_type(ex))
+ # The RequestSpec.instance_group.uuid should still be set.
+ reqspec = objects.RequestSpec.get_by_instance_uuid(ctxt, server['id'])
+ self.assertEqual(group_id, reqspec.instance_group.uuid)