From 01694b78e577ccef5be467a8d0fd450c80806a52 Mon Sep 17 00:00:00 2001 From: Elena Taivan Date: Mon, 6 Jul 2020 06:15:21 +0000 Subject: [PATCH] Cleanup stale data on the logical volume Wipe 10MB at the beginning and at the end of each LV in cgts-vg immediately after we create and extend them to cleanup the stale data that could lead to the failure of lvm/filesystem puppet resource. Closes-Bug: 1883825 Change-Id: I727b1cb02d74a4208a6c9593819b8513c1071fea Signed-off-by: Elena Taivan --- .../modules/platform/manifests/filesystem.pp | 24 +++++++++++++++---- 1 file changed, 19 insertions(+), 5 deletions(-) diff --git a/puppet-manifests/src/modules/platform/manifests/filesystem.pp b/puppet-manifests/src/modules/platform/manifests/filesystem.pp index 5194ebfe..782086e7 100644 --- a/puppet-manifests/src/modules/platform/manifests/filesystem.pp +++ b/puppet-manifests/src/modules/platform/manifests/filesystem.pp @@ -69,6 +69,21 @@ define platform::filesystem ( size_is_minsize => $fs_size_is_minsize, } + # Wipe 10MB at the beginning and at the end + # of each LV in cgts-vg to prevent problems caused + # by stale data on the disk + -> exec { "wipe start of device ${lv_name}": + command => "dd if=/dev/zero of=${lv_name} bs=1M count=10", + onlyif => "test ! -e /etc/platform/.${lv_name}" + } + -> exec { "wipe end of device ${lv_name}": + command => "dd if=/dev/zero of=${lv_name} bs=1M seek=$(($(blockdev --getsz ${lv_name})/2048 - 10)) count=10", + onlyif => "test ! -e /etc/platform/.${lv_name}" + } + -> exec { "mark lv as wiped ${lv_name}:": + command => "touch /etc/platform/.${lv_name}", + onlyif => "test ! -e /etc/platform/.${lv_name}" + } # create filesystem -> filesystem { $device: ensure => $ensure, @@ -125,12 +140,11 @@ define platform::filesystem::resize( command => "lvextend -L${lv_size}G ${device}", returns => [0, 5] } - # After a partition extend, make sure that there is no leftover drbd - # type metadata from a previous install. Drbd writes its meta at the - # very end of a block device causing confusion for blkid. + # After a partition extend, wipe 10MB at the end of the partition + # to make sure that there is no leftover + # type metadata from a previous install -> exec { "wipe end of device ${device}": - command => "dd if=/dev/zero of=${device} bs=512 seek=$(($(blockdev --getsz ${device}) - 34)) count=34", - onlyif => "blkid ${device} | grep TYPE=\\\"drbd\\\"", + command => "dd if=/dev/zero of=${device} bs=1M seek=$(($(blockdev --getsz ${device})/2048 - 10)) count=10", } -> exec { "resize2fs ${devmapper}": command => "resize2fs ${devmapper}",