Skip to content

Commit

Permalink
fix: issue #1441
Browse files Browse the repository at this point in the history
Simplifying thoubleshooting by capturing last seen exception
to set is as the direct cause of the `exceptions.TransportError`
  • Loading branch information
gchux committed Dec 21, 2023
1 parent 776d634 commit ab79c26
Showing 1 changed file with 3 additions and 1 deletion.
4 changes: 3 additions & 1 deletion google/auth/compute_engine/_metadata.py
Original file line number Diff line number Diff line change
Expand Up @@ -199,6 +199,7 @@ def get(
url = _helpers.update_query(base_url, query_params)

retries = 0
last_exception = None
while retries < retry_count:
try:
response = request(url=url, method="GET", headers=headers_to_use)
Expand All @@ -213,11 +214,12 @@ def get(
e,
)
retries += 1
last_exception = e
else:
raise exceptions.TransportError(
"Failed to retrieve {} from the Google Compute Engine "
"metadata service. Compute Engine Metadata server unavailable".format(url)
)
) from last_exception

content = _helpers.from_bytes(response.data)

Expand Down

0 comments on commit ab79c26

Please sign in to comment.