Skip to content

Commit

Permalink
Store CPU/memory requests in wlm pod
Browse files Browse the repository at this point in the history
  • Loading branch information
jennchenn committed Dec 24, 2024
1 parent 272716f commit 1b59e27
Show file tree
Hide file tree
Showing 3 changed files with 19 additions and 4 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -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 {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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"
)
Expand Down Expand Up @@ -61,6 +62,7 @@ func TestPodParser(t *testing.T) {
"nvidia.com/gpu": resource.Quantity{
Format: "1",
},
"cpu": resource.MustParse("100m"),
},
},
},
Expand Down Expand Up @@ -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",
Expand Down Expand Up @@ -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{},
Expand Down
15 changes: 11 additions & 4 deletions comp/core/workloadmeta/def/types.go
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down

0 comments on commit 1b59e27

Please sign in to comment.