[Pkg-puppet-devel] [facter] 105/180: (FACT-481) Infinite loop when EC2 metadata server times out
Stig Sandbeck Mathisen
ssm at debian.org
Mon Jun 30 15:06:36 UTC 2014
This is an automated email from the git hooks/post-receive script.
ssm pushed a commit to branch master
in repository facter.
commit 397806e73f5212a4cebc141896c307bbadf151b3
Author: Dominic Cleal <dcleal at redhat.com>
Date: Thu May 8 11:58:00 2014 +0100
(FACT-481) Infinite loop when EC2 metadata server times out
The retry loop for contacting the EC2 metadata server failed to increment the
attempt counter on each iteration, as the 'ensure' block only executes once
the entire begin/rescue block has been completed, not on each retry.
---
lib/facter/ec2/rest.rb | 5 +++--
spec/unit/ec2/rest_spec.rb | 5 +++++
2 files changed, 8 insertions(+), 2 deletions(-)
diff --git a/lib/facter/ec2/rest.rb b/lib/facter/ec2/rest.rb
index e9c1fca..9fa2cc7 100644
--- a/lib/facter/ec2/rest.rb
+++ b/lib/facter/ec2/rest.rb
@@ -28,14 +28,15 @@ module Facter
if e.message.match /404 Not Found/i
able_to_connect = false
else
+ attempts = attempts + 1
retry if attempts < retry_limit
end
rescue Timeout::Error
+ attempts = attempts + 1
retry if attempts < retry_limit
rescue *CONNECTION_ERRORS
- retry if attempts < retry_limit
- ensure
attempts = attempts + 1
+ retry if attempts < retry_limit
end
able_to_connect
diff --git a/spec/unit/ec2/rest_spec.rb b/spec/unit/ec2/rest_spec.rb
index 5c74b49..1e64cd5 100644
--- a/spec/unit/ec2/rest_spec.rb
+++ b/spec/unit/ec2/rest_spec.rb
@@ -18,6 +18,11 @@ shared_examples_for "an ec2 rest querier" do
subject.expects(:open).with(anything).once.raises(OpenURI::HTTPError.new("404 Not Found", StringIO.new("woo")))
expect(subject).to_not be_reachable
end
+
+ it "is false if the connection always times out" do
+ Timeout.expects(:timeout).with(0.2).times(3).raises(Timeout::Error)
+ expect(subject).to_not be_reachable
+ end
end
end
--
Alioth's /usr/local/bin/git-commit-notice on /srv/git.debian.org/git/pkg-puppet/facter.git
More information about the Pkg-puppet-devel
mailing list