diff --git a/chwrap/make-tarball.sh b/chwrap/make-tarball.sh index 0814a2d5c..5754cfa3a 100755 --- a/chwrap/make-tarball.sh +++ b/chwrap/make-tarball.sh @@ -5,7 +5,7 @@ PREFIX=$(mktemp -d) mkdir -p $PREFIX/netapp cp "$1" $PREFIX/netapp/chwrap -for BIN in apt blkid blockdev cat cryptsetup dd df dnf docker e2fsck free fsck.ext3 fsck.ext4 iscsiadm losetup ls lsblk lsscsi \ +for BIN in apt blkid blockdev cat cryptsetup dd df dmsetup dnf docker e2fsck free fsck.ext3 fsck.ext4 iscsiadm losetup ls lsblk lsscsi \ mkdir mkfs.ext3 mkfs.ext4 mkfs.xfs mount mount.nfs mount.nfs4 mpathconf multipath multipathd pgrep resize2fs rmdir \ rpcinfo stat systemctl umount xfs_growfs yum ; do ln -s chwrap $PREFIX/netapp/$BIN diff --git a/utils/devices.go b/utils/devices.go index 935b7a581..5e0defdd2 100644 --- a/utils/devices.go +++ b/utils/devices.go @@ -947,6 +947,31 @@ func RemoveMultipathDeviceMapping(ctx context.Context, devicePath string) { }).Error("Error encountered in multipath flush(remove) mapping command.") } + exists, err := PathExists(devicePath) + if err != nil { + Logc(ctx).WithField("error", err).Error("Error trying to determine if device path exists.") + } else if !exists { + return + } + + serial, err := execCommandWithTimeout(ctx, "multipath", 10*time.Second, true, "-l", devicePath, "-v", "1") + if err != nil { + Logc(ctx).WithFields(LogFields{ + "error": err, + "output": string(serial), + }).Error("Error trying to retrieve serial for device path.") + } + + out1, err := execCommandWithTimeout(ctx, "dmsetup", 10*time.Second, false, "remove", "-f", string(serial)) + if err != nil { + // Nothing to do if it generates an error, but log it. + Logc(ctx).WithFields(LogFields{ + "error": err, + "output": string(out1), + "devicePath": devicePath, + }).Error("Error encountered in dmsetup remove command.") + } + return }