From fddb9c7bc08b893960a5d9a09dfca62b94aa27ed Mon Sep 17 00:00:00 2001 From: Patrick East Date: Wed, 9 Mar 2016 11:08:27 -0800 Subject: [PATCH] Switch failover-host from rpc call to cast MIME-Version: 1.0 Content-Type: text/plain; charset=utf8 Content-Transfer-Encoding: 8bit There is some concern that with large numbers of volumes it will be difficult for drivers to failover the host before the rpc timeout hits. To avoid asking admins to bump the timeout just for these cases we can switch it to do a non-blocking cast instead of call. The difference now being that the active_backend_id is not returned from the API call to failover-host. An admin will have to look at the service-list output to see when it has changed states from ‘failing-over’ and then check what its active_backend_id is at that time. Change-Id: I69b4908fe783cf785d3e1612422fca15fea01c6f Closes-Bug: #1555342 --- cinder/api/contrib/services.py | 10 ++++++---- cinder/tests/unit/test_volume_rpcapi.py | 2 +- cinder/volume/api.py | 5 +---- cinder/volume/manager.py | 4 +--- cinder/volume/rpcapi.py | 4 ++-- 5 files changed, 11 insertions(+), 14 deletions(-) diff --git a/cinder/api/contrib/services.py b/cinder/api/contrib/services.py index c371650be..36a995439 100644 --- a/cinder/api/contrib/services.py +++ b/cinder/api/contrib/services.py @@ -182,10 +182,12 @@ class ServiceController(wsgi.Controller): elif id == "thaw": return self._thaw(context, body['host']) elif id == "failover_host": - return self._failover(context, - body['host'], - body.get('backend_id', - None)) + self._failover( + context, + body['host'], + body.get('backend_id', None) + ) + return webob.Response(status_int=202) else: raise webob.exc.HTTPNotFound(explanation=_("Unknown action")) diff --git a/cinder/tests/unit/test_volume_rpcapi.py b/cinder/tests/unit/test_volume_rpcapi.py index 2cafef66b..845a88c47 100644 --- a/cinder/tests/unit/test_volume_rpcapi.py +++ b/cinder/tests/unit/test_volume_rpcapi.py @@ -593,7 +593,7 @@ class VolumeRpcAPITestCase(test.TestCase): version='1.39') def test_failover_host(self): - self._test_volume_api('failover_host', rpc_method='call', + self._test_volume_api('failover_host', rpc_method='cast', host='fake_host', secondary_backend_id='fake_backend', version='1.39') diff --git a/cinder/volume/api.py b/cinder/volume/api.py index c2c50ca1e..9e99c0e7e 100644 --- a/cinder/volume/api.py +++ b/cinder/volume/api.py @@ -1619,10 +1619,7 @@ class API(base.Base): % expected_status) LOG.error(msg) raise exception.InvalidInput(reason=msg) - active_backend_id = self.volume_rpcapi.failover_host( - ctxt, host, - secondary_id) - return active_backend_id + self.volume_rpcapi.failover_host(ctxt, host, secondary_id) def freeze_host(self, ctxt, host): diff --git a/cinder/volume/manager.py b/cinder/volume/manager.py index d833ff4eb..9c124ad6a 100644 --- a/cinder/volume/manager.py +++ b/cinder/volume/manager.py @@ -3274,7 +3274,6 @@ class VolumeManager(manager.SchedulerDependentManager): :param context: security context :param secondary_backend_id: Specifies backend_id to fail over to - :returns : ID of the backend that was failed-over to """ svc_host = vol_utils.extract_host(self.host, 'backend') @@ -3320,7 +3319,7 @@ class VolumeManager(manager.SchedulerDependentManager): "%(host)s invalid target ID %(backend_id)"), {'host': self.host, 'backend_id': secondary_backend_id}) - return None + return if secondary_backend_id == "default": service.replication_status = fields.ReplicationStatus.ENABLED @@ -3351,7 +3350,6 @@ class VolumeManager(manager.SchedulerDependentManager): vobj.save() LOG.info(_LI("Failed over to replication target successfully.")) - return active_backend_id def freeze_host(self, context): """Freeze management plane on this backend. diff --git a/cinder/volume/rpcapi.py b/cinder/volume/rpcapi.py index 78a0b1805..9ea2fd5aa 100644 --- a/cinder/volume/rpcapi.py +++ b/cinder/volume/rpcapi.py @@ -328,8 +328,8 @@ class VolumeAPI(rpc.RPCAPI): secondary_backend_id=None): """Failover host to the specified backend_id (secondary). """ cctxt = self._get_cctxt(host, '1.39') - return cctxt.call(ctxt, 'failover_host', - secondary_backend_id=secondary_backend_id) + cctxt.cast(ctxt, 'failover_host', + secondary_backend_id=secondary_backend_id) def manage_existing_snapshot(self, ctxt, snapshot, ref, host): cctxt = self._get_cctxt(host, '1.28') -- 2.45.2