Skip to content

Commit

Permalink
fix: Setting non-empty overrides simulates metadata server existence …
Browse files Browse the repository at this point in the history
…setting (#64)
  • Loading branch information
dazuma authored Feb 1, 2024
1 parent 5a1a000 commit f23e7c4
Show file tree
Hide file tree
Showing 3 changed files with 4 additions and 2 deletions.
2 changes: 1 addition & 1 deletion .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -49,7 +49,7 @@ jobs:
node-version: "16.x"
- name: Install tools
shell: bash
run: "gem install --no-document bundler toys && bundle install"
run: "gem install --no-document toys && bundle install"
- name: Test ${{ matrix.task }}
shell: bash
run: toys do ${{ matrix.task }} < /dev/null
3 changes: 2 additions & 1 deletion lib/google/cloud/env/compute_metadata.rb
Original file line number Diff line number Diff line change
Expand Up @@ -389,12 +389,12 @@ def lookup_response path,
retry_count: :default,
retry_timeout: :default
query = canonicalize_query query
raise MetadataServerNotResponding unless gce_check
if @overrides
@mutex.synchronize do
return lookup_override path, query if @overrides
end
end
raise MetadataServerNotResponding unless gce_check
retry_count = self.retry_count if retry_count == :default
retry_count += 1 if retry_count
retry_timeout = self.retry_timeout if retry_timeout == :default
Expand Down Expand Up @@ -845,6 +845,7 @@ def lookup_override path, query
@existence = :no
raise MetadataServerNotResponding
end
@existence = :confirmed
result = @overrides.lookup path, query: query
result ||= Response.new 404, "Not found", FLAVOR_HEADER
result
Expand Down
1 change: 1 addition & 0 deletions test/helper.rb
Original file line number Diff line number Diff line change
Expand Up @@ -16,4 +16,5 @@
require "minitest/autorun"
require "minitest/focus"
require "minitest/rg"
require "base64"
require "json"

0 comments on commit f23e7c4

Please sign in to comment.