From 5c51f272f347690959c0faf02fbc20e08d602e93 Mon Sep 17 00:00:00 2001 From: Alex O'Rourke Date: Thu, 10 Mar 2016 16:09:01 -0800 Subject: [PATCH] Cleanup 3PAR/LeftHand failover_host exceptions The 3PAR and LeftHand drivers were raising the wrong exception, VolumeBackendAPIException, instead of InvalidReplicationTarget, which was putting the host in an unrecoverable state, Change-Id: I1c0ee4adb399dd1e89669477c53f79332a9f79ef Closes-Bug: #1556150 --- cinder/tests/unit/test_hpe3par.py | 6 +++--- cinder/tests/unit/test_hpelefthand.py | 4 ++-- cinder/volume/drivers/hpe/hpe_3par_common.py | 4 ++-- cinder/volume/drivers/hpe/hpe_lefthand_iscsi.py | 4 ++-- 4 files changed, 9 insertions(+), 9 deletions(-) diff --git a/cinder/tests/unit/test_hpe3par.py b/cinder/tests/unit/test_hpe3par.py index 03b963b73..463ce3ee2 100644 --- a/cinder/tests/unit/test_hpe3par.py +++ b/cinder/tests/unit/test_hpe3par.py @@ -4231,7 +4231,7 @@ class HPE3PARBaseDriver(object): volumes = [self.volume_replicated] # Test invalid secondary target. self.assertRaises( - exception.VolumeBackendAPIException, + exception.InvalidReplicationTarget, self.driver.failover_host, context.get_admin_context(), volumes, @@ -4239,7 +4239,7 @@ class HPE3PARBaseDriver(object): # Test no secondary target. self.assertRaises( - exception.VolumeBackendAPIException, + exception.InvalidReplicationTarget, self.driver.failover_host, context.get_admin_context(), volumes, @@ -4349,7 +4349,7 @@ class HPE3PARBaseDriver(object): volume['replication_status'] = 'failed-over' self.assertRaises( - exception.VolumeDriverException, + exception.InvalidReplicationTarget, self.driver.failover_host, context.get_admin_context(), [volume], diff --git a/cinder/tests/unit/test_hpelefthand.py b/cinder/tests/unit/test_hpelefthand.py index 489957ef6..2f0e76a3a 100644 --- a/cinder/tests/unit/test_hpelefthand.py +++ b/cinder/tests/unit/test_hpelefthand.py @@ -2243,7 +2243,7 @@ class TestHPELeftHandISCSIDriver(HPELeftHandBaseDriver, test.TestCase): # Test invalid secondary target. self.assertRaises( - exception.VolumeBackendAPIException, + exception.InvalidReplicationTarget, self.driver.failover_host, ctxt, [self.volume_replicated], @@ -2350,7 +2350,7 @@ class TestHPELeftHandISCSIDriver(HPELeftHandBaseDriver, test.TestCase): volume = self.volume_replicated.copy() self.assertRaises( - exception.VolumeDriverException, + exception.InvalidReplicationTarget, self.driver.failover_host, context.get_admin_context(), [volume], diff --git a/cinder/volume/drivers/hpe/hpe_3par_common.py b/cinder/volume/drivers/hpe/hpe_3par_common.py index 66ed9e63c..92a3f67e7 100644 --- a/cinder/volume/drivers/hpe/hpe_3par_common.py +++ b/cinder/volume/drivers/hpe/hpe_3par_common.py @@ -2890,7 +2890,7 @@ class HPE3PARCommon(object): msg = _("A valid secondary target MUST be specified in order " "to failover.") LOG.error(msg) - raise exception.VolumeBackendAPIException(data=msg) + raise exception.InvalidReplicationTarget(reason=msg) target_id = failover_target['backend_id'] # For each volume, if it is replicated, we want to fail it over. @@ -2947,7 +2947,7 @@ class HPE3PARCommon(object): "resynchronize the volumes and resume replication on the " "3PAR backends.") LOG.error(msg) - raise exception.VolumeDriverException(data=msg) + raise exception.InvalidReplicationTarget(reason=msg) # Update the volumes status to available. volume_update_list = [] diff --git a/cinder/volume/drivers/hpe/hpe_lefthand_iscsi.py b/cinder/volume/drivers/hpe/hpe_lefthand_iscsi.py index 36264f2ed..b7a04439d 100644 --- a/cinder/volume/drivers/hpe/hpe_lefthand_iscsi.py +++ b/cinder/volume/drivers/hpe/hpe_lefthand_iscsi.py @@ -1414,7 +1414,7 @@ class HPELeftHandISCSIDriver(driver.ISCSIDriver): msg = _("A valid secondary target MUST be specified in order " "to failover.") LOG.error(msg) - raise exception.VolumeBackendAPIException(data=msg) + raise exception.InvalidReplicationTarget(reason=msg) target_id = failover_target['backend_id'] self._active_backend_id = target_id @@ -1580,7 +1580,7 @@ class HPELeftHandISCSIDriver(driver.ISCSIDriver): "resynchronize the volumes and resume replication on the " "LeftHand backends.") LOG.error(msg) - raise exception.VolumeDriverException(data=msg) + raise exception.InvalidReplicationTarget(reason=msg) cl = None volume_update_list = [] -- 2.45.2