Merge "Fix status after a VolumeDriverException"

This commit is contained in:
Jenkins 2016-12-19 02:48:20 +00:00 committed by Gerrit Code Review
commit 824dad4e16
2 changed files with 18 additions and 1 deletions

View File

@ -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)

View File

@ -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: