Skip to content
This repository was archived by the owner on Mar 6, 2026. It is now read-only.

fix: add retry to google.auth.compute_engine._metadata.get() - #398

Merged
busunkim96 merged 1 commit into
googleapis:masterfrom
DaniilAnichin:feature/211-add-retry-on-metadata-get
Jan 9, 2020
Merged

fix: add retry to google.auth.compute_engine._metadata.get()#398
busunkim96 merged 1 commit into
googleapis:masterfrom
DaniilAnichin:feature/211-add-retry-on-metadata-get

Conversation

@DaniilAnichin

Copy link
Copy Markdown
Contributor

Initial fix of issue #211 was done in CL #323, but only for .ping()
This one is adding same behavior & tests for .get() method, as the problem still arises

Resolves: #211

@googlebotgooglebot added the cla: yes This human has signed the Contributor License Agreement. label Dec 5, 2019
@DaniilAnichin
DaniilAnichinforce-pushed the feature/211-add-retry-on-metadata-get branch 2 times, most recently from e0c2dbd to 917df1aCompareDecember 5, 2019 15:55
@DaniilAnichin

Copy link
Copy Markdown
ContributorAuthor

@dhermes can you take a look to finally make the #211 fixed?

@dhermes

Copy link
Copy Markdown
Contributor

cc @busunkim96

@DaniilAnichin I am no longer maintaining this library. Cheers

@DaniilAnichin
DaniilAnichinforce-pushed the feature/211-add-retry-on-metadata-get branch from 917df1a to 1226931CompareDecember 19, 2019 14:35
@DaniilAnichin
DaniilAnichinforce-pushed the feature/211-add-retry-on-metadata-get branch from 1226931 to 2f75de9CompareDecember 26, 2019 15:42
@lucasmbrown

Copy link
Copy Markdown

I can't tell who the maintainers currently are, but @theacodes or @busunkim96, would you be available to review this? It's caused us a few headaches so far (right now we're wrapping all our gets in our own retry logic). Thanks!

@busunkim96

Copy link
Copy Markdown
Contributor

@lucasmbrown Thank you for the ping! I missed this PR. I'll take a look now.

@busunkim96busunkim96 added the kokoro:run Add this label to force Kokoro to re-run the tests. label Jan 8, 2020
@busunkim96
busunkim96 self-requested a review January 8, 2020 19:24
@yoshi-kokoroyoshi-kokoro removed the kokoro:run Add this label to force Kokoro to re-run the tests. label Jan 8, 2020

@busunkim96busunkim96 left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It looks like there's a mismatch between the actual retry count (5) and the count in the test (3). Otherwise this looks good to me. Thank you for the PR!

=================================== FAILURES ===================================
______________________ test_get_failure_connection_failed ______________________
def test_get_failure_connection_failed():
request = make_request("")
request.side_effect = exceptions.TransportError()
with pytest.raises(exceptions.TransportError) as excinfo:
_metadata.get(request, PATH)
assert excinfo.match(r"Compute Engine Metadata server unavailable")
request.assert_called_with(
method="GET",
url=_metadata._METADATA_ROOT + PATH,
headers=_metadata._METADATA_HEADERS,
)
> assert request.call_count == 3
E AssertionError: assert 5 == 3
E + where 5 = <MagicMock spec='Request' id='140641503619536'>.call_count
tests/compute_engine/test__metadata.py:207: AssertionError

Comment threadsetup.py Outdated
…mpute_engine._metadata.get()
Initial fix of issue googleapis#211 was done in CL googleapis#323, but only for .ping()
This one is adding same behaviour & tests for .get() method, as the problem still occurres
See the issue for details
Refs: googleapis#323Resolves: googleapis#211
@DaniilAnichin

Copy link
Copy Markdown
ContributorAuthor

Updated call count in tests; ping me if I need to rebase to current master

@DaniilAnichin
DaniilAnichinforce-pushed the feature/211-add-retry-on-metadata-get branch from 2f75de9 to 3a1187fCompareJanuary 9, 2020 13:52
@busunkim96busunkim96 added the kokoro:run Add this label to force Kokoro to re-run the tests. label Jan 9, 2020
@yoshi-kokoroyoshi-kokoro removed the kokoro:run Add this label to force Kokoro to re-run the tests. label Jan 9, 2020
Sign up for freeto subscribe to this conversation on GitHub. Already have an account? Sign in.

Labels

cla: yesThis human has signed the Contributor License Agreement.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Intermittent DefaultCredentialsError on GCE

6 participants

@DaniilAnichin@dhermes@lucasmbrown@busunkim96@googlebot@yoshi-kokoro