Issue #4526 has been updated by Paul Nasrat.

Status changed from Accepted to Duplicate

Duplicate of Issue #2346 patch went to list as concerned over adding timeouts 
everywhere, we might want to do the search for 169.254.169.254 in the arp cache 
trick.
----------------------------------------
Bug #4526: ec2 facts: error with "cann_connect"
http://projects.puppetlabs.com/issues/4526

Author: Cedric Jeanneret
Status: Duplicate
Priority: High
Assigned to: 
Category: 
Target version: 1.5.8
Keywords: facter ec2
Branch: 


Hello,

we found a bug with the ec2.rb facts: it doesn't work at all.

The problem is in the "can_connect" function - it returns false every time.

Here's a quick patch which can be applied as is, we tested it on our AWS 
instances:

<pre>
diff -u ec2.rb.ori ec2.rb
--- ec2.rb.ori  2010-08-12 07:50:00.000000000 +0000
+++ ec2.rb      2010-08-12 07:50:53.000000000 +0000
@@ -5,14 +5,6 @@
 require 'open-uri'
 require 'timeout'
 
-def can_connect?(ip,port,wait_sec=2)
- Timeout::timeout(wait_sec) {open(ip, port)}
- return true
-rescue
-  return false
-end
-
-
 def metadata(id = "")
   open("http://169.254.169.254/2008-02-01/meta-data/#{id||=''}").read.
     split("\n").each do |o|
@@ -29,7 +21,8 @@
   end
 end
 
-if can_connect?("169.254.169.254","80")
-  metadata
+begin
+  Timeout::timeout(1) { metadata }
+rescue Timeout::Error
+  puts "ec2-metadata not loaded"
 end
-
</pre>

Related file is :
http://github.com/reductivelabs/facter/blob/master/lib/facter/ec2.rb

Thank you.

Best regards,

C.


-- 
You have received this notification because you have either subscribed to it, 
or are involved in it.
To change your notification preferences, please click here: 
http://projects.puppetlabs.com/my/account

-- 
You received this message because you are subscribed to the Google Groups 
"Puppet Bugs" group.
To post to this group, send email to [email protected].
To unsubscribe from this group, send email to 
[email protected].
For more options, visit this group at 
http://groups.google.com/group/puppet-bugs?hl=en.

Reply via email to