Repository navigation
Conversation
…h_for_device In get_unique_path_for_device(), linked_targets maps resolved device paths (e.g. /dev/sda, /dev/nvme0n1) to their /dev/disk/by-id/* symlinks. Previously, linked_wwn_targets iterated over the keys of linked_targets (the resolved /dev/sdX or /dev/nvmeXnY paths) and checked whether the resolved device name started with 'wwn-' or 'nvme-eui.', which was always False. In addition, because multiple /dev/disk/by-id symlinks resolve to the same block device, building linked_wwn_targets from linked_targets would miss wwn-/nvme-eui. symlinks whenever another symlink (such as ata-* or nvme-*) appeared later in the glob iteration. Materialize the glob results and build linked_wwn_targets directly from the /dev/disk/by-id symlink paths.
This branch has not been deployed
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
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
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.
PR Description:
In
get_unique_path_for_device(),linked_targets = {p.resolve(): p for p in paths}uses the resolved device path (e.g./dev/sda,/dev/nvme0n1) as the dictionary key and the/dev/disk/by-id/*symlink as the value.Previously,
linked_wwn_targetsiterated overlinked_targets(the resolved/dev/sdX//dev/nvmeXnYkeys) and checkedif p.name.startswith('wwn-') or p.name.startswith('nvme-eui.'), which was alwaysFalsebecausep.namewas'sda'/'nvme0n1'rather than the/dev/disk/by-id/symlink name. Furthermore, because a disk typically has multiple symlinks in/dev/disk/by-id/(e.g. bothata-*andwwn-*),linked_targetscould overwrite thewwn-*symlink withata-*.This PR materializes
pathsand buildslinked_wwn_targetsdirectly frompathsby checking the symlink name, plus adds unit tests intests/test_disk_utils.py.Tests and Checks