Skip to content

Commit

Permalink
Fix gce
Browse files Browse the repository at this point in the history
Starting from version 4.7.1, Facter is unable to read Gce metadata like below.
[2024-06-12 04:58:49.787568 ] DEBUG Facter::Util::Resolvers::Http - Trying to connect to http://metadata.google.internal/computeMetadata/v1/?recursive=true&alt=json but got: undefined method `[]' for false:FalseClass

This is because get_request is getting 4 parameters.
This commit set timeouts = {}, to avoid timeouts = false.
  • Loading branch information
jiwonaid committed Jun 13, 2024
1 parent 3e47ee6 commit 3973aaa
Show file tree
Hide file tree
Showing 2 changed files with 2 additions and 2 deletions.
2 changes: 1 addition & 1 deletion lib/facter/resolvers/gce.rb
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ def read_facts(fact_name)
end

def query_for_metadata
gce_data = extract_to_hash(Facter::Util::Resolvers::Http.get_request(METADATA_URL, HEADERS, false))
gce_data = extract_to_hash(Facter::Util::Resolvers::Http.get_request(METADATA_URL, HEADERS, {}, false))
parse_instance(gce_data)

gce_data.empty? ? nil : gce_data
Expand Down
2 changes: 1 addition & 1 deletion spec/facter/resolvers/gce_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@

before do
allow(Facter::Util::Resolvers::Http).to receive(:get_request)
.with(gce_metadata_url, gce_url_headers, false)
.with(gce_metadata_url, gce_url_headers, {}, false)
.and_return(http_response_body)
end

Expand Down

0 comments on commit 3973aaa

Please sign in to comment.