-
Notifications
You must be signed in to change notification settings - Fork 494
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
(FACT-3140) Include partition type uuid for GPT based systems #2511
Conversation
Can one of the admins verify this patch? |
lib/facter/resolvers/partitions.rb
Outdated
@@ -121,7 +121,7 @@ def execute_and_extract_blkid_info | |||
def populate_from_lsblk(partition_name, blkid_and_lsblk) | |||
return {} unless available?('lsblk', blkid_and_lsblk) | |||
|
|||
blkid_and_lsblk[:lsblk] ||= Facter::Core::Execution.execute('lsblk -fp', logger: log) | |||
blkid_and_lsblk[:lsblk] ||= Facter::Core::Execution.execute('lsblk -p -P -o NAME,FSTYPE,LABEL,UUID,PARTTYPE', logger: log) |
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 tried the command lsblk -p -P -o NAME,FSTYPE,LABEL,UUID,PARTTYPE
on a centos-7-x86_64 VM and it errored out with:
lsblk: unknown column: PARTTYPE
Looks like on redhat-9-x86_64 it does work as expected:
lsblk -p -P -o NAME,FSTYPE,LABEL,UUID,PARTTYPE
NAME="/dev/sda" FSTYPE="" LABEL="" UUID="" PARTTYPE=""
NAME="/dev/sda1" FSTYPE="xfs" LABEL="" UUID="e6a7819d-3337-4d37-8789-d6a08ff87af8" PARTTYPE="0x83"
NAME="/dev/sda2" FSTYPE="LVM2_member" LABEL="" UUID="yhI4fj-F1mX-rstz-2D5w-MFtV-Myil-LW5pl7" PARTTYPE="0x8e"
NAME="/dev/mapper/rhel-root" FSTYPE="xfs" LABEL="" UUID="9ff66d86-abea-4244-b7c2-4547f15db06d" PARTTYPE=""
NAME="/dev/mapper/rhel-swap" FSTYPE="swap" LABEL="" UUID="22260cab-8b6e-4777-af64-9f7e849d58d2" PARTTYPE=""
NAME="/dev/mapper/rhel-home" FSTYPE="xfs" LABEL="" UUID="326a248f-4e90-4207-92d0-33baa143774b" PARTTYPE=""
NAME="/dev/sr0" FSTYPE="" LABEL="" UUID="" PARTTYPE=""
Is the PARTYPE that important? Could we possibly drop it so we don't have to add in some logic to determine if lsblk
is the right version that will support PARTTYPE?
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 fear PARTTYPE
is what I was hopeful to capture with this patch set....
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.
It looks like PARTTYPE
was added in util-linux/util-linux@4686ba1 and first released in 2.25. So we'd need to make this conditional based on the version.
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 not sure how to do that....
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.
You'll want to do something like what this resolver does
facter/lib/facter/resolvers/augeas.rb
Line 32 in 39b48ad
output = Facter::Core::Execution.execute("#{command} --version 2>&1", logger: log) |
to detect the version and only include the new fact on more recent versions.
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 took a stab at implementation.
e7fd8f3
to
5ca83d0
Compare
Rebased off HEAD |
@jcpunk you'll need to stub out the call to facter/spec/facter/resolvers/partitions_spec.rb Lines 44 to 45 in 465c119
Also please add a test to test the fallback behavior when the version is older and verify facter omits the partition type. |
Long term it might make more sense to just run the version with the extra options and have it catch the error if it isn't supported. It may be a good while before I get back to this. |
I've started digging into this and I think the way the partition resolver currently works, in most cases the resolver won't even use facter/lib/facter/resolvers/partitions.rb Lines 76 to 78 in e776b42
However, it seems like Also a nit, but I think "GUID" is preferred over "UUID" in the context of partition types. The UEFI spec refers to what we're discussing here as "PartitionTypeGUID" (page 125): https://uefi.org/sites/default/files/resources/UEFI_Spec_2_9_2021_03_18.pdf I can work more on this next week and put up my own PR if you can't get back to this for a while. |
If you're able to put one together that would be great! |
Closing this in favor of #2745 |
I've taken a start at getting GPT GUID types into facter.
I fear I'll need a bit of help getting it over the line, but it should be a workable starting point....