From 1982d0581c6da98d270f0e56cdac2ce6b8dd5815 Mon Sep 17 00:00:00 2001 From: Vincent Whitchurch Date: Wed, 8 Jan 2025 16:00:40 +0100 Subject: [PATCH 1/2] service discovery: Add missing cgroup mount Add a missing cgroup mount to system-probe which is required to get container information. --- .../datadogagent/feature/servicediscovery/feature.go | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/internal/controller/datadogagent/feature/servicediscovery/feature.go b/internal/controller/datadogagent/feature/servicediscovery/feature.go index 55f4d95af..08ed6669b 100644 --- a/internal/controller/datadogagent/feature/servicediscovery/feature.go +++ b/internal/controller/datadogagent/feature/servicediscovery/feature.go @@ -71,6 +71,11 @@ func (f *serviceDiscoveryFeature) ManageNodeAgent(managers feature.PodTemplateMa managers.VolumeMount().AddVolumeMountToContainer(&procdirMount, apicommon.SystemProbeContainerName) managers.Volume().AddVolume(&procdirVol) + // Needed to resolve container information + cgroupsVol, cgroupsMount := volume.GetVolumes(v2alpha1.CgroupsVolumeName, v2alpha1.CgroupsHostPath, v2alpha1.CgroupsMountPath, true) + managers.VolumeMount().AddVolumeMountToContainer(&cgroupsMount, apicommon.SystemProbeContainerName) + managers.Volume().AddVolume(&cgroupsVol) + socketVol, socketVolMount := volume.GetVolumesEmptyDir(v2alpha1.SystemProbeSocketVolumeName, v2alpha1.SystemProbeSocketVolumePath, false) managers.Volume().AddVolume(&socketVol) managers.VolumeMount().AddVolumeMountToContainer(&socketVolMount, apicommon.SystemProbeContainerName) From 4b8e87e84e43cf54a0d9fb033231621e9bdc0afe Mon Sep 17 00:00:00 2001 From: Vincent Whitchurch Date: Wed, 8 Jan 2025 16:42:07 +0100 Subject: [PATCH 2/2] Update test --- .../feature/servicediscovery/feature_test.go | 13 +++++++++++++ 1 file changed, 13 insertions(+) diff --git a/internal/controller/datadogagent/feature/servicediscovery/feature_test.go b/internal/controller/datadogagent/feature/servicediscovery/feature_test.go index 177f5438b..544314fd8 100644 --- a/internal/controller/datadogagent/feature/servicediscovery/feature_test.go +++ b/internal/controller/datadogagent/feature/servicediscovery/feature_test.go @@ -63,6 +63,11 @@ func Test_serviceDiscoveryFeature_Configure(t *testing.T) { MountPath: v2alpha1.ProcdirMountPath, ReadOnly: true, }, + { + Name: v2alpha1.CgroupsVolumeName, + MountPath: v2alpha1.CgroupsMountPath, + ReadOnly: true, + }, { Name: v2alpha1.SystemProbeSocketVolumeName, MountPath: v2alpha1.SystemProbeSocketVolumePath, @@ -86,6 +91,14 @@ func Test_serviceDiscoveryFeature_Configure(t *testing.T) { }, }, }, + { + Name: v2alpha1.CgroupsVolumeName, + VolumeSource: corev1.VolumeSource{ + HostPath: &corev1.HostPathVolumeSource{ + Path: v2alpha1.CgroupsHostPath, + }, + }, + }, { Name: v2alpha1.SystemProbeSocketVolumeName, VolumeSource: corev1.VolumeSource{