Project

General

Profile

Actions

Bug #5925

closed

node.rb fails on first run

Added by Adam Winberg almost 10 years ago. Updated about 8 years ago.

Status:
Rejected
Priority:
Normal
Assignee:
-
Category:
External Nodes
Target version:
-
Difficulty:
Triaged:
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..?

Actions #1

Updated by Dominic Cleal almost 10 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).

Actions #2

Updated by Lukas Zapletal almost 10 years ago

Also check SELinux log, just for case.

Actions #3

Updated by Adam Winberg almost 10 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.

Actions #4

Updated by Dominic Cleal almost 10 years ago

  • Status changed from Feedback to Rejected
Actions #5

Updated by Taylor Leese almost 10 years ago

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

Actions #6

Updated by Mathieu Parent about 8 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).

Actions #7

Updated by Dominic Cleal about 8 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.

Actions #8

Updated by Mathieu Parent about 8 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)?

Actions

Also available in: Atom PDF