File tree Expand file tree Collapse file tree 1 file changed +10
-9
lines changed
google/auth/compute_engine Expand file tree Collapse file tree 1 file changed +10
-9
lines changed Original file line number Diff line number Diff line change 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 ()
You can’t perform that action at this time.
0 commit comments