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

discovery: update legacy name field when using container tags #31574

Merged
merged 2 commits into from
Nov 28, 2024
Merged
Show file tree
Hide file tree
Changes from 1 commit
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
4 changes: 4 additions & 0 deletions pkg/collector/corechecks/servicediscovery/impl_linux.go
Original file line number Diff line number Diff line change
Expand Up @@ -106,6 +106,8 @@ func (li *linuxImpl) DiscoverServices() (*discoveredServices, error) {
svc.service.CPUCores = service.CPUCores
svc.service.ContainerID = service.ContainerID
svc.service.GeneratedName = service.GeneratedName
svc.service.Name = service.Name
svc.meta.Name = service.Name
events.heartbeat = append(events.heartbeat, *svc)
}
}
Expand Down Expand Up @@ -143,6 +145,8 @@ func (li *linuxImpl) handlePotentialServices(events *serviceEvents, now time.Tim
svc.service.CPUCores = service.CPUCores
svc.service.ContainerID = service.ContainerID
svc.service.GeneratedName = service.GeneratedName
svc.service.Name = service.Name
svc.meta.Name = service.Name

li.aliveServices[pid] = svc
events.start = append(events.start, *svc)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -685,6 +685,10 @@ func (s *discovery) enrichContainerData(service *model.Service, containers map[s

if serviceName != "" {
service.GeneratedName = serviceName
// Update the legacy name field as well
if service.DDService == "" {
service.Name = serviceName
}
}
service.CheckedContainerData = true

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -840,6 +840,7 @@ func TestDocker(t *testing.T) {
require.Contains(t, portMap, pid1111)
require.Contains(t, portMap[pid1111].Ports, uint16(1234))
require.Contains(t, portMap[pid1111].ContainerID, "dummyCID")
require.Contains(t, portMap[pid1111].Name, "foo_from_app_tag")
require.Contains(t, portMap[pid1111].GeneratedName, "foo_from_app_tag")
}

Expand Down
Loading