From b310077093fd567944c6a46b7d0adcabe1f2b4b9 Mon Sep 17 00:00:00 2001 From: Mihnea Saracin Date: Sat, 22 May 2021 18:19:54 +0300 Subject: [PATCH] Fix resize of filesystems in puppet logical_volume After system reinstalls there is stale data on the disk and puppet fails when resizing, reporting some wrong filesystem types. In our case docker-lv was reported as drbd when it should have been xfs. This problem was solved in some cases e.g: when doing a live fs resize we wipe the last 10MB at the end of partition: https://opendev.org/starlingx/stx-puppet/src/branch/master/puppet-manifests/src/modules/platform/manifests/filesystem.pp#L146 Our issue happened here: https://opendev.org/starlingx/stx-puppet/src/branch/master/puppet-manifests/src/modules/platform/manifests/filesystem.pp#L65 Resize can happen at unlock when a bigger size is detected for the filesystem and the 'logical_volume' will resize it. To fix this we have to wipe the last 10MB of the partition after the 'lvextend' cmd in the 'logical_volume' module. Tested the following scenarios: B&R on SX with default sizes of filesystems and cgts-vg. B&R on SX with with docker-lv of size 50G, backup-lv also 50G and cgts-vg with additional physical volumes: - name: cgts-vg physicalVolumes: - path: /dev/disk/by-path/pci-0000:00:0d.0-ata-1.0 size: 50 type: partition - path: /dev/disk/by-path/pci-0000:00:0d.0-ata-1.0 size: 30 type: partition - path: /dev/disk/by-path/pci-0000:00:0d.0-ata-3.0 type: disk B&R on DX system with backup of size 70G and cgts-vg with additional physical volumes: physicalVolumes: - path: /dev/disk/by-path/pci-0000:00:0d.0-ata-1.0 size: 50 type: partition - path: /dev/disk/by-path/pci-0000:00:0d.0-ata-1.0 size: 30 type: partition - path: /dev/disk/by-path/pci-0000:00:0d.0-ata-3.0 type: disk Closes-Bug: 1926591 Change-Id: I55ae6954d24ba32e40c2e5e276ec17015d9bba44 Signed-off-by: Mihnea Saracin --- ...0MB-after-we-lvextend-the-partitions.patch | 24 +++++++++++++++++++ .../puppet-lvm/centos/puppet-lvm.spec | 2 ++ 2 files changed, 26 insertions(+) create mode 100644 config/puppet-modules/puppet-lvm/centos/files/0005-Wipe-10MB-after-we-lvextend-the-partitions.patch diff --git a/config/puppet-modules/puppet-lvm/centos/files/0005-Wipe-10MB-after-we-lvextend-the-partitions.patch b/config/puppet-modules/puppet-lvm/centos/files/0005-Wipe-10MB-after-we-lvextend-the-partitions.patch new file mode 100644 index 000000000..517eca883 --- /dev/null +++ b/config/puppet-modules/puppet-lvm/centos/files/0005-Wipe-10MB-after-we-lvextend-the-partitions.patch @@ -0,0 +1,24 @@ +From c14a96cb55a3bcd20f772c25f2294eb3a1d376b9 Mon Sep 17 00:00:00 2001 +From: Mihnea Saracin +Date: Fri, 21 May 2021 13:34:41 -0400 +Subject: [PATCH 5/5] Wipe 10MB after we lvextend the partitions + +--- + .../puppet/modules/lvm/lib/puppet/provider/logical_volume/lvm.rb | 1 + + 1 file changed, 1 insertion(+) + +diff --git a/packstack/puppet/modules/lvm/lib/puppet/provider/logical_volume/lvm.rb b/packstack/puppet/modules/lvm/lib/puppet/provider/logical_volume/lvm.rb +index f9b1c66..a604e96 100755 +--- a/packstack/puppet/modules/lvm/lib/puppet/provider/logical_volume/lvm.rb ++++ b/packstack/puppet/modules/lvm/lib/puppet/provider/logical_volume/lvm.rb +@@ -214,6 +214,7 @@ Puppet::Type.type(:logical_volume).provide :lvm do + end + end + lvextend( '-L', "#{new_size}k", path) || fail( "Cannot extend to size #{new_size} because lvextend failed." ) ++ exec_cmd("seek_end=$(($(blockdev --getsz #{path})/2048 - 10)); dd if=/dev/zero of=#{path} bs=1M seek=${seek_end} count=10") + exec_cmd('umount', path) + exec_cmd('fsadm', '-y', 'check', path ) + r = exec_cmd('fsadm', '-y', 'resize', path, "#{new_size}k") +-- +2.29.2 + diff --git a/config/puppet-modules/puppet-lvm/centos/puppet-lvm.spec b/config/puppet-modules/puppet-lvm/centos/puppet-lvm.spec index 247dc03c3..ceb191590 100644 --- a/config/puppet-modules/puppet-lvm/centos/puppet-lvm.spec +++ b/config/puppet-modules/puppet-lvm/centos/puppet-lvm.spec @@ -17,6 +17,7 @@ Patch1: 0002-UEFI-pvcreate-fix.patch Patch2: 0003-US94222-Persistent-Dev-Naming.patch Patch3: 0004-extendind-nuke_fs_on_resize_failure-functionality.patch Patch4: Fix-the-logical-statement-for-nuke_fs_on_resize.patch +Patch5: 0005-Wipe-10MB-after-we-lvextend-the-partitions.patch BuildArch: noarch @@ -36,6 +37,7 @@ A Puppet module for Logical Resource Management (LVM) %patch2 -p1 %patch3 -p1 %patch4 -p1 +%patch5 -p1 %install install -d -m 0755 %{buildroot}/%{_datadir}/puppet/modules/%{module_dir}