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

(FACT-3423) sys-filesystem updates #2604

Merged

Conversation

mhashizume
Copy link
Contributor

@mhashizume mhashizume commented Aug 29, 2023

This PR:

  • Moves sys-filesystem back from a runtime dependency to a development dependency.
  • Rescues LoadError in resolvers that depend on sys-filesystem.
  • Adds ffi as a development dependency, as some resolvers depend on ffi but it's only implicitly required through sys-filesystem.
  • Updates resolvers that depend on ffi to log a debug message when ffi is not present.
  • Fixes a minor Rubocop issue

@mhashizume mhashizume requested a review from a team as a code owner August 29, 2023 18:09
@mhashizume mhashizume force-pushed the FACT-3423/main/sys-filesystem-fix branch 2 times, most recently from 2f63622 to 3956912 Compare August 29, 2023 22:55
@mhashizume mhashizume force-pushed the FACT-3423/main/sys-filesystem-fix branch 6 times, most recently from 22e1b2a to 2908ce3 Compare September 5, 2023 18:46
@mhashizume mhashizume marked this pull request as draft September 5, 2023 19:04
In 19c2bb1, we moved sys-filesystem from a development to runtime
dependency. This was done because we mistakenly believed that a
LoadError introduced in Facter 4.4.2 was caused because sys-filesystem
was not a runtime dependency.

The LoadError was actually caused by another change: updating the base
resolver to log an error instead of a debug message on LoadError
(50bbef9).

The team that originally wrote Facter 4 intended for sys-filesystem to
be a development dependency due to its dependency on ffi. ffi contains
native extensions and would mean that `gem install facter` would require
a compiler.

This commit moves sys-filesystem back from a runtime to development
dependency and leaves a comment in the gemspec explaining the reasoning
for its placement.
In 50bbef9, we changed the base resolver's behavior to cause LoadErrors
to log an error by default. Previously, we had only logged a debug
message.

This commit updates several mountpoint resolvers to rescue LoadError
when calling the `read_mountpoint_stats` method, which requires the
sys-filesystem gem. sys-filesystem is only listed as a development
dependency (see dbc5a7c) and may not be present at runtime.
The ffi gem is a dependency for the FFI module in Facter. However, the
dependency on the ffi gem is only met as a transitive dependency through
sys-filesystem.

This commit adds the ffi gem as a development dependency to the gemspec.

The ffi gem is being added as a development dependency, as opposed to a
runtime dependency, because it contains native extensions. The original
intent was to allow users to install Facter without a compiler to be as
portable as possible, and native extensions would prevent that from
happening.
@mhashizume mhashizume force-pushed the FACT-3423/main/sys-filesystem-fix branch 4 times, most recently from d1c1257 to 0bddf6b Compare September 7, 2023 21:59
The ffi gem is required in many parts of Facter, but is not guaranteed
to be present because it is only a development dependency, not a runtime
dependency.

This commit updates modules that require ffi to add exception handling
for when ffi has not been installed and a LoadError is thrown.
@mhashizume mhashizume force-pushed the FACT-3423/main/sys-filesystem-fix branch from 0bddf6b to f912088 Compare September 7, 2023 22:03
@mhashizume mhashizume marked this pull request as ready for review September 7, 2023 22:22
Copy link
Contributor

@tvpartytonight tvpartytonight left a 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 if there is a better pattern than the implementing a LoadError rescue for each of these locations, seems like a whack-a-mole issue that could end up being problematic later on, but I think it works for now to remove the unwanted transitive dependency.

@tvpartytonight tvpartytonight merged commit 12b1e6f into puppetlabs:main Sep 11, 2023
@mhashizume mhashizume deleted the FACT-3423/main/sys-filesystem-fix branch September 16, 2023 17:00
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.

3 participants