Bug #15539
openENC node.rb fails to return cached yaml when server is unreachable
Description
When the Foreman server is down/unreachable the node.rb ENC script will return 1 with an error message of
Error retrieving node da1haln01pe.stsky.biz: Net::HTTPServiceUnavailable Check Foreman's /var/log/foreman/production.log for more information.
Adding "RuntimeError" to the list of rescues on line 347 fixes the issue.
rescue TimeoutError, SocketError, Errno::EHOSTUNREACH, Errno::ECONNREFUSED, RuntimeError
This is the version of node.rb I am using: https://github.com/theforeman/puppet-foreman/blob/master/files/external_node_v2.rb
Updated by Greg Sutcliffe over 8 years ago
I was helping to debug this on IRC - it seems that
- the Apache server is still up but serving Service Unavailable, so we're not hitting the timeout
- line 199 is consuming the real error code and raising RuntimeError instead
We should probably rewrite line 199 to pass the real error type up the stack and then add Net::HTTPServiceUnavailable to the list of rescues on line 347
Updated by Daniel Lobato Garcia over 8 years ago
- Pull request https://github.com/theforeman/puppet-foreman/pull/460 added
Updated by Greg Koch over 8 years ago
I applied this PR to our puppet masters. At this point we have apache up but requests to it are timing out and node.rb now returns
Could not send facts to Foreman: Net::ReadTimeoutinstead of using the cache.
Updated by Greg Koch over 8 years ago
And when Apache is stopped, we receive the following, again ignoring the cache:
Error retrieving node node.example.com: Net::HTTPServiceUnavailableCheck Foreman's /var/log/foreman/production.log for more information.
Updated by Daniel Lobato Garcia over 8 years ago
I can make it capture that Timeout error easily, I think we should rescue Timeout::Error instead, which is the parent exception of TimeoutError and ReadTimeout (and other timeouts).
The second error is kind of confusing though, as `res.code` should be 503 for Net::HTTPServiceUnavailable, which we should capture and raise here https://github.com/theforeman/puppet-foreman/pull/460/files#diff-56980159eb7873d008e28343dd19c1f3R201
Updated by The Foreman Bot almost 8 years ago
- Status changed from New to Ready For Testing
- Assignee set to Daniel Lobato Garcia
Updated by Anonymous over 7 years ago
- Status changed from Ready For Testing to New
- Assignee deleted (
Daniel Lobato Garcia)
Updated by Anonymous over 7 years ago
- Pull request deleted (
https://github.com/theforeman/puppet-foreman/pull/460)