-
Notifications
You must be signed in to change notification settings - Fork 1.4k
lib/promscrape/discovery/gce: add support for ipv6 in metadata labels #9370
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
lib/promscrape/discovery/gce: add support for ipv6 in metadata labels #9370
Conversation
if len(iface.Ipv6AccessConfigs) > 0 { | ||
ac := iface.Ipv6AccessConfigs[0] | ||
if ac.Type == "DIRECT_IPV6" { | ||
m.Add("__meta_gce_ipv6", ac.ExternalIpv6) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Should it be added as __meta_gce_public_ipv6
?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I guess it's a matter of taste. Looking at the other service discovery they seem to handle it all different. Eg:
__meta_digitalocean_public_ipv6
__meta_ec2_ipv6_addresses
__meta_hetzner_public_ipv6_network
__meta_ovhcloud_vps_ipv6
__meta_ovhcloud_dedicated_server_ipv6
__meta_vultr_instance_main_ipv6
In the case of GCE it can only have a native IPv6 range attached to it or a ULA address so there's won't ever be a conflict (unless Google break their APIs). That said, I have no strong opinions on this and would be fine with something like __meta_gce_public_ipv6
and __meta_gce_private_ipv6
if the project prefers it.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The only thing, that concerns me is possible label duplicate. If ULA
is defined and iface.Ipv6Address != ""
is not empty, multiple values for the __meta_gce_ipv6
label will be added.
There is already a case for GCE ipv4
address - __meta_gce_public_ip
. And I wonder, should be follow this naming pattern for nat related IPs?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
According to the google API docs https://cloud.google.com/compute/docs/reference/rest/beta/instances/addNetworkInterface:
ipv6Address - An IPv6 internal network address for this network interface. To use a static internal IP address, it must be unused and in the same region as the instance's zone. If not specified, Google Cloud will automatically assign an internal IPv6 address from the instance's subnetwork.
ipv6AccessConfigs[].externalIpv6 - Applies to ipv6AccessConfigs only. The first IPv6 address of the external IPv6 range associated with this instance, prefix length is stored in externalIpv6PrefixLength in ipv6AccessConfig. To use a static external IP address, it must be unused and in the same region as the instance's zone. If not specified, Google Cloud will automatically assign an external IPv6 address from the instance's subnetwork.
So I changed metadata labels according to it. Feel free to add your input.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I apologize for the radio silence, I've been away and I continue to be away from a computer for another couple of weeks. Thank you for taking care of this, the changes lgtm.
Signed-off-by: f41gh7 <nik@victoriametrics.com>
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM
Codecov Report❌ Patch coverage is
Additional details and impacted files@@ Coverage Diff @@
## master #9370 +/- ##
==========================================
- Coverage 60.37% 54.86% -5.52%
==========================================
Files 411 526 +115
Lines 76609 81926 +5317
==========================================
- Hits 46253 44947 -1306
- Misses 27794 34611 +6817
+ Partials 2562 2368 -194 ☔ View full report in Codecov by Sentry. 🚀 New features to boost your workflow:
|
Thanks for contribution! |
This change will expose any IPv6 addresses assigned to an instance under the meta labels: * `__meta_gce_public_ipv6` -native IPv6 address, globally routed * `__meta_gce_internal_ipv6` - unique local address (ULA). Fixes #9370
The feature was included into v1.123.0 release |
Describe Your Changes
Hi! Long time user, first time contributor. 👋
This change will expose any IPv6 address assigned to an instance under the meta label
__meta_gce_ipv6
. In GCE an instance can either have a native IPv6 address or an unique local address (ULA) but not both. I have not updated the tests because it's unfortunately outside of my ability (I'm not a programmer nor very familiar with golang). I've compiled and run vmagent against my own GCP project where I have instances without IPv6, with native IPv6 and with ULA IPv6 running. See result below (I've masked and replaced identifying information)Checklist
The following checks are mandatory: