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

Hide read error on params when you can't read them #78

Merged
merged 1 commit into from
Feb 4, 2022
Merged

Hide read error on params when you can't read them #78

merged 1 commit into from
Feb 4, 2022

Conversation

jcpunk
Copy link
Contributor

@jcpunk jcpunk commented Feb 3, 2022

Pull Request (PR) description

This should keep from showing errors on params that are write only.

This Pull Request (PR) fixes the following issues

None listed

@jcpunk jcpunk mentioned this pull request Feb 3, 2022
@kenyon
Copy link
Member

kenyon commented Feb 3, 2022

Still getting the permission denied warning:

kenyon@beta ~ % sudo puppet agent --test
Info: Using environment 'production'
Info: Retrieving pluginfacts
Info: Retrieving plugin
Notice: /File[/opt/puppetlabs/puppet/cache/lib/facter/kmod.rb]/content: 
--- /opt/puppetlabs/puppet/cache/lib/facter/kmod.rb     2022-02-02 17:58:56.180765273 -0800
+++ /tmp/puppet-file20220203-2601855-1i8wwif    2022-02-03 11:30:26.940804768 -0800
@@ -20,7 +20,7 @@
             Dir.foreach("/sys/module/#{directory}/parameters") do |param|
               next if ['.', '..'].include?(param)
 
-              kmod[directory]['parameters'][param] = File.read("/sys/module/#{directory}/parameters/#{param}").chomp
+              File.readable?("/sys/module/#{directory}/parameters/#{param}") && kmod[directory]['parameters'][param] = File.read("/sys/module/#{directory}/parameters/#{param}").chomp
             end
           rescue StandardError => e
             Facter.warn(e)

Notice: /File[/opt/puppetlabs/puppet/cache/lib/facter/kmod.rb]/content: content changed '{sha256}fe381dbb71ff5b063831169603b60d4bae91633880b5507ff5ff3c7b2170e8c8' to '{sha256}5f8358eb3c933fce630fe4bad46420ed123a25e669e9e332f26d2b10f530fbef'
Info: Loading facts
Warning: Facter: Permission denied @ rb_sysopen - /sys/module/md_mod/parameters/new_array
Info: Caching catalog for beta.kenyonralph.com
Info: Applying configuration version '4e0655397e4b0277f9827a063b07e06f57ea44c0'
Notice: Applied catalog in 15.38 seconds

Not sure where it's coming from. Would be nice if the warning could give a line number.

@jcpunk
Copy link
Contributor Author

jcpunk commented Feb 3, 2022

I'm showing that file as write only:

ls -l /sys/module/md_mod/parameters/new_array
--w-------. 1 root root 4096 Feb  3 13:53 /sys/module/md_mod/parameters/new_array

What does it look like on your system?

@jcpunk
Copy link
Contributor Author

jcpunk commented Feb 3, 2022

Pushed up a new version to try and do better....

@kenyon
Copy link
Member

kenyon commented Feb 3, 2022

Same, /sys/module/md_mod/parameters/new_array is write only.

@kenyon
Copy link
Member

kenyon commented Feb 3, 2022

No more warnings with commit ba9c4ac. 👍

I can see the warning when running puppet agent --test --debug, but that's fine.

lib/facter/kmod.rb Outdated Show resolved Hide resolved
Co-authored-by: Raphaël Pinson <github+aem1eeshi1@raphink.net>
@bastelfreak bastelfreak merged commit 1539557 into voxpupuli:master Feb 4, 2022
@jcpunk jcpunk deleted the hide-error branch February 4, 2022 16:33
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.

4 participants