Closed nvwls closed 1 year ago
The issue is that the top-level object never changes because of the trailing ?recursive=true
The calls will be:
/computeMetadata/v1/?recursive=true/
/computeMetadata/v1/?recursive=true/instance/
/computeMetadata/v1/?recursive=true/instance/instance/
and so on
diff --git lib/ohai/mixin/gce_metadata.rb lib/ohai/mixin/gce_metadata.rb
index 64b35f92..29725c3b 100644
--- lib/ohai/mixin/gce_metadata.rb
+++ lib/ohai/mixin/gce_metadata.rb
@@ -23,7 +23,7 @@ module Ohai
# Trailing dot to host is added to avoid DNS search path
GCE_METADATA_ADDR ||= "metadata.google.internal."
- GCE_METADATA_URL ||= "/computeMetadata/v1/?recursive=true"
+ GCE_METADATA_URL ||= "/computeMetadata/v1"
# fetch the meta content with a timeout and the required header
def http_get(uri)
@@ -36,7 +36,9 @@ module Ohai
end
def fetch_metadata(id = "")
- response = http_get("#{GCE_METADATA_URL}/#{id}")
+ url = "#{GCE_METADATA_URL}/#{id}"
+ url << "?recursive=true" if url.end_with?("/")
+ response = http_get(url)
return nil unless response.code == "200"
if json?(response.body)
Description
Running test-kitchen/dokken on GKE using chef 18.1.0 results in SystemStackError
Ohai Version
18.0.26
Platform Version
centos-7.9.2009 centos-stream-8 centos-stream-9
Ohai Output
chef-16.18.0 is fine. But chef-18.1.0 results in an SystemStackError.