Fix controller swact error caused by drbd resizing

Fix a bug found in ‘provider/logical_volume/lvm.rb’ in method
‘def size=(new_size)’ with the variable
‘nuke_fs_on_resize_failure’. The conditional statement was always
returning true and thus wiping bytes at the start of the volume
even is the variable was set to false.

For example resizing the extension filesystem with the command
‘system controllerfs-modify’ would cause a dd command to be
executed and erase data. This was seen in the puppet.log

Story: 2002990
Task: 23004

Change-Id: I9ce4f9869d8b72549640d1a4181df02490451a88
Signed-off-by: Kristine Bujold <kristine.bujold@windriver.com>
This commit is contained in:
Kristine Bujold 2018-08-15 17:11:27 -04:00
parent c7a85335e6
commit aea80fa088
3 changed files with 48 additions and 1 deletions

View File

@ -9,4 +9,4 @@ COPY_LIST="$CGCS_BASE/downloads/puppet/$PREFIX-$MODULE-$GIT_SHA.tar.gz $FILES_BA
TIS_PATCH_VER=4
TIS_PATCH_VER=5

View File

@ -0,0 +1,45 @@
From 21d2c4e714611ad08e5aa999e555e1e7591f2717 Mon Sep 17 00:00:00 2001
From: Kristine Bujold <kristine.bujold@windriver.com>
Date: Thu, 19 Jul 2018 09:02:27 -0400
Subject: [PATCH 1/1] Patch4:
Fix-the-logical-statement-for-nuke_fs_on_resize_2.patch
---
.../puppet/modules/lvm/lib/puppet/provider/logical_volume/lvm.rb | 9 ++++++---
1 file changed, 6 insertions(+), 3 deletions(-)
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 2abfea3..f9b1c66 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
@@ -184,13 +184,15 @@ Puppet::Type.type(:logical_volume).provide :lvm do
exec_cmd('umount', path)
exec_cmd('fsadm', '-y', 'check', path )
r = exec_cmd('fsadm', '-y', 'resize', path, "#{new_size}k")
- if r[:exit] != 0 and @resource[:nuke_fs_on_resize_failure]
+ if r[:exit] != 0 and [:true, "true", true ].include? @resource[:nuke_fs_on_resize_failure]
+ info( "Failed 'fsadm resize' erase the disk #{r}" )
exec_cmd('dd', 'if=/dev/zero', "of=#{path}", "bs=512", "count=16", "conv=notrunc")
blkid('-g')
end
r = exec_cmd('lvresize', '-r', '-f', '-L', "#{new_size}k", path)
if r[:exit] != 0
- if @resource[:nuke_fs_on_resize_failure]
+ if [:true, "true", true ].include? @resource[:nuke_fs_on_resize_failure]
+ info( "Failed 'fsadm resize' erase the disk #{r}" )
exec_cmd('dd', 'if=/dev/zero', "of=#{path}", "bs=512", "count=16", "conv=notrunc")
blkid('-g')
lvresize( '-f', '-L', "#{new_size}k", path) || fail( "Cannot reduce to size #{new_size} because lvresize failed." )
@@ -215,7 +217,8 @@ Puppet::Type.type(:logical_volume).provide :lvm do
exec_cmd('umount', path)
exec_cmd('fsadm', '-y', 'check', path )
r = exec_cmd('fsadm', '-y', 'resize', path, "#{new_size}k")
- if r[:exit] != 0 and @resource[:nuke_fs_on_resize_failure]
+ if r[:exit] != 0 and [:true, "true", true ].include? @resource[:nuke_fs_on_resize_failure]
+ info( "Failed 'fsadm resize' erase the disk #{r}" )
exec_cmd('dd', 'if=/dev/zero', "of=#{path}", "bs=512", "count=16", "conv=notrunc")
blkid('-g')
end
--
1.8.3.1

View File

@ -16,6 +16,7 @@ Patch0: 0001-puppet-lvm-kilo-quilt-changes.patch
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
BuildArch: noarch
@ -34,6 +35,7 @@ A Puppet module for Logical Resource Management (LVM)
%patch1 -p1
%patch2 -p1
%patch3 -p1
%patch4 -p1
%install
install -d -m 0755 %{buildroot}/%{_datadir}/puppet/modules/%{module_dir}