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

Export zone locality in outbound destination metrics #13129

Merged
merged 1 commit into from
Oct 15, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
19 changes: 14 additions & 5 deletions controller/api/destination/endpoint_translator.go
Original file line number Diff line number Diff line change
Expand Up @@ -444,6 +444,7 @@ func (et *endpointTranslator) sendClientAdd(set watcher.AddressSet) {
Addr: addr,
Weight: defaultWeight,
AuthorityOverride: authOverride,
MetricLabels: map[string]string{},
}

if address.Identity != "" {
Expand All @@ -465,12 +466,20 @@ func (et *endpointTranslator) sendClientAdd(set watcher.AddressSet) {
}
}

if et.extEndpointZoneWeights {
// EXPERIMENTAL: Use the endpoint weight field to indicate zonal
// preference so that local endoints are more heavily weighted.
if et.nodeTopologyZone != "" && address.Zone != nil && *address.Zone == et.nodeTopologyZone {
wa.Weight *= 10
if et.nodeTopologyZone != "" && address.Zone != nil {
if *address.Zone == et.nodeTopologyZone {
wa.MetricLabels["zone_locality"] = "local"

if et.extEndpointZoneWeights {
// EXPERIMENTAL: Use the endpoint weight field to indicate zonal
// preference so that local endoints are more heavily weighted.
wa.Weight *= 10
}
} else {
wa.MetricLabels["zone_locality"] = "remote"
}
} else {
wa.MetricLabels["zone_locality"] = "unknown"
}

addrs = append(addrs, wa)
Expand Down
2 changes: 2 additions & 0 deletions controller/api/destination/endpoint_translator_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -485,6 +485,7 @@ func TestEndpointTranslatorForPods(t *testing.T) {
"serviceaccount": "serviceaccount-name",
"control_plane_ns": "linkerd",
"zone": "",
"zone_locality": "unknown",
}
if diff := deep.Equal(actualAddedAddress1MetricLabels, expectedAddedAddress1MetricLabels); diff != nil {
t.Fatalf("Expected global metric labels sent to be [%v] but was [%v]", expectedAddedAddress1MetricLabels, actualAddedAddress1MetricLabels)
Expand Down Expand Up @@ -658,6 +659,7 @@ func TestEndpointTranslatorExternalWorkloads(t *testing.T) {
expectedAddedAddress1MetricLabels := map[string]string{
"external_workload": "ew-1",
"zone": "",
"zone_locality": "unknown",
"workloadgroup": "wg-name",
}
if diff := deep.Equal(actualAddedAddress1MetricLabels, expectedAddedAddress1MetricLabels); diff != nil {
Expand Down
Loading