summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorMatt Riedemann <mriedem.os@gmail.com>2019-05-28 11:24:11 -0400
committerMatt Riedemann <mriedem.os@gmail.com>2019-06-04 17:01:48 -0400
commit3390c7af7ac774163fc8aa43e65662dfcefdc4cc (patch)
treefbc074e04a021602bd6311489197eeed84c6e18d
parentc41fe944dbf554e2d5980595e6155e25e6c0c25b (diff)
downloadnova-3390c7af7ac774163fc8aa43e65662dfcefdc4cc.tar.gz
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 (cherry picked from commit da453c2bfe86ab7a825f0aa7ebced15886f7a5fd) (cherry picked from commit 8569eb9b4fb905cb92041b84c293dc4e7af27fa8) (cherry picked from commit 9fed1803b4d6b2778c47add9c327f0610edc5952) (cherry picked from commit 20b90f2e26e6a46a12c2fd943b4472c3147528fa) (cherry picked from commit 79cc08642172a3df1cd8d7a7c413adc21b468dcf)
-rw-r--r--nova/objects/request_spec.py8
-rw-r--r--nova/tests/functional/regressions/test_bug_1830747.py21
2 files changed, 14 insertions, 15 deletions
diff --git a/nova/objects/request_spec.py b/nova/objects/request_spec.py
index f3529f3cd8..fb3c52948f 100644
--- a/nova/objects/request_spec.py
+++ b/nova/objects/request_spec.py
@@ -197,6 +197,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)
@@ -439,6 +441,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 0ceb45f823..ed9b069868 100644
--- a/nova/tests/functional/regressions/test_bug_1830747.py
+++ b/nova/tests/functional/regressions/test_bug_1830747.py
@@ -11,11 +11,9 @@
# under the License.
import mock
-import six
import nova.conf
from nova import context as nova_context
-from nova import exception
from nova import objects
from nova.scheduler import weights
from nova import test
@@ -137,17 +135,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'])
-
- # 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))
+ self.api, server, 'VERIFY_RESIZE')
+ self.assertEqual('host2', server['OS-EXT-SRV-ATTR:host'])
+
+ # 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)