From 73ef94d38fcf28d6de5133db662b19e06d86fde7 Mon Sep 17 00:00:00 2001 From: Rodrigo Barbieri Date: Wed, 7 Feb 2018 13:36:26 -0200 Subject: [PATCH] Fix LVM driver not handling IPv6 in recovery mode Recovery mode is currently used by host-assisted share migration to bulk remove and add back rules while casting them to read only. Unfortunately, it is not handling IPv6 addresses when removing the rules in this code path. This patch adds a call to a function that handles the IPv6 addresses, adding brackets around them. Change-Id: Icba4b22ad87ccfabcc02078648b1abc6410e5353 Closes-bug: #1746723 --- manila/share/drivers/helpers.py | 3 ++- manila/tests/share/drivers/test_helpers.py | 22 +++++++++++++------ .../notes/bug-1746723-8b89633062885f0b.yaml | 5 +++++ 3 files changed, 22 insertions(+), 8 deletions(-) create mode 100644 releasenotes/notes/bug-1746723-8b89633062885f0b.yaml diff --git a/manila/share/drivers/helpers.py b/manila/share/drivers/helpers.py index 983b7d5cc5..e302c5c6f7 100644 --- a/manila/share/drivers/helpers.py +++ b/manila/share/drivers/helpers.py @@ -241,8 +241,9 @@ class NFSHelper(NASHelperBase): hosts = self.get_host_list(out, local_path) for host in hosts: + parsed_host = self._get_parsed_address_or_cidr(host) self._ssh_exec(server, ['sudo', 'exportfs', '-u', - ':'.join((host, local_path))]) + ':'.join((parsed_host, local_path))]) self._sync_nfs_temp_and_perm_files(server) for access in access_rules: rules_options = '%s,no_subtree_check,no_root_squash' diff --git a/manila/tests/share/drivers/test_helpers.py b/manila/tests/share/drivers/test_helpers.py index ea704a5a82..6c5d9bf9a9 100644 --- a/manila/tests/share/drivers/test_helpers.py +++ b/manila/tests/share/drivers/test_helpers.py @@ -226,14 +226,22 @@ class NFSHelperTestCase(test.TestCase): result = self._helper.get_host_list(fake_exportfs, '/shares/share-1') self.assertEqual(expected, result) - @ddt.data(const.ACCESS_LEVEL_RW, const.ACCESS_LEVEL_RO) - def test_update_access_recovery_mode(self, access_level): + @ddt.data({"level": const.ACCESS_LEVEL_RW, "ip": "1.1.1.1", + "expected": "1.1.1.1"}, + {"level": const.ACCESS_LEVEL_RO, "ip": "1.1.1.1", + "expected": "1.1.1.1"}, + {"level": const.ACCESS_LEVEL_RW, "ip": "fd12:abcd::10", + "expected": "[fd12:abcd::10]"}, + {"level": const.ACCESS_LEVEL_RO, "ip": "fd12:abcd::10", + "expected": "[fd12:abcd::10]"}) + @ddt.unpack + def test_update_access_recovery_mode(self, level, ip, expected): expected_mount_options = '%s,no_subtree_check,no_root_squash' access_rules = [test_generic.get_fake_access_rule( - '1.1.1.1', access_level), ] + ip, level), ] self.mock_object(self._helper, '_sync_nfs_temp_and_perm_files') self.mock_object(self._helper, 'get_host_list', - mock.Mock(return_value=['1.1.1.1'])) + mock.Mock(return_value=[ip])) self._helper.update_access(self.server, self.share_name, access_rules, [], []) local_path = os.path.join(CONF.share_mount_path, self.share_name) @@ -241,11 +249,11 @@ class NFSHelperTestCase(test.TestCase): mock.call(self.server, ['sudo', 'exportfs']), mock.call( self.server, ['sudo', 'exportfs', '-u', - ':'.join([access_rules[0]['access_to'], + ':'.join([expected, local_path])]), mock.call(self.server, ['sudo', 'exportfs', '-o', - expected_mount_options % access_level, - ':'.join(['1.1.1.1', local_path])]), + expected_mount_options % level, + ':'.join([expected, local_path])]), ]) self._helper._sync_nfs_temp_and_perm_files.assert_called_with( self.server) diff --git a/releasenotes/notes/bug-1746723-8b89633062885f0b.yaml b/releasenotes/notes/bug-1746723-8b89633062885f0b.yaml new file mode 100644 index 0000000000..05d1455704 --- /dev/null +++ b/releasenotes/notes/bug-1746723-8b89633062885f0b.yaml @@ -0,0 +1,5 @@ +--- +fixes: + - LVM driver now correctly parses IPv6 addresses during a Host-assisted + share migration. +