Merge "Make resize raise exception when no valid host found"
This commit is contained in:
commit
736778e370
|
@ -159,6 +159,8 @@ class AdminActionsController(wsgi.Controller):
|
|||
'migrate')
|
||||
except exception.InstanceNotFound as e:
|
||||
raise exc.HTTPNotFound(explanation=e.format_message())
|
||||
except exception.NoValidHost as e:
|
||||
raise exc.HTTPBadRequest(explanation=e.format_message())
|
||||
except Exception as e:
|
||||
LOG.exception(_("Error in migrate %s"), e)
|
||||
raise exc.HTTPBadRequest()
|
||||
|
|
|
@ -63,6 +63,9 @@ class MigrateServerController(wsgi.Controller):
|
|||
'migrate')
|
||||
except exception.InstanceNotFound as e:
|
||||
raise exc.HTTPNotFound(explanation=e.format_message())
|
||||
except exception.NoValidHost as e:
|
||||
raise exc.HTTPBadRequest(explanation=e.format_message())
|
||||
|
||||
return webob.Response(status_int=202)
|
||||
|
||||
@extensions.expected_errors((400, 404, 409))
|
||||
|
|
|
@ -1189,6 +1189,8 @@ class Controller(wsgi.Controller):
|
|||
except exception.Invalid:
|
||||
msg = _("Invalid instance image.")
|
||||
raise exc.HTTPBadRequest(explanation=msg)
|
||||
except exception.NoValidHost as e:
|
||||
raise exc.HTTPBadRequest(explanation=e.format_message())
|
||||
|
||||
return webob.Response(status_int=202)
|
||||
|
||||
|
|
|
@ -520,9 +520,8 @@ class ComputeTaskManager(base.Base):
|
|||
updates, ex, request_spec)
|
||||
quotas.rollback()
|
||||
|
||||
LOG.warning(_("No valid host found for cold migrate"),
|
||||
instance=instance)
|
||||
return
|
||||
msg = _("No valid host found for cold migrate")
|
||||
raise exception.NoValidHost(reason=msg)
|
||||
|
||||
try:
|
||||
scheduler_utils.populate_filter_properties(filter_properties,
|
||||
|
|
|
@ -16,6 +16,7 @@
|
|||
import base64
|
||||
import uuid
|
||||
|
||||
import mock
|
||||
import mox
|
||||
from oslo.config import cfg
|
||||
import webob
|
||||
|
@ -866,6 +867,16 @@ class ServerActionsControllerTest(test.TestCase):
|
|||
self.controller._action_resize,
|
||||
req, FAKE_UUID, body)
|
||||
|
||||
@mock.patch('nova.compute.api.API.resize',
|
||||
side_effect=exception.NoValidHost(reason=''))
|
||||
def test_resize_raises_no_valid_host(self, mock_resize):
|
||||
body = dict(resize=dict(flavorRef="http://localhost/3"))
|
||||
|
||||
req = fakes.HTTPRequest.blank(self.url)
|
||||
self.assertRaises(webob.exc.HTTPBadRequest,
|
||||
self.controller._action_resize,
|
||||
req, FAKE_UUID, body)
|
||||
|
||||
def test_confirm_resize_server(self):
|
||||
body = dict(confirmResize=None)
|
||||
|
||||
|
|
|
@ -1648,8 +1648,10 @@ class ConductorTaskTestCase(_BaseTaskTestCase, test_compute.BaseTestCase):
|
|||
|
||||
self.mox.ReplayAll()
|
||||
|
||||
self.conductor._cold_migrate(self.context, inst_obj,
|
||||
'flavor', filter_props, [resvs])
|
||||
self.assertRaises(exc.NoValidHost,
|
||||
self.conductor._cold_migrate,
|
||||
self.context, inst_obj,
|
||||
'flavor', filter_props, [resvs])
|
||||
|
||||
def test_cold_migrate_no_valid_host_back_in_stopped_state(self):
|
||||
inst = fake_instance.fake_db_instance(image_ref='fake-image_ref',
|
||||
|
@ -1701,8 +1703,9 @@ class ConductorTaskTestCase(_BaseTaskTestCase, test_compute.BaseTestCase):
|
|||
|
||||
self.mox.ReplayAll()
|
||||
|
||||
self.conductor._cold_migrate(self.context, inst_obj,
|
||||
'flavor', filter_props, [resvs])
|
||||
self.assertRaises(exc.NoValidHost,
|
||||
self.conductor._cold_migrate, self.context,
|
||||
inst_obj, 'flavor', filter_props, [resvs])
|
||||
|
||||
def test_cold_migrate_exception_host_in_error_state_and_raise(self):
|
||||
inst = fake_instance.fake_db_instance(image_ref='fake-image_ref',
|
||||
|
|
|
@ -1970,7 +1970,8 @@ class AdminActionsSamplesJsonTest(ServersSampleBase):
|
|||
'admin-actions-resume', {})
|
||||
self.assertEqual(response.status, 202)
|
||||
|
||||
def test_post_migrate(self):
|
||||
@mock.patch('nova.conductor.manager.ComputeTaskManager._cold_migrate')
|
||||
def test_post_migrate(self, mock_cold_migrate):
|
||||
# Get api samples to migrate server request.
|
||||
response = self._do_post('servers/%s/action' % self.uuid,
|
||||
'admin-actions-migrate', {})
|
||||
|
|
|
@ -13,6 +13,8 @@
|
|||
# License for the specific language governing permissions and limitations
|
||||
# under the License.
|
||||
|
||||
import mock
|
||||
|
||||
from nova.conductor import manager as conductor_manager
|
||||
from nova import db
|
||||
from nova.tests.integrated.v3 import test_servers
|
||||
|
@ -30,7 +32,8 @@ class MigrateServerSamplesJsonTest(test_servers.ServersSampleBase):
|
|||
super(MigrateServerSamplesJsonTest, self).setUp()
|
||||
self.uuid = self._post_server()
|
||||
|
||||
def test_post_migrate(self):
|
||||
@mock.patch('nova.conductor.manager.ComputeTaskManager._cold_migrate')
|
||||
def test_post_migrate(self, mock_cold_migrate):
|
||||
# Get api samples to migrate server request.
|
||||
response = self._do_post('servers/%s/action' % self.uuid,
|
||||
'migrate-server', {})
|
||||
|
|
Loading…
Reference in New Issue