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

Un special-case system drive btrfs-in-partition treatment #2824 #2825

Conversation

phillxnet
Copy link
Member

@phillxnet phillxnet commented Mar 29, 2024

No functional change on first commit. Some basic code improvements to clear the way for the planed simplification/modification later in this draft PR.

Includes:

  • Modernisation re type hints in scan_disks().
  • Programmatically establish lsblk field derived Disk namedtuple fields.
  • Refactoring for readability.
  • Black reformatting.

See issue text #2824

Includes:
- Modernisation re type hints in scan_disks().
- Programmatically establish `lsblk` field derived Disk namedtuple fields.
- Refactoring for readability.
- Black reformatting.
@phillxnet
Copy link
Member Author

phillxnet commented Mar 29, 2024

@Hooverdan96 Thanks for the review: but this is very much a draft still: I've not actually begun the functional changes. And I'll have to squash these and many other changes to come so your contributions/attribution will be lost.

But thanks for the typos anyway. I'll incorporate when next working on this draft: soon hopefully. Pushing my work as I go here though just in case - and easier to ask advice etc if I get stuck. Or do end-to-end testing via our back-end rpmbuild against PRs (draft or otherwise). I think I have a few simplifications on the way, and hopefully the end result will be more maintainable. Pretty sure we can simplify quite a bit: as what we have currently is definitely super stretched. I also plan to make more use of our Disk namedtuple in scan_disks() so the code can be more self documenting, and to help guard against accidental changes we don't intend: named tuples are immutable.

@Hooverdan96
Copy link
Member

Understood absolutely, and I'm not craving attribution for those cosmetic things, but figured if I mention them now, you can get rid of that, especially since you will now start focusing on making actual functional changes...

Godspeed on the simplification, and definitely makes sense to me if you will be able to put a more complete dataset/logic on the scan_disks() to simplify subsequent functions and overall usage for other pieces.

Replace by-hand lsblk output line parser with dictionary comprehension.
Successive work towards modernisation/simplification of scan_disks().

Employ defaults in Disk named tuple to ease creation using lsblk info,
as these defaults pertain to our extra flag info.
By normalising on lowecase we can ease the transition to using
our Disk named tuple as the working copy: to help readability
and highlight where we write (via Disk.replace(root=True)). This
should also simplify the build of our final return value.

We also have a large number of tests that use the existing lowercase
Disk fields.
Explicit, rather than programmatic, namedtuple difintion works
way better for PyCharm editor assistance. Otherwise it fails
through to generic tuple hints/fencing.
 By working directly with the Disk namedtuple we gain readability
 and the advantages of an immutable type: i.e. more explicit where
 writes/changes happen due to requirement to use ._replace(). We
 also require less type transitions.
@phillxnet
Copy link
Member Author

phillxnet commented Mar 30, 2024

At this point in this draft PR associated branch all existing osi.py tests again pass. And we have maintained the existing observed failure in the 2 new tests associated with draft PR: "Disk being misattributed to ROOT pool #2749" #2823.

So we are still at no functional change: as intended. But the code is now likely more robust and easier to read with many more type hints and way more obvious re internal changes and intent within scan_disks(). Next:

  • a little more tidy, and given the increased readability we can likely do away with many of the explanatory comments to further help readability.
  • modify all existing tests to expect the issue associated behaviour change.
  • approach the functional changes in scan_disks() to return all tests to passing again.
  • ensure we have accounted for and fixed the failure detailed in the 2 new tests associated with Disk miss-attribution to ROOT pool #2749 & Disk being misattributed to ROOT pool #2749 #2823

@phillxnet phillxnet closed this Apr 3, 2024
@phillxnet phillxnet deleted the 2824-Un-special-case-system-drive-btrfs-in-partition-treatment branch April 3, 2024 15:59
@phillxnet
Copy link
Member Author

This Draft PR's work-to-date represents a significant enough modification to address a stepping stone defined by the following issue: Modernise scan_disks() - no functional change intended #2826 for which a new PR will be presented shorlty.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants