Skip to content
Merged
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 mantle/cmd/kola/testiso.go
Original file line number Diff line number Diff line change
Expand Up @@ -245,7 +245,7 @@ Before=coreos-test-installer.service
[Service]
Type=oneshot
RemainAfterExit=yes
ExecStart=/bin/bash -c '[[ $(findmnt -nvro SOURCE /sysroot) == /dev/mapper/mpatha4 ]]'
ExecStart=/bin/bash -c 'lsblk -pno NAME "/dev/mapper/$(multipath -l -v 1)" | grep -qw "$(findmnt -nvr /sysroot -o SOURCE)"'
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

high

This command has a few issues that make it incorrect or fragile:

  1. The -v flag to findmnt means --invert, which will cause it to list the sources for all mountpoints except /sysroot. This is not the intended behavior. The v should be removed.
  2. The $(multipath -l -v 1) is quoted. If multipath were to return multiple devices (one per line), command substitution would replace newlines with spaces, and lsblk would receive a single invalid path like "/dev/mapper/mpatha mpathb". While the current test setup only creates one multipath device, it's more robust to not quote this to allow for word splitting.
  3. If multipath -l -v 1 returns no devices, lsblk will be called on /dev/mapper/ which lists all devices under it. This could lead to false positives. It's better to check that multipath returns at least one device.

I'd also recommend using -v1 instead of -v 1 for multipath for better compatibility.

Here is a more robust version of the command that addresses these points:

Suggested change
ExecStart=/bin/bash -c 'lsblk -pno NAME "/dev/mapper/$(multipath -l -v 1)" | grep -qw "$(findmnt -nvr /sysroot -o SOURCE)"'
ExecStart=/bin/bash -c 'MPATH_DEVS=$(multipath -l -v1); [ -n "$MPATH_DEVS" ] && lsblk -pno NAME /dev/mapper/$MPATH_DEVS | grep -qw "$(findmnt -nr /sysroot -o SOURCE)"'

[Install]
RequiredBy=multi-user.target`

Expand Down
Loading