prometheus/discovery/moby
Anas Khan ad59b2f542 discovery/moby: guard nil ContainerSpec for non-container swarm services
Docker Swarm service discovery dereferenced
s.Spec.TaskTemplate.ContainerSpec unconditionally when building the
per-service labels. In the moby SDK, TaskSpec.ContainerSpec is an
optional pointer that is mutually exclusive with PluginSpec and
NetworkAttachmentSpec: it is nil when a service's task runtime is
"plugin" or "attachment". ServiceList returns those services with no
runtime filtering, so a nil ContainerSpec reached the label map and
panicked, aborting the whole services refresh.

Set the container hostname and image labels only when ContainerSpec is
non-nil, mirroring the existing guard in refreshTasks. Add a regression
test with a plugin service (nil ContainerSpec) alongside a normal one.

Signed-off-by: Anas Khan <83116240+anxkhn@users.noreply.github.com>
2026-07-05 10:27:27 +05:30
..
testdata discovery/moby: guard nil ContainerSpec for non-container swarm services 2026-07-05 10:27:27 +05:30
docker.go update deprecated calls 2026-04-02 15:54:32 -07:00
docker_test.go Remove copyright date from headers (#17785) 2026-01-05 13:46:21 +01:00
dockerswarm.go update deprecated calls 2026-04-02 15:54:32 -07:00
metrics_docker.go Remove copyright date from headers (#17785) 2026-01-05 13:46:21 +01:00
metrics_dockerswarm.go Remove copyright date from headers (#17785) 2026-01-05 13:46:21 +01:00
mock_test.go Remove copyright date from headers (#17785) 2026-01-05 13:46:21 +01:00
network.go chore: remove dependency on github.com/docker/docker 2026-04-02 15:11:24 -07:00
nodes.go chore: remove dependency on github.com/docker/docker 2026-04-02 15:11:24 -07:00
nodes_test.go Remove copyright date from headers (#17785) 2026-01-05 13:46:21 +01:00
services.go discovery/moby: guard nil ContainerSpec for non-container swarm services 2026-07-05 10:27:27 +05:30
services_test.go discovery/moby: guard nil ContainerSpec for non-container swarm services 2026-07-05 10:27:27 +05:30
tasks.go chore: remove dependency on github.com/docker/docker 2026-04-02 15:11:24 -07:00
tasks_test.go Remove copyright date from headers (#17785) 2026-01-05 13:46:21 +01:00