-
Notifications
You must be signed in to change notification settings - Fork 1.7k
Fix(zpool): Ensure consistent device path normalization for idempotency #11020
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
Open
puffymob
wants to merge
4
commits into
ansible-collections:main
Choose a base branch
from
puffymob:fix/zpool-canonical-id-idempotency
base: main
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
+11
−4
Open
Changes from all commits
Commits
Show all changes
4 commits
Select commit
Hold shift + click to select a range
b476b2f
Fix(zpool): Ensure consistent device path normalization for idempotency
gumbo2k 5ad795d
Add changelog fragment for PR 11020
72afd38
Remove trailing space from the new line
ed52c1f
Update changelogs/fragments/11020-zpool-device-path-idempotency.yaml
puffymob File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
2 changes: 2 additions & 0 deletions
2
changelogs/fragments/11020-zpool-device-path-idempotency.yaml
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,2 @@ | ||
| bugfixes: | ||
| - zpool - idempotency failed when canonical device IDs were used; the fix now ensures consistent device path normalization (https://github.com/ansible-collections/community.general/issues/10771, https://github.com/ansible-collections/community.general/issues/10744, https://github.com/ansible-collections/community.general/pull/11020). |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I'm wondering whether this change (and the one further below) could break some uses of the module unrelated to
/dev/disk/by-id/, and would require another adjustment to avoid this breakage.There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I've been hoping to take some time to look at this a bit more, but I just haven't been able to find any lately, so my comments are based solely on browsing the changes and not testing, but my instincts are that:
/dev/disk/by-*/*to be used for identifying disks, so ideally we'd cover more than just theby-idpath./dev/disk/by-*/*is really just a symlink, so I would have initially though that just doing anos.readlinkon any devices passed as symlinks might solve the problem. I'm not sure if this truely vibes with how zfs stores device names though.There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Second that. A fix for the underlying problem should aim to support all kinds of
/dev/disk/by-*symlinks.Uh oh!
There was an error while loading. Please reload this page.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@felixfontein , I thought about that, but I do not think it will cause problems. Not here where we only read the current layout, and not further down.
Rather the opposite.
In both places we call
zpool statusand extract the devices that make up the pool.As an admin, when creating a zfs pool on a server with lots of disks, I expect disks to fail over time, to disappear or be replaced, and so on. So when I create the pool, I make sure to use device links that will survive those changes.
Enforcing
real_pathsinget_current_layoutdoesn't make sense. I want the same layout reported back, that I put in.If I used the stable
by-idsymlinks during creation of the pool, I want them to be reported back.If I used
/dev/sdx, /dev/sdy, /dev/sdzduring creation of the pool, I want those to be reported back.I checked the history of the module, to see if the translation to "real_paths" was added in a commit that would explain the rational, but it seems
real_paths=Truewas in there from the start.Uh oh!
There was an error while loading. Please reload this page.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@dthomson-triumf , @n3ph , I briefly considered extending the regex match to include all
/dev/disk/by-*/directoriies but I intentionally limited the blast radius to avoid unintentional changes in behavior, just in case somebody creates a symlink namedsomething-part123that is not a link to a partition.I know more-or-less what to expect in
by-id, but directories likeby-diskseq,by-dname,by-loop-inode,by-loop-ref,by-partuuid,by-pathorby-uuid? Some are only there for loopback devices and some only get populated by creation of filesystems or partitions. Exactly whatbase_device()tries to avoid.I don't have much experience with zfs, but the module does not resolve symlinks when creating a pool, and zpools seems to work nicely with those symlinked devices.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@gumbo2k IMO the risk is fairly low considering that these device paths are values that would have been entered by a person (or a lookup module or something, but I think the point remains).
However, I think the best solution is what you mentioned in your previous reply to @felixfontein. I was kind of fuzzy on why the device names were different in the zpool from the values that were entered. I didn't realize that it was the zpool module that was trying to change the device name via the
real_pathsoption. Generally, I don't think the Ansible module should be the responsible for what my device names are according to ZFS. That should be ZFS's responsibility.Uh oh!
There was an error while loading. Please reload this page.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think, most of these devices are managed by udev and device mapper anyway.
In general, I would leave it up to the user to make sense out of what is going to be configured. Underlying LUN specifics are nothing for an anisble module to assume, but for the user to consider.
Edit: Though, thank you for looking into this issue.. 🙇🏼