ENC node.rb fails to return cached yaml when server is unreachable
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
#1 Updated by Greg Sutcliffe over 5 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
#5 Updated by Daniel Lobato Garcia about 5 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