summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorTim Smith <tsmith@chef.io>2017-04-27 20:36:34 -0700
committerTim Smith <tsmith@chef.io>2017-04-27 20:39:19 -0700
commit79f0626b6723dfca04299350fd389470efcf6873 (patch)
tree1e6467ddb85fda9b057baae9bbb39dff5a00ff53
parentc2dbf95d9dd1c16755accb8bbec775edcd5b29fc (diff)
downloadohai-79f0626b6723dfca04299350fd389470efcf6873.tar.gz
Add additional debug logging to the metadata mixinreuse_metadata_connections
Signed-off-by: Tim Smith <tsmith@chef.io>
-rw-r--r--lib/ohai/mixin/ec2_metadata.rb5
1 files changed, 4 insertions, 1 deletions
diff --git a/lib/ohai/mixin/ec2_metadata.rb b/lib/ohai/mixin/ec2_metadata.rb
index 1932623b..886191fe 100644
--- a/lib/ohai/mixin/ec2_metadata.rb
+++ b/lib/ohai/mixin/ec2_metadata.rb
@@ -49,6 +49,7 @@ module Ohai
def best_api_version
@api_version ||= begin
+ Ohai::Log.debug("ec2 metadata mixin: Fetching http://#{EC2_METADATA_ADDR}/ to determine the latest supported metadata release")
response = http_client.get("/")
if response.code == "404"
Ohai::Log.debug("ec2 metadata mixin: Received HTTP 404 from metadata server while determining API version, assuming 'latest'")
@@ -63,7 +64,7 @@ module Ohai
pv = versions.pop
Ohai::Log.debug("ec2 metadata mixin: EC2 lists metadata version: #{pv} not yet supported by Ohai") unless pv == "latest"
end
- Ohai::Log.debug("ec2 metadata mixin: EC2 metadata version: #{versions.last}")
+ Ohai::Log.debug("ec2 metadata mixin: Latest supported EC2 metadata version: #{versions.last}")
if versions.empty?
raise "Unable to determine EC2 metadata version (no supported entries found)"
end
@@ -87,6 +88,7 @@ module Ohai
# `nil` and continue the run instead of failing it.
def metadata_get(id, api_version)
path = "/#{api_version}/meta-data/#{id}"
+ Ohai::Log.debug("ec2 metadata mixin: Fetching http://#{EC2_METADATA_ADDR}#{path}")
response = http_client.get(path)
case response.code
when "200"
@@ -167,6 +169,7 @@ module Ohai
end
def fetch_userdata
+ Ohai::Log.debug("ec2 metadata mixin: Fetching http://#{EC2_METADATA_ADDR}/#{best_api_version}/user-data/")
response = http_client.get("/#{best_api_version}/user-data/")
response.code == "200" ? response.body : nil
end