Project

General

Profile

Bug #5925

node.rb fails on first run

Added by Adam Winberg about 5 years ago. Updated over 3 years ago.

Status:
Rejected
Priority:
Normal
Assignee:
-
Category:
External Nodes
Target version:
-
Difficulty:
Triaged:
No
Bugzilla link:
Pull request:
Team Backlog:
Fixed in Releases:
Found in Releases:

Description

node.rb fails on first run because of missing yaml file.

in node.rb, def generate_fact_request, this line:
last_fact = File.stat(filename).mtime.utc

causes node.rb to 'crash' if the file does not exist (i.e. on first puppetrun) with error message 'No such file or directory - /var/lib/puppet/yaml/facts/<fqdn>.yaml'.

Adding a simple check before above mentioned line fixes the problem:
if File.exists?(filename)
last_fact = File.stat(filename).mtime.utc
else
#print "No yaml file, probably first run. Will not push facts to foreman"
return
end

Feels like a bug, but maybe we're doing something wrong..?

History

#1 Updated by Dominic Cleal about 5 years ago

  • Status changed from New to Feedback

Puppet should always create the facts YAML file before running the ENC, so not sure how you could get into this situation.

I've sometimes seen Puppet not create YAML files, usually it's a config error: /etc/puppet/routes.yaml overriding it, strange puppet.conf entries or a badly configured config.ru for Passenger (typically when upgrading Puppet 2 to 3).

#2 Updated by Lukas Zapletal about 5 years ago

Also check SELinux log, just for case.

#3 Updated by Adam Winberg about 5 years ago

alright, had a feeling something was not right. I have checked further in logs and all these shenanigans started when I upgraded to puppet 3.4, so i will investigate in that end instead. Thanks for the pointers, you can obviously close this report now.

#4 Updated by Dominic Cleal about 5 years ago

  • Status changed from Feedback to Rejected

#5 Updated by Taylor Leese almost 5 years ago

I'm actually running into this same issue in an unrelated project. I'm curious if something specific resolved it?

#6 Updated by Mathieu Parent over 3 years ago

I reproduce the problem on a new puppetmaster.

Setting log_level to debug on this newmaster print the following:

[...]
Mar  3 11:53:59 newmaster puppet-master[17135]: Starting Puppet master version 3.8.4
[...]
Mar  3 11:53:59 newmaster puppet-master[17147]: Handling request: GET /production/node/myagent.example.com?transaction_uuid=47faf14c-a347-4e4b-a5ab-7dbec6a26af6&fail_on_404=true
[...]
Mar  3 11:53:59 newmaster puppet-master[17147]: Executing '/etc/puppet/node.rb myagent.example.com'
[...]
Mar  3 11:54:00 newmaster puppet-master[17147]: Handling request: GET /production/file_metadatas/pluginfacts?links=manage&recurse=true&ignore=.svn&ignore=CVS&ignore=.git&checksum_type=md5
[...]
Mar  3 11:54:01 newmaster puppet-master[17147]: Handling request: GET /production/file_metadatas/plugins?links=manage&recurse=true&ignore=.svn&ignore=CVS&ignore=.git&checksum_type=md5
[...]
Mar  3 11:54:37 newmaster puppet-master[17147]: Handling request: PUT /production/report/myagent.example.com
[...]

I suppose that facts are executed on the agent after the "pluginfacts" and "plugins" requests. So node.rb is indeed executed before the fact upload (which I don't find in the log).

#7 Updated by Dominic Cleal over 3 years ago

Puppet 3 will now perform a node lookup before pluginsync to fetch its environment, which if the node has never checked in before will result in a warning from the Puppet agent as the node's unknown. This is normal. It should though perform a regular ENC run with no errors when it fetches the catalog.

Matthieu, your log is showing this first node fetch but it doesn't show the subsequent catalog fetch. The fetch for a catalog will upload facts from the agent, and the ENC run should then be successful. Subsequent runs will be fine on both requests as the ENC knows the agent.

#8 Updated by Mathieu Parent over 3 years ago

Dominic Cleal wrote:

Puppet 3 will now perform a node lookup before pluginsync to fetch its environment, which if the node has never checked in before will result in a warning from the Puppet agent as the node's unknown. This is normal. It should though perform a regular ENC run with no errors when it fetches the catalog.

Matthieu, your log is showing this first node fetch but it doesn't show the subsequent catalog fetch. The fetch for a catalog will upload facts from the agent, and the ENC run should then be successful. Subsequent runs will be fine on both requests as the ENC knows the agent.

I agree, But I don't find any "POST /production/catalog/myagent.example.com" in the log. Could it go to the main master (which I couldn't set to debug because of too many nodes)?

Also available in: Atom PDF