diff --git a/nova/scheduler/filters/isolated_hosts_filter.py b/nova/scheduler/filters/isolated_hosts_filter.py index 86ab1c4ce901..3402ecd49ac7 100644 --- a/nova/scheduler/filters/isolated_hosts_filter.py +++ b/nova/scheduler/filters/isolated_hosts_filter.py @@ -59,7 +59,10 @@ class IsolatedHostsFilter(filters.BaseHostFilter): return ((not restrict_isolated_hosts_to_isolated_images) or (host_state.host not in isolated_hosts)) - image_ref = spec_obj.image.id if spec_obj.image else None + # Check to see if the image id is set since volume-backed instances + # can be created without an imageRef in the server create request. + image_ref = spec_obj.image.id \ + if spec_obj.image and 'id' in spec_obj.image else None image_isolated = image_ref in isolated_images host_isolated = host_state.host in isolated_hosts diff --git a/nova/tests/functional/regressions/test_bug_1746483.py b/nova/tests/functional/regressions/test_bug_1746483.py index 9e55030f31e0..64dc0c6731ee 100644 --- a/nova/tests/functional/regressions/test_bug_1746483.py +++ b/nova/tests/functional/regressions/test_bug_1746483.py @@ -92,7 +92,11 @@ class TestBootFromVolumeIsolatedHostsFilter( # networks='none'. with utils.temporary_mutation(self.api, microversion='2.37'): server = self.api.post_server(server_req_body) - server = self._wait_for_state_change(self.api, server, 'ERROR') - # Due to bug 1746483 we expect scheduling to fail. - self.assertIn("Cannot load 'id' in the base class", - server['fault']['message']) + server = self._wait_for_state_change(self.api, server, 'ACTIVE') + # NOTE(mriedem): The instance is successfully scheduled but since + # the image_id from the volume_image_metadata isn't stored in the + # RequestSpec.image.id, and restrict_isolated_hosts_to_isolated_images + # is True, the isolated host (host1) is filtered out because the + # filter doesn't have enough information to know if the image within + # the volume can be used on that host. + self.assertEqual('host2', server['OS-EXT-SRV-ATTR:host'])