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

fix: fetch GCP metadata from 169.254.169.254 directly #293

Merged
merged 2 commits into from
May 24, 2024
Merged

Conversation

nettrino
Copy link
Contributor

@nettrino nettrino commented May 24, 2024

Issue

Fixes #292

@nettrino nettrino requested a review from viega as a code owner May 24, 2024 12:43
@nettrino nettrino requested review from miki725 and ee7 May 24, 2024 12:45
ee7
ee7 previously approved these changes May 24, 2024
Copy link
Contributor

@ee7 ee7 left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM. We already used 169.254.169.254 for AWS and Azure:

awsBaseUri = "http://169.254.169.254/latest/"

let resultOpt = hitProviderEndpoint("http://169.254.169.254/metadata/instance?api-version=2021-02-01", newHttpHeaders([("Metadata", "true")]))

We should probably define 169.254.169.254 as a const in this file and use that everywhere, but I don't mind leaving that till later.

@nettrino
Copy link
Contributor Author

We should probably define 169.254.169.254 as a const in this file and use that everywhere, but I don't mind leaving that till later.

Agreed - not sure though if there are lists of IPs that differ slightly per provider? this plugin could be split / refactored in the future so left it as such for now as I treated it as a nit as well

@ee7
Copy link
Contributor

ee7 commented May 24, 2024

not sure though if there are lists of IPs that differ slightly per provider

For this particular case, I think we'd be pretty safe even if we added more cloud providers. My understanding is that 169.254.0.0/16 is reserved for link-local addressing, and it's pretty standard for the instance metadata service to be available via 169.254.169.254. At least also for:

@thc202
Copy link

thc202 commented May 24, 2024

Alibaba Cloud uses a different address: https://www.alibabacloud.com/help/en/ecs/user-guide/view-instance-metadata (not arguing against or for, just providing an example).

@ee7
Copy link
Contributor

ee7 commented May 24, 2024

Cool, thanks.

Yeah, I've got no context for Alibaba Cloud. Looks like it's different for Tencent Cloud too.

@ee7 ee7 changed the title fix: change GCP metadata to be fetched from 169.254.169.254 directly fix: fetch GCP metadata from 169.254.169.254 directly May 24, 2024
@ee7
Copy link
Contributor

ee7 commented May 24, 2024

I suggest merging with the edited shorter PR title - commit title would be longer than 72 chars otherwise, which overflows e.g. GitHub's commit view.

@ee7 ee7 merged commit df36709 into main May 24, 2024
4 checks passed
@ee7 ee7 deleted the fix-gcp-metadata-ip branch May 24, 2024 18:32
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

Successfully merging this pull request may close these issues.

Change metadata ip for GOOGLE to use IP
4 participants