diff --git a/cinder/tests/unit/volume/test_replication_manager.py b/cinder/tests/unit/volume/test_replication_manager.py index 0c20ae4e450..3cc2a48e863 100644 --- a/cinder/tests/unit/volume/test_replication_manager.py +++ b/cinder/tests/unit/volume/test_replication_manager.py @@ -62,3 +62,18 @@ class ReplicationTestCase(base.BaseVolumeTestCase): db_svc = objects.Service.get_by_id(self.context, svc.id) self.assertEqual(expected, db_svc.replication_status) + + @mock.patch('cinder.volume.driver.BaseVD.failover_host', + mock.Mock(side_effect=exception.VolumeDriverException(''))) + def test_failover_host_driver_exception(self): + svc = utils.create_service( + self.context, + host=self.host, + active_backend_id=None, + replication_status=fields.ReplicationStatus.FAILING_OVER) + + self.manager.failover_host(self.context, mock.sentinel.backend_id) + + db_svc = objects.Service.get_by_id(self.context, svc.id) + self.assertEqual(fields.ReplicationStatus.FAILOVER_ERROR, + db_svc.replication_status) diff --git a/cinder/volume/manager.py b/cinder/volume/manager.py index 45e5e05c215..ae7948b2378 100644 --- a/cinder/volume/manager.py +++ b/cinder/volume/manager.py @@ -4075,7 +4075,9 @@ class VolumeManager(manager.CleanableManager, # backend is still set as primary as per driver memory LOG.error(_LE("Driver reported error during " "replication failover.")) - service.status = 'error' + service.replication_status = ( + fields.ReplicationStatus.FAILOVER_ERROR) + service.disabled = True service.save() exception_encountered = True if exception_encountered: