Jira (FACT-2937) 'puppet facts show' logs error when stdlib is installed

184 views
Skip to first unread message

Gheorghe Popescu (Jira)

unread,
Feb 5, 2021, 1:06:04 AM2/5/21
to puppe...@googlegroups.com
Gheorghe Popescu updated an issue
 
Facter / Bug FACT-2937
'puppet facts show' logs error when stdlib is installed
Change By: Gheorghe Popescu
Summary: Puppet 'puppet facts show ' logs error when stdlib is installed
Add Comment Add Comment
 
This message was sent by Atlassian Jira (v8.5.2#805002-sha1:a66f935)
Atlassian logo

Gheorghe Popescu (Jira)

unread,
Feb 5, 2021, 1:14:03 AM2/5/21
to puppe...@googlegroups.com
Gheorghe Popescu updated an issue
When running `puppet facts show` and puppetlabs-stdlib is installed, the following error message is shown:

{noformat}
Error: Could not autoload puppet/provider/service/init: undefined method `downcase' for nil:NilClass
Error: Could not autoload puppet/provider/service/bsd: Could not autoload puppet/provider/service/init: undefined method `downcase' for nil:NilClass
Error: Facter: error while resolving custom facts in /etc/puppetlabs/code/modules/stdlib/lib/facter/service_provider.rb Could not autoload puppet/provider/service/bsd: Could not autoload puppet/provider/service/init: undefined method `downcase' for nil:NilClass
{noformat}

- puppet facts show calls `Facter.resolve` which sets show_legacy to false
- when resolving facts, Facter also load modules facts(stdlib)
- stdlib has a fact that creates a dummy provider: https://github.com/puppetlabs/puppetlabs-stdlib/blob/main/lib/facter/service_provider.rb
- when Facter loads that fact, it calls Puppet to initalize the provider, Puppet tries to see what specific provider is suitable, and when it gets to `init.rb` it calls Facter back, with `operatingsystem`
- because `Facter::Options[:show_legacy]` is false, Facter.value(:operatingsystem) returns `nil`, which breaks the call of `downcase`: https://github.com/puppetlabs/puppet/blob/main/lib/puppet/provider/service/init.rb#L24

This happens because `Facter::Options` is globally set for the entire run.

Note that the command is working, and running `puppet facts show #{fact}` does not log any error

Gheorghe Popescu (Jira)

unread,
Feb 5, 2021, 1:15:03 AM2/5/21
to puppe...@googlegroups.com
Note that the command is working, and running "puppet facts show { fact } " does not log any error

Gheorghe Popescu (Jira)

unread,
Feb 5, 2021, 1:15:04 AM2/5/21
to puppe...@googlegroups.com
Note that the command is working, and running "puppet facts show # {fact}" does not log any error

Gheorghe Popescu (Jira)

unread,
Feb 5, 2021, 1:15:05 AM2/5/21
to puppe...@googlegroups.com

Josh Cooper (Jira)

unread,
Feb 5, 2021, 1:46:04 PM2/5/21
to puppe...@googlegroups.com
Josh Cooper commented on Bug FACT-2937
 
Re: 'puppet facts show' logs error when stdlib is installed

Given there are so many 3rd party modules with legacy facts in them, it seems unlikely that someone would ever be able to block legacy facts entirely for the foreseeable future. Could facter instead warn if a legacy fact is requested (with the fact name and where it came from), but still collect and return it? That way individual modules can be updated as needed? Also I'd recommend having a facter setting that could be used to hide deprecation warnings, for example, puppet has a strict setting.

Gheorghe Popescu (Jira)

unread,
Feb 9, 2021, 11:06:05 AM2/9/21
to puppe...@googlegroups.com

Mihai Buzgau (Jira)

unread,
Feb 17, 2021, 6:29:03 AM2/17/21
to puppe...@googlegroups.com
Mihai Buzgau updated an issue
Change By: Mihai Buzgau
Sprint: Triaged tickets NW - 2021-03-03

Gheorghe Popescu (Jira)

unread,
Feb 17, 2021, 6:35:04 AM2/17/21
to puppe...@googlegroups.com

Gheorghe Popescu (Jira)

unread,
Feb 17, 2021, 7:45:03 AM2/17/21
to puppe...@googlegroups.com

Josh Cooper (Jira)

unread,
Feb 26, 2021, 1:11:02 PM2/26/21
to puppe...@googlegroups.com
Josh Cooper updated an issue
Change By: Josh Cooper
Fix Version/s: FACT 4.0.52

Gene Liverman (Jira)

unread,
Mar 2, 2021, 7:03:56 PM3/2/21
to puppe...@googlegroups.com

Josh Cooper (Jira)

unread,
Mar 2, 2021, 7:18:57 PM3/2/21
to puppe...@googlegroups.com
Josh Cooper commented on Bug FACT-2937
 
Re: 'puppet facts show' logs error when stdlib is installed

I verified the "Could not autoload" errors are resolved. But if legacy facts are blocked, then Facter.value(:operatingsystem) is returning nil. I thought we were only going to block legacy facts when listed (eg puppet facts show), but not when a legacy fact is explicitly requested via `Facter.value(:operatingsystem)`? To reproduce, install stahnma/puppetlabs_yum on a redhat8 puppetserver:

# puppet module install stahnma/puppetlabs_yum
Notice: Preparing to install into /etc/puppetlabs/code/environments/production/modules ...
Notice: Downloading from https://forgeapi.puppet.com ...
Notice: Installing -- do not interrupt ...
/etc/puppetlabs/code/environments/production/modules
└── stahnma-puppetlabs_yum (v0.1.4)
# puppet agent -t
...
Info: Applying configuration version '1614713076'
Notice: Applied catalog in 0.01 seconds
# mkdir /etc/puppetlabs/facter
# cat <<END > /etc/puppetlabs/facter/facter.conf
facts : {
  blocklist: ["legacy"]
}
END
# puppet agent -t
Info: Using configured environment 'production'
Info: Retrieving pluginfacts
Info: Retrieving plugin
Info: Loading facts
Error: Facter: Error while resolving custom fact fact='os_maj_version', resolution='<anonymous>': undefined method `split' for nil:NilClass

Gheorghe Popescu (Jira)

unread,
Mar 3, 2021, 2:01:02 AM3/3/21
to puppe...@googlegroups.com

Josh Cooper thanks for looking into this. I would be inclined to move this issue to a separate ticket as it is impacting the general Facter blocking mechanism. We can talk more about it and decide the behaviour that we want.

For the `puppet facts show` issue, the fix was made in the `Facter.resolve` which fetches all the facts and then it can filter out specific facts(like legacy). If someone blocks legacy facts using the config file, that is going thorough the Facter blocking mechanism. We need to define a clear way on how we want it to behave and make sure we document it accordingly for all the uses-case.

I would assume that if someone explicitly blocks "legacy" facts in their config, they really want that, not just partially block them in certain situations.

cc Bogdan Irimie Mihai Buzgau

Mihai Buzgau (Jira)

unread,
Mar 3, 2021, 3:44:01 AM3/3/21
to puppe...@googlegroups.com
Mihai Buzgau commented on Bug FACT-2937

This ticket addresses the --show-legacy CLI option that was created with the intent to "hide" legacy facts and not to block them. 

 

Blocking should block facts. For example, if a user decides to block the EC2 metadata, any module that relies on this information will no longer work.

 

By default Facter 4 does not block any facts, it only provides a couple of pre-defined block groups that users can be used.

 

These default groups also serve as examples for creating new groups.

 

Kevin Reeuwijk (Jira)

unread,
Mar 3, 2021, 8:50:01 AM3/3/21
to puppe...@googlegroups.com

This breaks PE 2021.0.0 for me, I can't use the product at all in this state.

Kevin Reeuwijk (Jira)

unread,
Mar 3, 2021, 10:55:02 AM3/3/21
to puppe...@googlegroups.com
Kevin Reeuwijk updated an issue
 
Change By: Kevin Reeuwijk
Comment:
This breaks PE 2021.0.0 for me, I can't use the product at all in this state.

Josh Cooper (Jira)

unread,
Mar 3, 2021, 11:44:01 AM3/3/21
to puppe...@googlegroups.com

Claire Cadman (Jira)

unread,
Mar 11, 2021, 4:06:02 AM3/11/21
to puppe...@googlegroups.com
Claire Cadman updated an issue
 
Change By: Claire Cadman
Labels: customer0 doc_reviewed

Maggie Dreyer (Jira)

unread,
Mar 23, 2021, 6:51:03 PM3/23/21
to puppe...@googlegroups.com
Maggie Dreyer commented on Bug FACT-2937
 
Re: 'puppet facts show' logs error when stdlib is installed

I'm also seeing this when I start the developer repl for puppetserver, even after taking up the commit that resolved this ticket. I don't see it when I start the server from a package build. It seems to happen as part of creating the settings catalog:

2021-03-23 14:37:53,963 ERROR [clojure-agent-send-pool-0] [puppetserver] Facter error while resolving custom facts in /Users/aileen/.puppetlabs/opt/puppet/cache/lib/facter/service_provider.rb Could not autoload puppet/provider/service/upstart: Could not autoload puppet/provider/service/debian: Could not autoload puppet/provider/service/init: undefined method `downcase' for nil:NilClass
backtrace:
/Users/aileen/code/server/puppetserver/ruby/puppet/lib/puppet/provider/service/init.rb:24:in `block in <main>'
org/jruby/RubyModule.java:3249:in `module_eval'
/Users/aileen/code/server/puppetserver/ruby/puppet/lib/puppet/util/classgen.rb:132:in `genthing'
/Users/aileen/code/server/puppetserver/ruby/puppet/lib/puppet/util/classgen.rb:33:in `genclass'
/Users/aileen/code/server/puppetserver/ruby/puppet/lib/puppet/type.rb:1847:in `provide'
/Users/aileen/code/server/puppetserver/ruby/puppet/lib/puppet/provider/service/init.rb:3:in `<main>'
org/jruby/RubyKernel.java:1009:in `load'
/Users/aileen/code/server/puppetserver/ruby/puppet/lib/puppet/util/autoload.rb:78:in `load_file'
/Users/aileen/code/server/puppetserver/ruby/puppet/lib/puppet/util/autoload.rb:182:in `load'
/Users/aileen/code/server/puppetserver/ruby/puppet/lib/puppet/type.rb:1780:in `provider'
/Users/aileen/code/server/puppetserver/ruby/puppet/lib/puppet/type.rb:1832:in `provide'
/Users/aileen/code/server/puppetserver/ruby/puppet/lib/puppet/provider/service/debian.rb:3:in `<main>'
org/jruby/RubyKernel.java:1009:in `load'
/Users/aileen/code/server/puppetserver/ruby/puppet/lib/puppet/util/autoload.rb:78:in `load_file'
/Users/aileen/code/server/puppetserver/ruby/puppet/lib/puppet/util/autoload.rb:182:in `load'
/Users/aileen/code/server/puppetserver/ruby/puppet/lib/puppet/type.rb:1780:in `provider'
/Users/aileen/code/server/puppetserver/ruby/puppet/lib/puppet/type.rb:1832:in `provide'
/Users/aileen/code/server/puppetserver/ruby/puppet/lib/puppet/provider/service/upstart.rb:1:in `<main>'
org/jruby/RubyKernel.java:1009:in `load'
/Users/aileen/code/server/puppetserver/ruby/puppet/lib/puppet/util/autoload.rb:78:in `load_file'
/Users/aileen/code/server/puppetserver/ruby/puppet/lib/puppet/util/autoload.rb:93:in `block in loadall'
org/jruby/RubyArray.java:1809:in `each'
/Users/aileen/code/server/puppetserver/ruby/puppet/lib/puppet/util/autoload.rb:91:in `loadall'
/Users/aileen/code/server/puppetserver/ruby/puppet/lib/puppet/util/autoload.rb:196:in `loadall'
/Users/aileen/code/server/puppetserver/ruby/puppet/lib/puppet/metatype/manager.rb:126:in `block in newtype'
/Users/aileen/code/server/puppetserver/ruby/puppet/lib/puppet/concurrent/lock.rb:10:in `synchronize'
/Users/aileen/code/server/puppetserver/ruby/puppet/lib/puppet/metatype/manager.rb:73:in `newtype'
/Users/aileen/code/server/puppetserver/ruby/puppet/lib/puppet/type/service.rb:10:in `<module:Puppet>'
/Users/aileen/code/server/puppetserver/ruby/puppet/lib/puppet/type/service.rb:8:in `<main>'
org/jruby/RubyKernel.java:974:in `require'
uri:classloader:/META-INF/jruby.home/lib/ruby/stdlib/rubygems/core_ext/kernel_require.rb:54:in `require'
/Users/aileen/.puppetlabs/opt/puppet/cache/lib/facter/service_provider.rb:11:in `<main>'
org/jruby/RubyKernel.java:1009:in `load'
/Users/aileen/code/server/puppetserver/ruby/facter/lib/facter/custom_facts/util/loader.rb:129:in `kernel_load'
/Users/aileen/code/server/puppetserver/ruby/facter/lib/facter/custom_facts/util/loader.rb:112:in `load_file'
/Users/aileen/code/server/puppetserver/ruby/facter/lib/facter/custom_facts/util/loader.rb:47:in `block in load_all'
org/jruby/RubyArray.java:1809:in `each'
/Users/aileen/code/server/puppetserver/ruby/facter/lib/facter/custom_facts/util/loader.rb:45:in `block in load_all'
org/jruby/RubyArray.java:1809:in `each'
/Users/aileen/code/server/puppetserver/ruby/facter/lib/facter/custom_facts/util/loader.rb:41:in `load_all'
/Users/aileen/code/server/puppetserver/ruby/facter/lib/facter/custom_facts/util/collection.rb:120:in `custom_facts'
/Users/aileen/code/server/puppetserver/ruby/facter/lib/facter/framework/core/fact_loaders/external_fact_loader.rb:20:in `load_custom_facts'
/Users/aileen/code/server/puppetserver/ruby/facter/lib/facter/framework/core/fact_loaders/external_fact_loader.rb:6:in `custom_facts'
/Users/aileen/code/server/puppetserver/ruby/facter/lib/facter/framework/core/fact_loaders/fact_loader.rb:57:in `load_custom_facts'
/Users/aileen/code/server/puppetserver/ruby/facter/lib/facter/framework/core/fact_manager.rb:114:in `all_custom_facts'
/Users/aileen/code/server/puppetserver/ruby/facter/lib/facter/framework/core/fact_manager.rb:50:in `resolve_fact'
/Users/aileen/code/server/puppetserver/ruby/facter/lib/facter.rb:549:in `resolve_fact'
/Users/aileen/code/server/puppetserver/ruby/facter/lib/facter.rb:396:in `value'
/Users/aileen/code/server/puppetserver/ruby/puppet/lib/puppet/confine/variable.rb:21:in `facter_value'
/Users/aileen/code/server/puppetserver/ruby/puppet/lib/puppet/confine/variable.rb:57:in `test_value'
/Users/aileen/code/server/puppetserver/ruby/puppet/lib/puppet/confine/variable.rb:45:in `valid?'
/Users/aileen/code/server/puppetserver/ruby/puppet/lib/puppet/confine_collection.rb:49:in `block in valid?'
org/jruby/RubyEnumerable.java:671:in `detect'
/Users/aileen/code/server/puppetserver/ruby/puppet/lib/puppet/confine_collection.rb:49:in `valid?'
/Users/aileen/code/server/puppetserver/ruby/puppet/lib/puppet/confiner.rb:44:in `suitable?'
/Users/aileen/code/server/puppetserver/ruby/puppet/lib/puppet/type.rb:1949:in `block in suitableprovider'
org/jruby/RubyHash.java:1415:in `each'
org/jruby/RubyEnumerable.java:842:in `find_all'
/Users/aileen/code/server/puppetserver/ruby/puppet/lib/puppet/type.rb:1948:in `suitableprovider'
/Users/aileen/code/server/puppetserver/ruby/puppet/lib/puppet/type.rb:1738:in `defaultprovider'
/Users/aileen/code/server/puppetserver/ruby/puppet/lib/puppet/type.rb:1901:in `block in default'
/Users/aileen/code/server/puppetserver/ruby/puppet/lib/puppet/type.rb:844:in `set_default'
/Users/aileen/code/server/puppetserver/ruby/puppet/lib/puppet/type.rb:2371:in `initialize'
/Users/aileen/code/server/puppetserver/ruby/puppet/lib/puppet/type/file.rb:537:in `initialize'
/Users/aileen/code/server/puppetserver/ruby/puppet/lib/puppet/resource.rb:475:in `to_ral'
/Users/aileen/code/server/puppetserver/ruby/puppet/lib/puppet/resource/catalog.rb:610:in `block in to_catalog'
org/jruby/RubyArray.java:1809:in `each'
/Users/aileen/code/server/puppetserver/ruby/puppet/lib/puppet/resource/catalog.rb:602:in `to_catalog'
/Users/aileen/code/server/puppetserver/ruby/puppet/lib/puppet/resource/catalog.rb:495:in `to_ral'
/Users/aileen/code/server/puppetserver/ruby/puppet/lib/puppet/settings.rb:1103:in `use'
uri:classloader:/puppetserver-lib/puppet/server/puppet_config.rb:92:in `initialize_puppet'
uri:classloader:/puppetserver-lib/puppet/server/master.rb:39:in `initialize'

Reply all
Reply to author
Forward
0 new messages