Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Use dmsetup remove to ensure multipath device #856

Draft
wants to merge 1 commit into
base: stable/v23.04
Choose a base branch
from
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion chwrap/make-tarball.sh
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
25 changes: 25 additions & 0 deletions utils/devices.go
Original file line number Diff line number Diff line change
Expand Up @@ -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
}

Expand Down