Project

General

Profile

Bug #15539

ENC node.rb fails to return cached yaml when server is unreachable

Added by Greg Koch over 5 years ago. Updated over 4 years ago.

Status:
New
Priority:
Normal
Assignee:
-
Category:
-
Target version:
-
Difficulty:
Triaged:
No
Bugzilla link:
Pull request:
Fixed in Releases:
Found in Releases:

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

History

#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

#2 Updated by Daniel Lobato Garcia about 5 years ago

  • Pull request https://github.com/theforeman/puppet-foreman/pull/460 added

#3 Updated by Greg Koch about 5 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::ReadTimeout
instead of using the cache.

#4 Updated by Greg Koch about 5 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.

#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

#6 Updated by The Foreman Bot almost 5 years ago

  • Status changed from New to Ready For Testing
  • Assignee set to Daniel Lobato Garcia

#7 Updated by Anonymous over 4 years ago

  • Status changed from Ready For Testing to New
  • Assignee deleted (Daniel Lobato Garcia)

#8 Updated by Anonymous over 4 years ago

  • Pull request deleted (https://github.com/theforeman/puppet-foreman/pull/460)

Also available in: Atom PDF