Skip to content

Zpool not idempotent when using /dev/disk/by-id/ #89

Open
@shoddyguard

Description

@shoddyguard

Describe the Bug

When managing a zpool using the /dev/disk/by-id/ path for it's members Puppet constantly wants to change the disks to the /dev/sd* variants.

I believe the issue stems from this block of code:

# get full drive name if the value is a partition (Linux only)
tmp << if Facter.value(:kernel) == 'Linux' && value =~ %r{/dev/(:?[a-z]+([0-9]+n[0-9]+p)?1|disk/by-id/.+-part1)$}
execute("lsblk -p -no pkname #{value}").chomp
else
value
end

The issue being that lsblk returns the path of /dev/sd* as opposed to the /dev/disk/by-id path.

It seems this was originally done to stop partitions being used instead of disks but perhaps using some regex and stripping away the -part\n would be a simpler solution?

Expected Behavior

Puppet does not want to adjust the zpool members

Steps to Reproduce

Assuming we have 2 disks we want to mirror /dev/sdb at /dev/disk/by-id/my-disk-SN1234 and /dev/sdc at /dev/disk/by-id/my-disk-SN5678

zpool { 'myPool':
  ensure => 'present'
  mirror => ['dev/disk/by-id/my-disk-SN1234 /dev/disk/by-id/my-disk-SN5678'],
}

First run should apply correctly and the pool will be created with the correct members, on subsequent runs Puppet will constantly want to change the members to ['/dev/sdb /dev/sdc']

Environment

  • Puppet Agent: 7.31.0
  • Module version: 1.6.1
  • Debian 12 Bookworm

Additional Context

There is a workaround - declare the Zpool with the /dev/disk/by-id path, then once the pool has been created swap out the paths to their /dev/sd* counterparts. However this is not a particularly good workaround due to the below.

It's generally considered best practice with ZOL to use the by-id path for disks when declaring Zpool members rather than the /dev/sd* as the latter can change on reboots especially with hardware changes. (ZFS does actually seem to handle this these days)

As a real-world example we recently swapped out a pair of hard drives in one of our servers, this caused almost all of the other drives to swap around (I believe the /dev/sd* labels get applied as the disks become available) this caused Puppet to get very confused and want to swap all the disks around until we re-jigged our definitions.

Metadata

Metadata

Assignees

No one assigned

    Labels

    bugSomething isn't working

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions