fix(metrics): keep k8s workload names when DNS resolves a destination late - #339
Merged
Merged
Conversation
… late WithResolvedDomain replaced both destination workload names with the FQDN, even when a side had already resolved to a k8s workload. That produced labels like name="rabbitmq.rabbit.svc.cluster.local", kind="StatefulSet", which the service map reports as a second copy of the StatefulSet. Apply the same isKubernetesResolved guard that NewDestinationKey got in #298. Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com>
There was a problem hiding this comment.
Code Review
This pull request updates the WithResolvedDomain method in common/net.go to ensure that already resolved Kubernetes workloads keep their own names instead of being overwritten by the FQDN. It also adds corresponding unit tests in common/net_workload_identity_test.go to verify this behavior. There are no review comments, and we have no feedback to provide.
mayankpande88
approved these changes
Sep 18, 2026
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
What this PR does
DestinationKey.WithResolvedDomainnow leaves a side's name alone if that side already resolved to a k8s workload. Only unresolved orexternalsides get the FQDN.This is the path that runs when the DNS cache fills after a connection was keyed. It replaced both workload names with the FQDN without checking. A connection whose ClusterIP hadn't resolved yet but whose pod had came out as:
The service map then shows that as a second, phantom StatefulSet next to the real
rabbitmq. #298 fixed the same problem inNewDestinationKey. This PR applies the sameisKubernetesResolvedcheck to the second path it missed.Linked issue / context
Part of nudgebee/nudgebee-enterprise#35231 (phantom KG workloads). That issue has two causes:
services-servershowing up asservices: fixed in the service-map builder, fix(runner): keep full destination names in the service map k8s-agent#620, not here.How was this tested?
TestWithResolvedDomain_ResolvedWorkloadKeepsItsNamefails onmain(getsrabbitmq.rabbit.svc.cluster.local, expectsrabbitmq) and passes with the fix.TestWithResolvedDomain_ExternalTakesFQDNchecks that external destinations still get the FQDN.golang:1.25(Linux):go vetandgo testpass for./common/and./containers/, including a run with-race.count({actual_destination_workload_name=~".*[.]svc[.]cluster[.]local", actual_destination_workload_kind!="external"}).It already returns 0 on dev-gke with v0.1.7. This path only triggers when the pod IP counts as "external" (outside RFC1918 and 100.64/10), which is common for Service ClusterIPs on GKE. So this closes a gap that can still happen, not a flood currently on dev.
Notes
enrichDestinationKey,migrateConnectionKeyIfNeeded) check only the destination name before calling in. The actual side got overwritten no matter what kind it was.-racerun of./common/flaggedTestEphemeralWorkloadAggregation. It passed 10/10 in isolation on both this branch andmain, and a full-package-racererun was clean. That test doesn't touchDestinationKey. It looks like a flaky test sharing global state, and CI doesn't run with-race.[Unreleased]isn't kept per fix in this repo.eBPF changes?
No.
Checklist
go testpasses (./common/,./containers/on Linux)🤖 Generated with Claude Code