From cd53a181be22291e6f9be1430cab12ba1f381b8a Mon Sep 17 00:00:00 2001 From: Matt Riedemann Date: Fri, 11 May 2018 14:44:47 -0400 Subject: [PATCH] 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 --- nova/compute/manager.py | 5 ++++- nova/tests/unit/compute/test_compute_mgr.py | 4 ++++ 2 files changed, 8 insertions(+), 1 deletion(-) diff --git a/nova/compute/manager.py b/nova/compute/manager.py index 858961a5ed..a0c192ebbd 100644 --- a/nova/compute/manager.py +++ b/nova/compute/manager.py @@ -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( diff --git a/nova/tests/unit/compute/test_compute_mgr.py b/nova/tests/unit/compute/test_compute_mgr.py index 1dbab19671..3162de2c35 100644 --- a/nova/tests/unit/compute/test_compute_mgr.py +++ b/nova/tests/unit/compute/test_compute_mgr.py @@ -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',