Skip to content

(FACT-3186) Handle partitions fact when none exist#2575

Merged
joshcooper merged 1 commit intopuppetlabs:mainfrom
mhashizume:FACT-3186/main/partition-hash
Jun 6, 2023
Merged

(FACT-3186) Handle partitions fact when none exist#2575
joshcooper merged 1 commit intopuppetlabs:mainfrom
mhashizume:FACT-3186/main/partition-hash

Conversation

@mhashizume
Copy link
Contributor

@mhashizume mhashizume commented May 19, 2023

Prior to this commit, when a diskless machine used Facter the partitions fact errored out with an undefined method error. This was because the machine did not have any partitions and Facter was unable to dig into the partitions hash because the hash didn't exist.

This commit updates Linux's partition fact to return nil early in the partitions method if the partitions resolver returns nothing.

@mhashizume
Copy link
Contributor Author

Opening as a draft PR until I can do more testing

@joshcooper
Copy link
Contributor

joshcooper commented May 24, 2023

Wondering if these other facts have the same issue:

❯ git grep -A2 ' mountpoints\.each ' lib
lib/facter/facts/freebsd/mountpoints.rb:        mountpoints.each do |mnt|
lib/facter/facts/freebsd/mountpoints.rb-          fact[mnt[:path].to_sym] = mnt.reject { |k| k == :path }
lib/facter/facts/freebsd/mountpoints.rb-        end
--
lib/facter/facts/linux/mountpoints.rb:        mountpoints.each do |mnt|
lib/facter/facts/linux/mountpoints.rb-          fact[mnt[:path].to_sym] = mnt.reject { |k| k == :path }
lib/facter/facts/linux/mountpoints.rb-        end
--
lib/facter/facts/solaris/mountpoints.rb:        mountpoints.each do |mnt|
lib/facter/facts/solaris/mountpoints.rb-          fact[mnt[:path].to_sym] = mnt.reject { |k| k == :path }
lib/facter/facts/solaris/mountpoints.rb-        end

@mhashizume mhashizume force-pushed the FACT-3186/main/partition-hash branch from 972c86d to 752655f Compare May 30, 2023 17:50
@mhashizume
Copy link
Contributor Author

@joshcooper I don't think we need to worry about those facts because this should only be an issue with partitions, right?

Prior to this commit, when a diskless machine used Facter the
partitions fact errored out with an undefined method error. This was
because the machine did not have any partitions and Facter was unable
to dig into the partitions hash because the hash didn't exist.

This commit updates Linux's partition fact to return nil early in
the partitions method if the partitions resolver returns nothing.
@mhashizume mhashizume force-pushed the FACT-3186/main/partition-hash branch from 752655f to 1505961 Compare May 30, 2023 17:53
@mhashizume
Copy link
Contributor Author

After some feedback from the user who reported this issue, I've updated my fix

@mhashizume mhashizume marked this pull request as ready for review June 5, 2023 20:19
@mhashizume mhashizume requested a review from a team as a code owner June 5, 2023 20:19
@mhashizume
Copy link
Contributor Author

Confirmed with the user in the ticket that this fixes the issue.

@joshcooper joshcooper merged commit b64cd02 into puppetlabs:main Jun 6, 2023
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

Comments