Project

General

Profile

Actions

Bug #15539

open

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

Added by Greg Koch almost 8 years ago. Updated about 7 years ago.

Status:
New
Priority:
Normal
Assignee:
-
Category:
-
Target version:
-
Difficulty:
Triaged:
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

Actions #1

Updated by Greg Sutcliffe almost 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

Actions #2

Updated by Daniel Lobato Garcia almost 8 years ago

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

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

Actions #4

Updated by Greg Koch almost 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.

Actions #5

Updated by Daniel Lobato Garcia almost 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

Actions #6

Updated by The Foreman Bot over 7 years ago

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

Updated by Anonymous about 7 years ago

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

Updated by Anonymous about 7 years ago

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

Also available in: Atom PDF