]> review.fuel-infra Code Review - openstack-build/cinder-build.git/commitdiff
Switch failover-host from rpc call to cast
authorPatrick East <patrick.east@purestorage.com>
Wed, 9 Mar 2016 19:08:27 +0000 (11:08 -0800)
committerPatrick East <patrick.east@purestorage.com>
Wed, 9 Mar 2016 21:50:52 +0000 (13:50 -0800)
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
cinder/tests/unit/test_volume_rpcapi.py
cinder/volume/api.py
cinder/volume/manager.py
cinder/volume/rpcapi.py

index c371650be48efd1e5b3b8e078c671ac7a65df445..36a9954396192073c37c00d84b8a2ce6d1b6ec94 100644 (file)
@@ -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"))
 
index 2cafef66bc9cbe2e70e6f48e6ab9980a36e4497b..845a88c47bf4961699cdbe51bfa8d5a85fdfbf64 100644 (file)
@@ -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')
index c2c50ca1e3a19dbf1a1dd28ca33447c24ef67ace..9e99c0e7ea897aa703156464d743a5cd2a712658 100644 (file)
@@ -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):
 
index d833ff4ebd1b21ae5b3770a50038d7819eecf201..9c124ad6a1886f5f1958fda980a02362014e077c 100644 (file)
@@ -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.
index 78a0b18053068141426823f4b2793c41a87b9fec..9ea2fd5aa14caa0ea047338cf4b04274f723bb31 100644 (file)
@@ -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')