TT#118659 Do not abort on disk partition listing failures

We identify any existing partitions of the disk we need to wipe via:

| root@license42 ~ # lsblk --noheadings --output KNAME /dev/sda
| sda
| sda1
| sda2
| sda3
| root@license42 ~ # blockdevice="/dev/sda"
| root@license42 ~ # lsblk --noheadings --output KNAME /dev/sda | grep -v "^${blockdevice#\/dev\/}$"
| sda1
| sda2
| sda3

This might fail though, if there are no partitions present:

| root@license42 ~ # dd if=/dev/zero of=/dev/sda bs=10M count=1
| 1+0 records in
| 1+0 records out
| 10485760 bytes (10 MB, 10 MiB) copied, 0.0487036 s, 215 MB/s
| root@license42 ~ # pvremove /dev/sda --force --force --yes
|   Labels on physical volume "/dev/sda" successfully wiped.
| root@license42 ~ # blockdevice="/dev/sda"
| root@license42 ~ # lsblk --noheadings --output KNAME /dev/sda | grep -v "^${blockdevice#\/dev\/}$"
| 1 root@license42 ~ #

Ending up in our daily-build-install-vm Jenkins jobs like this:

| +13:08:19 (netscript.grml:489): clear_partition_table():  echo 'Removing possibly existing LVM/PV label from /dev/sda'
| +13:08:19 (netscript.grml:490): clear_partition_table():  pvremove /dev/sda --force --force --yes
|   Labels on physical volume "/dev/sda" successfully wiped.
| ++13:08:19 (netscript.grml:495): clear_partition_table():  grep -v '^sda$'
| ++13:08:19 (netscript.grml:495): clear_partition_table():  lsblk --noheadings --output KNAME /dev/sda
| +++13:08:19 (netscript.grml:495): clear_partition_table():  wait_exit
| +++13:08:19 (netscript.grml:339): wait_exit():  local e_code=1
| +++13:08:19 (netscript.grml:340): wait_exit():  [[ 1 -ne 0 ]]
| +++13:08:19 (netscript.grml:341): wait_exit():  set_deploy_status error
| +++13:08:19 (netscript.grml:103): set_deploy_status():  '[' -n error ']'
| +++13:08:19 (netscript.grml:104): set_deploy_status():  echo error
| Wiping disk signatures from /dev/sda
| +++13:08:19 (netscript.grml:343): wait_exit():  trap '' 1 2 3 6 15 ERR EXIT
| +++13:08:19 (netscript.grml:344): wait_exit():  status_wait
| +++13:08:19 (netscript.grml:329): status_wait():  [[ -n 0 ]]
| +++13:08:19 (netscript.grml:329): status_wait():  [[ 0 != 0 ]]

Followup change for e9244a289b, to fix failing VM deployments.

Change-Id: Ic63ecf5dd090722705473ad5aac289473b082650
mr12.3
Michael Prokop 1 year ago
parent fc9b43f92e
commit 1d59d89d04

@ -492,7 +492,7 @@ clear_partition_table() {
# ensure we remove signatures from partitions like /dev/nvme1n1p3 first,
# and only then get rid of signaturs from main blockdevice /dev/nvme1n1
for partition in $(lsblk --noheadings --output KNAME "${blockdevice}" | grep -v "^${blockdevice#\/dev\/}$") ; do
for partition in $(lsblk --noheadings --output KNAME "${blockdevice}" | grep -v "^${blockdevice#\/dev\/}$" || true) ; do
[ -b "${partition}" ] || continue
echo "Wiping disk signatures from partition ${partition}"
wipefs -a "${partition}"

Loading…
Cancel
Save