[PATCH/facter 1/1] Discussion on ec2 facts - #2346

101 views
Skip to first unread message

Paul Nasrat

unread,
Jun 28, 2009, 6:22:28 AM6/28/09
to puppe...@googlegroups.com
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 <pna...@googlemail.com>
---
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

--
1.6.1.3

Luke Kanies

unread,
Jun 28, 2009, 9:40:58 AM6/28/09
to puppe...@googlegroups.com
+1
--
I love deadlines. I like the whooshing sound they make as they fly by.
--Douglas Adams
---------------------------------------------------------------------
Luke Kanies | http://reductivelabs.com | http://madstop.com

Paul Nasrat

unread,
Jun 28, 2009, 5:42:41 PM6/28/09
to puppe...@googlegroups.com
2009/6/28 Luke Kanies <lu...@madstop.com>:
>
> +1

What's your feeling on the fact that having a timeout like this slows
everything down?

Paul

Luke Kanies

unread,
Jun 29, 2009, 3:30:54 PM6/29/09
to puppe...@googlegroups.com

The timeout always slows things down?

Sorry, I think I skipped too much.


--
In theory, there is no difference between theory and practice; in
practice, there is. -- Chuck Reid

Reply all
Reply to author
Forward
0 new messages