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

Allow setting metadata environment variable GCE_METADATA_HOST alone #1505

Open
salrashid123 opened this issue Mar 25, 2024 · 1 comment
Open

Comments

@salrashid123
Copy link
Contributor

salrashid123 commented Mar 25, 2024

If users want to set a custom metadata server endpoint, you have to use both

GCE_METADATA_IP and GCE_METADATA_HOST.

The IP based env var is used here to ping the address of the server.

Using GCE_METADATA_IP seems to be unique to google-auth-python while other gcp sdk libraries allows you to override with just GCE_METADATA_HOST.

The usecase is if anyone wants to run a custom endpoint or local metadata emulator you'd have to know this specific environment variable just for python.


The suggestion is if a user set GCE_METADATA_HOST, just use whats there.

For backwards compatibility, if the user sets both GCE_METADATA_HOST and GCE_METADATA_IP, the behavior is the same as now.

i think one simplistic way to get to that is to alter _metadata.py as such

if os.getenv(environment_vars.GCE_METADATA_HOST, None) is not None and os.getenv(environment_vars.GCE_METADATA_IP,None) is None:
    _METADATA_IP_ROOT = "http://{}".format(_GCE_METADATA_HOST)
else:
    _METADATA_IP_ROOT = "http://{}".format(
        os.getenv(environment_vars.GCE_METADATA_IP, "169.254.169.254")
    )
@salrashid123
Copy link
Contributor Author

also noted here tensorflow/tensorflow#60235 (comment)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant