Don't reschedule on RequestedVRamTooHigh errors

The libvirt driver validates the hw_video_ram image property,
if specified, and the flavor extra spec "hw_video:ram_max_mb"
is set. If validation fails, the libvirt driver raises
RequestedVRamTooHigh which is not handled explicitly in
ComputeManager._build_and_run_instance so it will result in
a RescheduledException to another compute to retry the spawn
but that will always fail because this isn't something that
is per-compute host.

This change adds the error handling in _build_and_run_instance
so that we'll fail and abort the build and not reschedule.

Long-term, this validation should be moved into the API code
since it's not specific to a compute host and would be user
error that should result in a 400 response.

Change-Id: I93b409ca2b7b36400759ee9d2cd5b71c6df186ab
Partial-Bug: #1770726
This commit is contained in:
Matt Riedemann
2018-05-11 14:44:47 -04:00
parent 1da469010f
commit cd53a181be
2 changed files with 8 additions and 1 deletions
+4 -1
View File
@@ -2083,7 +2083,10 @@ class ComputeManager(manager.Manager):
exception.InvalidDiskFormat,
cursive_exception.SignatureVerificationError,
exception.VolumeEncryptionNotSupported,
exception.InvalidInput) as e:
exception.InvalidInput,
# TODO(mriedem): We should be validating RequestedVRamTooHigh
# in the API during server create and rebuild.
exception.RequestedVRamTooHigh) as e:
self._notify_about_instance_usage(context, instance,
'create.error', fault=e)
compute_utils.notify_about_instance_create(
@@ -5466,6 +5466,10 @@ class ComputeManagerBuildInstanceTestCase(test.NoDBTestCase):
self._test_build_and_run_spawn_exceptions(
exception.InvalidInput(reason=""))
def test_build_and_run_requested_vram_too_high(self):
self._test_build_and_run_spawn_exceptions(
exception.RequestedVRamTooHigh(req_vram=200, max_vram=100))
def _test_build_and_run_spawn_exceptions(self, exc):
with test.nested(
mock.patch.object(self.compute.driver, 'spawn',