Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Make http://metadata.google.internal configurable #40317

Merged
merged 2 commits into from
Aug 7, 2020

Commits on Jun 9, 2020

  1. Make http://metadata.google.internal configurable

    The TPU client library has a hardcoded dependency on `http://metadata.google.internal`. We happen to need to redirect this URL to a different VM. Since the URL is hardcoded, we're forced to use a fragile code patch against our version of Tensorflow, which isn't ideal, or rely on `/etc/hosts` to forward `metadata.google.internal`, which causes unexpected global side effects to the user's VM. (For example, GCE uses `metadata.google.internal` to distribute SSH keys to GCE VMs, which breaks when we reroute `metadata.google.internal` using `/etc/hosts`.)
    
    oauth2client solves this by making `http://metadata.google.internal` configurable via the `GCE_METADATA_IP` environment variable. The final url becomes `'http://' + os.getenv('GCE_METADATA_IP', '169.254.169.254')`:
    
    https://github.com/googleapis/oauth2client/blob/50d20532a748f18e53f7d24ccbe6647132c979a9/oauth2client/client.py#L111
    
    Following oauth2client's lead, this PR makes `http://metadata.google.internal` configurable for Tensorflow users via `GCE_METADATA_IP`:
    
    ```py
    _GCE_METADATA_URL_ENV_VARIABLE = 'GCE_METADATA_IP'
    
    # ...
    
    def _gce_metadata_endpoint():
      return 'http://' + os.environ.get(
        _GCE_METADATA_URL_ENV_VARIABLE,
        'metadata.google.internal')
    ```
    
    `GCE_METADATA_IP` might seem like an awkward name. After all, `metadata.google.internal` is a URL, not an IP address. But it's probably best to match oauth2client's naming convention. That way users won't need to worry about setting two slightly-different variable names to configure both oauth2client and Tensorflow.
    shawwn committed Jun 9, 2020
    Configuration menu
    Copy the full SHA
    efe0812 View commit details
    Browse the repository at this point in the history

Commits on Aug 5, 2020

  1. Fix pylint errors

    shawwn committed Aug 5, 2020
    Configuration menu
    Copy the full SHA
    3b5dca4 View commit details
    Browse the repository at this point in the history