summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorZuul <zuul@review.openstack.org>2019-02-18 10:33:38 +0000
committerGerrit Code Review <review@openstack.org>2019-02-18 10:33:38 +0000
commit7de49404598d8832a82678829c23b936e8013c4d (patch)
tree67d8278d73fafe8e8b3fad8430743972cc37d8b5
parentfcb40df7773b033c9d6c3d2b4d46cedc311bac87 (diff)
parent55507cc603f8ab00b2b6dbeb2d4a2fa4e862f317 (diff)
Merge "[LVM] Run filesystem check before assigning UUID" into stable/rockystable/rocky
-rw-r--r--etc/manila/rootwrap.d/share.filters4
-rw-r--r--manila/share/drivers/generic.py3
-rw-r--r--manila/share/drivers/lvm.py20
-rw-r--r--manila/tests/share/drivers/test_generic.py1
-rw-r--r--manila/tests/share/drivers/test_lvm.py6
-rw-r--r--releasenotes/notes/bug-1798219-fix-snapshot-creation-lvm-and-generic-driver-55e349e02e7fa370.yaml8
6 files changed, 35 insertions, 7 deletions
diff --git a/etc/manila/rootwrap.d/share.filters b/etc/manila/rootwrap.d/share.filters
index 7234591..c3609cd 100644
--- a/etc/manila/rootwrap.d/share.filters
+++ b/etc/manila/rootwrap.d/share.filters
@@ -174,7 +174,9 @@ docker: CommandFilter, docker, root
174# manila/share/drivers/container/container.py: brctl <whatever> 174# manila/share/drivers/container/container.py: brctl <whatever>
175brctl: CommandFilter, brctl, root 175brctl: CommandFilter, brctl, root
176 176
177# manila/share/drivers/container/container.py: e2fsck <whatever> 177# manila/share/drivers/container/storage_helper.py: e2fsck <whatever>
178# manila/share/drivers/generic.py: e2fsck <whatever>
179# manila/share/drivers/lvm.py: e2fsck <whatever>
178e2fsck: CommandFilter, e2fsck, root 180e2fsck: CommandFilter, e2fsck, root
179 181
180# manila/share/drivers/lvm.py: lvconvert --merge %s 182# manila/share/drivers/lvm.py: lvconvert --merge %s
diff --git a/manila/share/drivers/generic.py b/manila/share/drivers/generic.py
index c746ef4..1845f12 100644
--- a/manila/share/drivers/generic.py
+++ b/manila/share/drivers/generic.py
@@ -357,6 +357,9 @@ class GenericShareDriver(driver.ExecuteMixin, driver.ShareDriver):
357 # 'tune2fs' command can be executed only when device 357 # 'tune2fs' command can be executed only when device
358 # is not mounted and also, in current case, it takes 358 # is not mounted and also, in current case, it takes
359 # effect only after it was mounted. Closes #1645751 359 # effect only after it was mounted. Closes #1645751
360 # NOTE(gouthamr): Executing tune2fs -U only works on
361 # a recently checked filesystem. See debian bug 857336
362 '&&', 'sudo', 'e2fsck', '-y', '-f', device_path,
360 '&&', 'sudo', 'tune2fs', '-U', 'random', device_path, 363 '&&', 'sudo', 'tune2fs', '-U', 'random', device_path,
361 '&&', 'sudo', 'mount', device_path, mount_path, 364 '&&', 'sudo', 'mount', device_path, mount_path,
362 ) 365 )
diff --git a/manila/share/drivers/lvm.py b/manila/share/drivers/lvm.py
index e96f0d6..fe32d1b 100644
--- a/manila/share/drivers/lvm.py
+++ b/manila/share/drivers/lvm.py
@@ -131,9 +131,21 @@ class LVMMixin(driver.ExecuteMixin):
131 'lvcreate', '-L', '%sG' % snapshot['share']['size'], 131 'lvcreate', '-L', '%sG' % snapshot['share']['size'],
132 '--name', snapshot['name'], 132 '--name', snapshot['name'],
133 '--snapshot', orig_lv_name, run_as_root=True) 133 '--snapshot', orig_lv_name, run_as_root=True)
134 snapshot_device_name = self._get_local_path(snapshot) 134
135 self._set_random_uuid_to_device(snapshot)
136
137 def _set_random_uuid_to_device(self, share_or_snapshot):
138 # NOTE(vponomaryov): 'tune2fs' is required to make
139 # filesystem of share created from snapshot have
140 # unique ID, in case of LVM volumes, by default,
141 # it will have the same UUID as source volume. Closes #1645751
142 # NOTE(gouthamr): Executing tune2fs -U only works on
143 # a recently checked filesystem.
144 # See: https://bugs.debian.org/cgi-bin/bugreport.cgi?bug=857336
145 device_path = self._get_local_path(share_or_snapshot)
146 self._execute('e2fsck', '-y', '-f', device_path, run_as_root=True)
135 self._execute( 147 self._execute(
136 'tune2fs', '-U', 'random', snapshot_device_name, run_as_root=True, 148 'tune2fs', '-U', 'random', device_path, run_as_root=True,
137 ) 149 )
138 150
139 def create_snapshot(self, context, snapshot, share_server=None): 151 def create_snapshot(self, context, snapshot, share_server=None):
@@ -248,9 +260,7 @@ class LVMShareDriver(LVMMixin, driver.ShareDriver):
248 self._allocate_container(share) 260 self._allocate_container(share)
249 snapshot_device_name = self._get_local_path(snapshot) 261 snapshot_device_name = self._get_local_path(snapshot)
250 share_device_name = self._get_local_path(share) 262 share_device_name = self._get_local_path(share)
251 self._execute( 263 self._set_random_uuid_to_device(share)
252 'tune2fs', '-U', 'random', share_device_name, run_as_root=True,
253 )
254 self._copy_volume( 264 self._copy_volume(
255 snapshot_device_name, share_device_name, share['size']) 265 snapshot_device_name, share_device_name, share['size'])
256 location = self._get_helper(share).create_exports( 266 location = self._get_helper(share).create_exports(
diff --git a/manila/tests/share/drivers/test_generic.py b/manila/tests/share/drivers/test_generic.py
index a40d4a5..095f450 100644
--- a/manila/tests/share/drivers/test_generic.py
+++ b/manila/tests/share/drivers/test_generic.py
@@ -323,6 +323,7 @@ class GenericShareDriverTestCase(test.TestCase):
323 '&&', 'sudo', 'mount', volume['mountpoint'], mount_path, 323 '&&', 'sudo', 'mount', volume['mountpoint'], mount_path,
324 '&&', 'sudo', 'chmod', '777', mount_path, 324 '&&', 'sudo', 'chmod', '777', mount_path,
325 '&&', 'sudo', 'umount', mount_path, 325 '&&', 'sudo', 'umount', mount_path,
326 '&&', 'sudo', 'e2fsck', '-y', '-f', volume['mountpoint'],
326 '&&', 'sudo', 'tune2fs', '-U', 'random', volume['mountpoint'], 327 '&&', 'sudo', 'tune2fs', '-U', 'random', volume['mountpoint'],
327 '&&', 'sudo', 'mount', volume['mountpoint'], mount_path, 328 '&&', 'sudo', 'mount', volume['mountpoint'], mount_path,
328 ), 329 ),
diff --git a/manila/tests/share/drivers/test_lvm.py b/manila/tests/share/drivers/test_lvm.py
index 2196773..addb1fc 100644
--- a/manila/tests/share/drivers/test_lvm.py
+++ b/manila/tests/share/drivers/test_lvm.py
@@ -228,6 +228,7 @@ class LVMShareDriverTestCase(test.TestCase):
228 expected_exec = [ 228 expected_exec = [
229 'lvcreate -L 1G -n fakename fakevg', 229 'lvcreate -L 1G -n fakename fakevg',
230 'mkfs.ext4 /dev/mapper/fakevg-fakename', 230 'mkfs.ext4 /dev/mapper/fakevg-fakename',
231 'e2fsck -y -f %s' % mount_share,
231 'tune2fs -U random %s' % mount_share, 232 'tune2fs -U random %s' % mount_share,
232 ("dd count=0 if=%s of=%s iflag=direct oflag=direct" % 233 ("dd count=0 if=%s of=%s iflag=direct oflag=direct" %
233 (mount_snapshot, mount_share)), 234 (mount_snapshot, mount_share)),
@@ -333,6 +334,7 @@ class LVMShareDriverTestCase(test.TestCase):
333 expected_exec = [ 334 expected_exec = [
334 ("lvcreate -L 1G --name fakesnapshotname --snapshot " 335 ("lvcreate -L 1G --name fakesnapshotname --snapshot "
335 "%s/fakename" % (CONF.lvm_share_volume_group,)), 336 "%s/fakename" % (CONF.lvm_share_volume_group,)),
337 "e2fsck -y -f /dev/mapper/fakevg-%s" % self.snapshot['name'],
336 "tune2fs -U random /dev/mapper/fakevg-%s" % self.snapshot['name'], 338 "tune2fs -U random /dev/mapper/fakevg-%s" % self.snapshot['name'],
337 "mkdir -p " + mount_path, 339 "mkdir -p " + mount_path,
338 "mount /dev/mapper/fakevg-fakesnapshotname " + mount_path, 340 "mount /dev/mapper/fakevg-fakesnapshotname " + mount_path,
@@ -579,7 +581,9 @@ class LVMShareDriverTestCase(test.TestCase):
579 ("lvconvert --merge %s" % snap_lv), 581 ("lvconvert --merge %s" % snap_lv),
580 ("lvcreate -L 1G --name fakesnapshotname --snapshot %s" % 582 ("lvcreate -L 1G --name fakesnapshotname --snapshot %s" %
581 share_lv), 583 share_lv),
582 ('tune2fs -U random /dev/mapper/%s-fakesnapshotname' % 584 ("e2fsck -y -f /dev/mapper/%s-fakesnapshotname" %
585 CONF.lvm_share_volume_group),
586 ("tune2fs -U random /dev/mapper/%s-fakesnapshotname" %
583 CONF.lvm_share_volume_group), 587 CONF.lvm_share_volume_group),
584 ("mkdir -p %s" % share_mount_path), 588 ("mkdir -p %s" % share_mount_path),
585 ("mount /dev/mapper/%s-fakename %s" % 589 ("mount /dev/mapper/%s-fakename %s" %
diff --git a/releasenotes/notes/bug-1798219-fix-snapshot-creation-lvm-and-generic-driver-55e349e02e7fa370.yaml b/releasenotes/notes/bug-1798219-fix-snapshot-creation-lvm-and-generic-driver-55e349e02e7fa370.yaml
new file mode 100644
index 0000000..742635c
--- /dev/null
+++ b/releasenotes/notes/bug-1798219-fix-snapshot-creation-lvm-and-generic-driver-55e349e02e7fa370.yaml
@@ -0,0 +1,8 @@
1---
2fixes:
3 - |
4 The generic and LVM drivers have been fixed to always perform a filesystem
5 check on newly created snapshots and derivative shares before attempting
6 to assign a UUID to them. See
7 `Launchpad bug 1798219 <https://bugs.launchpad.net/manila/+bug/1798219>`_
8 for more details.