Skip to content

Commit 1c2a4e5

Browse files
committed
chore: reformat to match structure in googleapis#1481
1 parent 037c367 commit 1c2a4e5

File tree

1 file changed

+10
-9
lines changed

1 file changed

+10
-9
lines changed

google/auth/compute_engine/_metadata.py

Lines changed: 10 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -60,12 +60,7 @@
6060

6161
# The number of tries to perform when waiting for the GCE metadata server
6262
# when detecting the GCE environment.
63-
try:
64-
_METADATA_DETECT_RETRIES = int(
65-
os.getenv(environment_vars.GCE_METADATA_DETECT_RETRIES, "3")
66-
)
67-
except ValueError: # pragma: NO COVER
68-
_METADATA_DETECT_RETRIES = 3
63+
_METADATA_DETECT_RETRIES = 3
6964

7065
# Detect GCE Residency
7166
_GOOGLE = "Google"
@@ -109,9 +104,7 @@ def detect_gce_residency_linux():
109104
return content.startswith(_GOOGLE)
110105

111106

112-
def ping(
113-
request, timeout=_METADATA_DEFAULT_TIMEOUT, retry_count=_METADATA_DETECT_RETRIES
114-
):
107+
def ping(request, timeout=_METADATA_DEFAULT_TIMEOUT, retry_count=None):
115108
"""Checks to see if the metadata server is available.
116109
117110
Args:
@@ -130,6 +123,14 @@ def ping(
130123
# could lead to false negatives in the event that we are on GCE, but
131124
# the metadata resolution was particularly slow. The latter case is
132125
# "unlikely".
126+
if retry_count is None:
127+
retry_count = int(
128+
os.getenv(
129+
environment_vars.GCE_METADATA_DETECT_RETRIES,
130+
_METADATA_DETECT_RETRIES,
131+
)
132+
)
133+
133134
retries = 0
134135
headers = _METADATA_HEADERS.copy()
135136
headers[metrics.API_CLIENT_HEADER] = metrics.mds_ping()

0 commit comments

Comments
 (0)