Jira (PUP-5362) `puppet agent` errors out if it can't get a catalog and there's no catalog in the cache

6 views
Skip to first unread message

William Hopper (JIRA)

unread,
Oct 13, 2015, 8:31:03 PM10/13/15
to puppe...@googlegroups.com
William Hopper created an issue
 
Puppet / Bug PUP-5362
`puppet agent` errors out if it can't get a catalog and there's no catalog in the cache
Issue Type: Bug Bug
Affects Versions: PUP 4.2.2, PUP 3.8.3
Assignee: Unassigned
Created: 2015/10/13 5:30 PM
Environment:

All platforms

Priority: Normal Normal
Reporter: William Hopper

When `puppet agent` is run without the `--no-usecacheonfailure` option (as is the case when running puppet resource service puppet ensure=running, and there is no catalog available in the cache, puppet will explode with:

/root/puppet/lib/puppet/agent.rb:77:in `exit': no implicit conversion from nil to integer (TypeError)
        from /root/puppet/lib/puppet/agent.rb:77:in `block in run_in_fork'
        from /root/puppet/lib/puppet/agent.rb:74:in `fork'
        from /root/puppet/lib/puppet/agent.rb:74:in `run_in_fork'
        from /root/puppet/lib/puppet/agent.rb:41:in `block in run'
        from /root/puppet/lib/puppet/application.rb:179:in `call'
        from /root/puppet/lib/puppet/application.rb:179:in `controlled_run'
        from /root/puppet/lib/puppet/agent.rb:39:in `run'
        from /root/puppet/lib/puppet/daemon.rb:163:in `block in run_event_loop'
        from /root/puppet/lib/puppet/scheduler/job.rb:49:in `call'
        from /root/puppet/lib/puppet/scheduler/job.rb:49:in `run'
        from /root/puppet/lib/puppet/scheduler/scheduler.rb:39:in `block in run_ready'
        from /root/puppet/lib/puppet/scheduler/scheduler.rb:34:in `each'
        from /root/puppet/lib/puppet/scheduler/scheduler.rb:34:in `run_ready'
        from /root/puppet/lib/puppet/scheduler/scheduler.rb:11:in `run_loop'
        from /root/puppet/lib/puppet/daemon.rb:186:in `run_event_loop'
        from /root/puppet/lib/puppet/daemon.rb:142:in `start'
        from /root/puppet/lib/puppet/application/agent.rb:369:in `main'
        from /root/puppet/lib/puppet/application/agent.rb:330:in `run_command'
        from /root/puppet/lib/puppet/application.rb:344:in `block in run'
        from /root/puppet/lib/puppet/util.rb:446:in `exit_on_fail'
        from /root/puppet/lib/puppet/application.rb:344:in `run'
        from /root/puppet/lib/puppet/util/command_line.rb:128:in `run'
        from /root/puppet/lib/puppet/util/command_line.rb:72:in `execute'
        from /root/puppet/bin/puppet:5:in `<top (required)>'
        from /usr/local/share/gems/bin/puppet:23:in `load'
        from /usr/local/share/gems/bin/puppet:23:in `<main>'

This is only one set of circumstances that can cause this to happen. If anything in the process of getting a catalog raises an error and returns nil at any point, the same thing will happen.

This was introduced by https://github.com/puppetlabs/puppet/commit/fa4a1d9, a commit merged over 3 years ago.

As a consequence of this, if puppet resource service puppet ensure=running is used and this happens, the service cannot be stopped using normal means, other than killing the process.

Add Comment Add Comment
 
This message was sent by Atlassian JIRA (v6.4.11#64026-sha1:78f6ec4)
Atlassian logo

Josh Cooper (JIRA)

unread,
Oct 13, 2015, 11:56:01 PM10/13/15
to puppe...@googlegroups.com
Josh Cooper commented on Bug PUP-5362
 
Re: `puppet agent` errors out if it can't get a catalog and there's no catalog in the cache

This is a regression introduced in fa4a1d9 in 3.0.0 as part of applying the catalog in a forked child.

Josh Cooper (JIRA)

unread,
Oct 13, 2015, 11:57:02 PM10/13/15
to puppe...@googlegroups.com
Josh Cooper updated an issue
 
Change By: Josh Cooper
Comment: This is a regression introduced in [fa4a1d9|https://github.com/puppetlabs/puppet/commit/fa4a1d9] in 3.0.0 as part of applying the catalog in a forked child.

William Hopper (JIRA)

unread,
Oct 14, 2015, 2:02:09 PM10/14/15
to puppe...@googlegroups.com

Jacob Helwig (JIRA)

unread,
Dec 4, 2017, 6:26:03 PM12/4/17
to puppe...@googlegroups.com
Jacob Helwig updated an issue
Change By: Jacob Helwig
Sub-team: Coremunity
This message was sent by Atlassian JIRA (v7.0.2#70111-sha1:88534db)
Atlassian logo

Josh Cooper (JIRA)

unread,
Jun 10, 2019, 7:28:03 PM6/10/19
to puppe...@googlegroups.com
Josh Cooper commented on Bug PUP-5362
 
Re: `puppet agent` errors out if it can't get a catalog and there's no catalog in the cache

Here's an easy way to repro:

[root@nkvytwnhz7rwoj2 ~]# puppet agent --no-daemonize --verbose --server localhost
Notice: Starting Puppet client version 5.5.13
...
Error: Could not retrieve catalog from remote server: Failed to open TCP connection to localhost:8140 (Connection refused - connect(2) for "localhost" port 8140)
Error: Could not retrieve catalog; skipping run
Error: Could not send report: Failed to open TCP connection to localhost:8140 (Connection refused - connect(2) for "localhost" port 8140)
/opt/puppetlabs/puppet/lib/ruby/vendor_ruby/puppet/agent.rb:98:in `exit': no implicit conversion from nil to integer (TypeError)
	from /opt/puppetlabs/puppet/lib/ruby/vendor_ruby/puppet/agent.rb:98:in `block in run_in_fork'
	from /opt/puppetlabs/puppet/lib/ruby/vendor_ruby/puppet/agent.rb:94:in `fork'
	from /opt/puppetlabs/puppet/lib/ruby/vendor_ruby/puppet/agent.rb:94:in `run_in_fork'
	from /opt/puppetlabs/puppet/lib/ruby/vendor_ruby/puppet/agent.rb:48:in `block in run'
	from /opt/puppetlabs/puppet/lib/ruby/vendor_ruby/puppet/application.rb:179:in `controlled_run'
	from /opt/puppetlabs/puppet/lib/ruby/vendor_ruby/puppet/agent.rb:46:in `run'
	from /opt/puppetlabs/puppet/lib/ruby/vendor_ruby/puppet/daemon.rb:170:in `block in run_event_loop'
	from /opt/puppetlabs/puppet/lib/ruby/vendor_ruby/puppet/scheduler/job.rb:49:in `run'
	from /opt/puppetlabs/puppet/lib/ruby/vendor_ruby/puppet/scheduler/scheduler.rb:39:in `block in run_ready'
	from /opt/puppetlabs/puppet/lib/ruby/vendor_ruby/puppet/scheduler/scheduler.rb:34:in `each'
	from /opt/puppetlabs/puppet/lib/ruby/vendor_ruby/puppet/scheduler/scheduler.rb:34:in `run_ready'
	from /opt/puppetlabs/puppet/lib/ruby/vendor_ruby/puppet/scheduler/scheduler.rb:11:in `run_loop'
	from /opt/puppetlabs/puppet/lib/ruby/vendor_ruby/puppet/daemon.rb:193:in `run_event_loop'
	from /opt/puppetlabs/puppet/lib/ruby/vendor_ruby/puppet/daemon.rb:149:in `start'
	from /opt/puppetlabs/puppet/lib/ruby/vendor_ruby/puppet/application/agent.rb:390:in `main'
	from /opt/puppetlabs/puppet/lib/ruby/vendor_ruby/puppet/application/agent.rb:352:in `run_command'
	from /opt/puppetlabs/puppet/lib/ruby/vendor_ruby/puppet/application.rb:375:in `block in run'
	from /opt/puppetlabs/puppet/lib/ruby/vendor_ruby/puppet/util.rb:667:in `exit_on_fail'
	from /opt/puppetlabs/puppet/lib/ruby/vendor_ruby/puppet/application.rb:375:in `run'
	from /opt/puppetlabs/puppet/lib/ruby/vendor_ruby/puppet/util/command_line.rb:139:in `run'
	from /opt/puppetlabs/puppet/lib/ruby/vendor_ruby/puppet/util/command_line.rb:77:in `execute'

This message was sent by Atlassian JIRA (v7.7.1#77002-sha1:e75ca93)
Atlassian logo

Josh Cooper (JIRA)

unread,
Feb 21, 2020, 5:35:10 PM2/21/20
to puppe...@googlegroups.com

Josh Cooper (JIRA)

unread,
Feb 21, 2020, 5:38:06 PM2/21/20
to puppe...@googlegroups.com
Josh Cooper commented on Bug PUP-5362
 
Re: `puppet agent` errors out if it can't get a catalog and there's no catalog in the cache

This was fixed in PUP-6256 to not blow up, but it now exits 0 instead of 1:

$ bx puppet agent -t
Info: Using configured environment 'production'
Info: Retrieving pluginfacts
Info: Retrieving plugin
Info: Retrieving locales
Info: Caching catalog for XXX
Info: Applying configuration version '1582324566'
Notice: Applied catalog in 0.04 seconds
$ bx puppet agent --no-daemonize --verbose --server localhost --onetime
Warning: Unable to fetch my node definition, but the agent run will continue:
Warning: Failed to open TCP connection to localhost:8140 (Connection refused - connect(2) for "localhost" port 8140)
Info: Retrieving pluginfacts
Error: /File[/Users/josh/.puppetlabs/opt/puppet/cache/facts.d]: Failed to generate additional resources using 'eval_generate': Failed to open TCP connection to localhost:8140 (Connection refused - connect(2) for "localhost" port 8140)
Error: /File[/Users/josh/.puppetlabs/opt/puppet/cache/facts.d]: Could not evaluate: Could not retrieve file metadata for puppet:///pluginfacts: Failed to open TCP connection to localhost:8140 (Connection refused - connect(2) for "localhost" port 8140)
Info: Retrieving plugin
Error: /File[/Users/josh/.puppetlabs/opt/puppet/cache/lib]: Failed to generate additional resources using 'eval_generate': Failed to open TCP connection to localhost:8140 (Connection refused - connect(2) for "localhost" port 8140)
Error: /File[/Users/josh/.puppetlabs/opt/puppet/cache/lib]: Could not evaluate: Could not retrieve file metadata for puppet:///plugins: Failed to open TCP connection to localhost:8140 (Connection refused - connect(2) for "localhost" port 8140)
Error: Could not retrieve catalog from remote server: Failed to open TCP connection to localhost:8140 (Connection refused - connect(2) for "localhost" port 8140)
Info: Using cached catalog from environment 'production'
Info: Caching catalog for XXX
Info: Applying configuration version '1582324566'
Notice: Applied catalog in 0.02 seconds
Error: Could not send report: Failed to open TCP connection to localhost:8140 (Connection refused - connect(2) for "localhost" port 8140)
$ echo $?
0

Josh Cooper (JIRA)

unread,
Feb 21, 2020, 5:40:04 PM2/21/20
to puppe...@googlegroups.com
Josh Cooper updated an issue
Change By: Josh Cooper
Summary: `puppet agent` exitserrors errors out if it can't get a catalog and there's no catalog in the cache
Reply all
Reply to author
Forward
0 new messages