Jira (FACT-2999) Facter cannot autoload provider from stdlib inside puppetserver repl

24 views
Skip to first unread message

Maggie Dreyer (Jira)

unread,
Mar 26, 2021, 11:22:04 AM3/26/21
to puppe...@googlegroups.com
Maggie Dreyer created an issue
 
Facter / Bug FACT-2999
Facter cannot autoload provider from stdlib inside puppetserver repl
Issue Type: Bug Bug
Assignee: Unassigned
Created: 2021/03/26 8:21 AM
Priority: Normal Normal
Reporter: Maggie Dreyer

When starting puppetserver from the repl, I get the following stack trace while trying to resolve facts:

2021-03-26 08:10:19,454 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:1099:in `use'
uri:classloader:/puppetserver-lib/puppet/server/puppet_config.rb:91:in `initialize_puppet'
uri:classloader:/puppetserver-lib/puppet/server/master.rb:39:in `initialize'

It doesn't prevent the server from starting, so this isn't pressing, but it looks like the same error as in FACT-2937, which was resolved. Apparently that fix wasn't sufficient for whatever is going on in this environment. We run into this while trying to construct the Puppet settings catalog, which is a Puppet catalog constructed internally on init that enforces file-related settings.

Note that this does not happen in a package install, only in the repl environment.

Add Comment Add Comment
 
This message was sent by Atlassian Jira (v8.5.2#805002-sha1:a66f935)
Atlassian logo

Mihai Buzgau (Jira)

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

Mihai Buzgau (Jira)

unread,
Mar 29, 2021, 3:26:03 AM3/29/21
to puppe...@googlegroups.com

Mihai Buzgau (Jira)

unread,
Mar 29, 2021, 3:26:04 AM3/29/21
to puppe...@googlegroups.com

Gabriel Nagy (Jira)

unread,
Mar 29, 2021, 11:29:04 AM3/29/21
to puppe...@googlegroups.com
Gabriel Nagy commented on Bug FACT-2999
 
Re: Facter cannot autoload provider from stdlib inside puppetserver repl

Hi Maggie,

We were able to reproduce this issue by running from source on both macOS and Linux (RHEL & Arch). From what we found out, it seems that the first
call to Facter::Core::Execution.execute always fails. When running on macOS the first call happens when resolving the operatingsystem fact:
https://github.com/puppetlabs/facter/blob/main/lib/facter/resolvers/uname.rb#L16

This is also reproducible without stdlib, but it might fail silently if the fact that is queried is not used anywhere (for example, for me on Linux it failed when resolving some networking macaddress facts).

The call that fails is the Process.waitpid here: https://github.com/puppetlabs/facter/blob/main/lib/facter/custom_facts/core/execution/popen3.rb#L23

We observed that only the first execution is problematic, subsequent ones work correctly. In our case Process.waitpid fails with #<Errno::ENOENT: No such file or directory - No such file or directory> (the error is doubled for some reason: https://github.com/jruby/jruby/blob/89380e03689eb4361b25f3829cfde1156f8bb76a/core/src/main/java/org/jruby/ext/JRubyPOSIXHelper.java#L20)

We found the following JRuby issue which seems very similar: https://github.com/jruby/jruby/issues/5971

We're still searching for a viable workaround. It's also interesting that this only happens when running from source and not with packaged versions.

Maggie Dreyer (Jira)

unread,
Mar 29, 2021, 11:57:04 AM3/29/21
to puppe...@googlegroups.com

Ah yeah, that JRuby issue has bitten us before. Doesn't sound like they've made any progress with it... too bad.

In whatever way it's failing, it doesn't really seem to be causing an issue generally, and not for real users, so I'm okay ignoring the stacktrace for now, though we should probably keep this ticket open as something to point to, if that's okay.

Gabriel Nagy (Jira)

unread,
Mar 30, 2021, 11:02:02 AM3/30/21
to puppe...@googlegroups.com

Gabriel Nagy (Jira)

unread,
Mar 30, 2021, 11:05:03 AM3/30/21
to puppe...@googlegroups.com
Gabriel Nagy commented on Bug FACT-2999
 
Re: Facter cannot autoload provider from stdlib inside puppetserver repl

Opened a PR with a workaround here: https://github.com/puppetlabs/facter/pull/2332

It looks like even though Process.wait fails, the command output is correctly parsed so silently continuing in this case fixes the issue.

Josh Cooper (Jira)

unread,
Mar 30, 2021, 12:05:03 PM3/30/21
to puppe...@googlegroups.com

Mihai Buzgau (Jira)

unread,
Mar 31, 2021, 5:31:05 AM3/31/21
to puppe...@googlegroups.com
Mihai Buzgau updated an issue
Change By: Mihai Buzgau
Sprint: NW - 2021-03-31 , NW - 2021-04-14

Josh Cooper (Jira)

unread,
Apr 1, 2021, 2:07:04 PM4/1/21
to puppe...@googlegroups.com

Claire Cadman (Jira)

unread,
Apr 13, 2021, 9:20:01 AM4/13/21
to puppe...@googlegroups.com
Claire Cadman updated an issue
 
Change By: Claire Cadman
Labels: doc_reviewed
This message was sent by Atlassian Jira (v8.13.2#813002-sha1:c495a97)
Atlassian logo
Reply all
Reply to author
Forward
0 new messages