From 245a488c36003764e3550c2c95fa4bef6119e0ea Mon Sep 17 00:00:00 2001 From: Jon Bernard Date: Thu, 22 Mar 2018 08:09:35 -0700 Subject: [PATCH] RBD: add support for active/active replication This patch breaks failover_host into the two requisite parts (failover and failover_completed) to support both single-backend and multiple backends configured as active/active. Change-Id: Ie59ba9ad538b2e607dd7ccabc0fbb035a6acf3b0 --- cinder/tests/unit/volume/drivers/test_rbd.py | 2 +- cinder/volume/drivers/rbd.py | 30 ++++++++++++++++--- ...e-active-replication-b230367912fe4a23.yaml | 5 ++++ 3 files changed, 32 insertions(+), 5 deletions(-) create mode 100644 releasenotes/notes/rbd-active-active-replication-b230367912fe4a23.yaml diff --git a/cinder/tests/unit/volume/drivers/test_rbd.py b/cinder/tests/unit/volume/drivers/test_rbd.py index 8c63bc019f4..c6e2ee8e7eb 100644 --- a/cinder/tests/unit/volume/drivers/test_rbd.py +++ b/cinder/tests/unit/volume/drivers/test_rbd.py @@ -1804,7 +1804,7 @@ class RBDTestCase(test.TestCase): [mock.call(mock.ANY, v, remote, False, fields.ReplicationStatus.FAILED_OVER) for v in volumes]) - mock_get_cfg.assert_called_once_with(secondary_id) + mock_get_cfg.assert_called_with(secondary_id) @mock.patch.object(driver.RBDDriver, '_failover_volume', autospec=True) def test_failover_host_failback(self, mock_failover_vol): diff --git a/cinder/volume/drivers/rbd.py b/cinder/volume/drivers/rbd.py index 4c64976e24b..0d9187af40f 100644 --- a/cinder/volume/drivers/rbd.py +++ b/cinder/volume/drivers/rbd.py @@ -200,6 +200,8 @@ class RBDDriver(driver.CloneableImageVD, driver.MigrateVD, # ThirdPartySystems wiki page CI_WIKI_NAME = "Cinder_Jenkins" + SUPPORTS_ACTIVE_ACTIVE = True + SYSCONFDIR = '/etc/ceph/' def __init__(self, active_backend_id=None, *args, **kwargs): @@ -1185,8 +1187,8 @@ class RBDDriver(driver.CloneableImageVD, driver.MigrateVD, secondary_id = candidates.pop() return secondary_id, self._get_target_config(secondary_id) - def failover_host(self, context, volumes, secondary_id=None, groups=None): - """Failover to replication target.""" + def failover(self, context, volumes, secondary_id=None, groups=None): + """Failover replicated volumes.""" LOG.info('RBD driver failover started.') if not self._is_replication_enabled: raise exception.UnableToFailOver( @@ -1201,15 +1203,35 @@ class RBDDriver(driver.CloneableImageVD, driver.MigrateVD, # Try to demote the volumes first demotion_results = self._demote_volumes(volumes) + # Do the failover taking into consideration if they have been demoted updates = [self._failover_volume(volume, remote, is_demoted, replication_status) for volume, is_demoted in zip(volumes, demotion_results)] - self._active_backend_id = secondary_id - self._active_config = remote + LOG.info('RBD driver failover completed.') return secondary_id, updates, [] + def failover_completed(self, context, secondary_id=None): + """Failover to replication target.""" + LOG.info('RBD driver failover completion started.') + secondary_id, remote = self._get_failover_target_config(secondary_id) + + self._active_backend_id = secondary_id + self._active_config = remote + LOG.info('RBD driver failover completion completed.') + + def failover_host(self, context, volumes, secondary_id=None, groups=None): + """Failover to replication target. + + This function combines calls to failover() and failover_completed() to + perform failover when Active/Active is not enabled. + """ + active_backend_id, volume_update_list, group_update_list = ( + self.failover(context, volumes, secondary_id, groups)) + self.failover_completed(context, secondary_id) + return active_backend_id, volume_update_list, group_update_list + def ensure_export(self, context, volume): """Synchronously recreates an export for a logical volume.""" pass diff --git a/releasenotes/notes/rbd-active-active-replication-b230367912fe4a23.yaml b/releasenotes/notes/rbd-active-active-replication-b230367912fe4a23.yaml new file mode 100644 index 00000000000..fa7f236a37f --- /dev/null +++ b/releasenotes/notes/rbd-active-active-replication-b230367912fe4a23.yaml @@ -0,0 +1,5 @@ +--- +features: + - Added support for active-active replication to the RBD driver. This allows + users to configure multiple volume backends that are all a member of the + same cluster participating in replication.