|
| 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