diff options
author | Paul Nasrat <pnas...@googlemail.com> | 2009-06-28 11:22:28 +0100 |
---|---|---|
committer | James Turnbull <james@lovedthanlost.net> | 2011-03-17 07:56:07 +1100 |
commit | 5b6f4fa4aae419bd2d65e1af6e185123dd432ac6 (patch) | |
tree | 5c4b203e085c91564eda919ed774395638901ff1 /lib | |
parent | d151bd6a4abb7a94131f1660395fae8222e20105 (diff) | |
download | facter-5b6f4fa4aae419bd2d65e1af6e185123dd432ac6.tar.gz facter-5b6f4fa4aae419bd2d65e1af6e185123dd432ac6.tar.xz facter-5b6f4fa4aae419bd2d65e1af6e185123dd432ac6.zip |
Discussion on ec2 facts - #2346
The EC2 fact is completely broken at the moment:
* Timeout::Error isn't caught by rescue (due to how it inherits)
* The issue of wrong open semantics outlined here, this is causing hidden immediate failure
* The fact is going to cause a 2 second wait to every facter run
Whilst the following patch fixes the first two, I'm not sure we want to take
the timeout hit, we also want to add tests as even simple ruby code can get
logic errors such as the open().
Signed-off-by: Paul Nasrat <pnas...@googlemail.com>
Diffstat (limited to 'lib')
-rw-r--r-- | lib/facter/ec2.rb | 7 |
1 files changed, 5 insertions, 2 deletions
diff --git a/lib/facter/ec2.rb b/lib/facter/ec2.rb index ef84757..ea29d14 100644 --- a/lib/facter/ec2.rb +++ b/lib/facter/ec2.rb @@ -6,9 +6,12 @@ require 'open-uri' require 'timeout' def can_connect?(ip,port,wait_sec=2) - Timeout::timeout(wait_sec) {open(ip, port)} + url = "http://#{ip}:#{port}/" + Timeout::timeout(wait_sec) {open(url)} return true -rescue +rescue Timeout::Error + return false +rescue return false end |