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

Commit fc440ca

Browse files
Review for PR #1481
1 parent 97bfea9 commit fc440ca

1 file changed

Lines changed: 46 additions & 0 deletions

File tree

Lines changed: 46 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,46 @@
1+
2+
<<<<<<< SEARCH
3+
# Timeout in seconds to wait for the GCE metadata server when detecting the
4+
# GCE environment.
5+
try:
6+
_METADATA_DEFAULT_TIMEOUT = int(os.getenv(environment_vars.GCE_METADATA_TIMEOUT, 3))
7+
except ValueError: # pragma: NO COVER
8+
_METADATA_DEFAULT_TIMEOUT = 3
9+
10+
# The number of tries to perform when waiting for the GCE metadata server
11+
=======
12+
# Timeout in seconds to wait for the GCE metadata server when detecting the
13+
# GCE environment.
14+
_METADATA_PING_DEFAULT_TIMEOUT = 3
15+
16+
# The number of tries to perform when waiting for the GCE metadata server
17+
>>>>>>> REPLACE
18+
<<<<<<< SEARCH
19+
# NOTE: The explicit ``timeout`` is a workaround. The underlying
20+
# issue is that resolving an unknown host on some networks will take
21+
# 20-30 seconds; making this timeout short fixes the issue, but
22+
# could lead to false negatives in the event that we are on GCE, but
23+
# the metadata resolution was particularly slow. The latter case is
24+
# "unlikely".
25+
headers = _METADATA_HEADERS.copy()
26+
headers[metrics.API_CLIENT_HEADER] = metrics.mds_ping()
27+
=======
28+
# NOTE: The explicit ``timeout`` is a workaround. The underlying
29+
# issue is that resolving an unknown host on some networks will take
30+
# 20-30 seconds; making this timeout short fixes the issue, but
31+
# could lead to false negatives in the event that we are on GCE, but
32+
# the metadata resolution was particularly slow. The latter case is
33+
# "unlikely".
34+
35+
if timeout is None:
36+
try:
37+
timeout = float(os.getenv(
38+
environment_vars.GCE_METADATA_TIMEOUT,
39+
str(_METADATA_PING_DEFAULT_TIMEOUT)))
40+
except ValueError:
41+
timeout = _METADATA_PING_DEFAULT_TIMEOUT
42+
43+
retries = 0
44+
headers = _METADATA_HEADERS.copy()
45+
headers[metrics.API_CLIENT_HEADER] = metrics.mds_ping()
46+
>>>>>>> REPLACE

0 commit comments

Comments
 (0)