diff --git a/comp/core/workloadmeta/collectors/internal/kubelet/kubelet.go b/comp/core/workloadmeta/collectors/internal/kubelet/kubelet.go index 25440989430f9..dc52d42c6ba94 100644 --- a/comp/core/workloadmeta/collectors/internal/kubelet/kubelet.go +++ b/comp/core/workloadmeta/collectors/internal/kubelet/kubelet.go @@ -246,6 +246,7 @@ func parsePodContainers( if containerSpec != nil { env = extractEnvFromSpec(containerSpec.Env) resources = extractResources(containerSpec) + podContainer.Resources = resources podContainer.Image, err = workloadmeta.NewContainerImage(imageID, containerSpec.Image) if err != nil { diff --git a/comp/core/workloadmeta/collectors/internal/kubelet/kubelet_test.go b/comp/core/workloadmeta/collectors/internal/kubelet/kubelet_test.go index a8a1ba1bdda20..716f850058c76 100644 --- a/comp/core/workloadmeta/collectors/internal/kubelet/kubelet_test.go +++ b/comp/core/workloadmeta/collectors/internal/kubelet/kubelet_test.go @@ -16,6 +16,7 @@ import ( "github.com/DataDog/datadog-agent/pkg/util/kubernetes" "github.com/DataDog/datadog-agent/pkg/util/kubernetes/kubelet" + "github.com/DataDog/datadog-agent/pkg/util/pointer" workloadmeta "github.com/DataDog/datadog-agent/comp/core/workloadmeta/def" ) @@ -61,6 +62,7 @@ func TestPodParser(t *testing.T) { "nvidia.com/gpu": resource.Quantity{ Format: "1", }, + "cpu": resource.MustParse("100m"), }, }, }, @@ -113,6 +115,7 @@ func TestPodParser(t *testing.T) { Runtime: "docker", Resources: workloadmeta.ContainerResources{ GPUVendorList: []string{"nvidia"}, + CPURequest: pointer.Ptr(10.0), }, Owner: &workloadmeta.EntityID{ Kind: "kubernetes_pod", @@ -158,6 +161,10 @@ func TestPodParser(t *testing.T) { Tag: "1.25.2", RawName: "nginx:1.25.2", }, + Resources: workloadmeta.ContainerResources{ + GPUVendorList: []string{"nvidia"}, + CPURequest: pointer.Ptr(10.0), + }, }, }, InitContainers: []workloadmeta.OrchestratorContainer{}, diff --git a/comp/core/workloadmeta/def/types.go b/comp/core/workloadmeta/def/types.go index 47315eca9db06..b022fcd1e59be 100644 --- a/comp/core/workloadmeta/def/types.go +++ b/comp/core/workloadmeta/def/types.go @@ -469,14 +469,21 @@ func (c ContainerAllocatedResource) String() string { // OrchestratorContainer is a reference to a Container with // orchestrator-specific data attached to it. type OrchestratorContainer struct { - ID string - Name string - Image ContainerImage + ID string + Name string + Image ContainerImage + Resources ContainerResources } // String returns a string representation of OrchestratorContainer. func (o OrchestratorContainer) String(_ bool) string { - return fmt.Sprintln("Name:", o.Name, "ID:", o.ID) + var sb strings.Builder + _, _ = fmt.Fprintln(&sb, "Name:", o.Name) + _, _ = fmt.Fprintln(&sb, "ID:", o.ID) + _, _ = fmt.Fprintln(&sb, "Image:", o.Image) + _, _ = fmt.Fprintln(&sb, "----------- Resources -----------") + _, _ = fmt.Fprint(&sb, o.Resources.String(true)) + return sb.String() } // ECSContainer is a reference to a container running in ECS