Skip to content
Merged
Show file tree
Hide file tree
Changes from 3 commits
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
5 changes: 5 additions & 0 deletions internal/containers/graph/builder.go
Original file line number Diff line number Diff line change
Expand Up @@ -44,6 +44,11 @@ type ContainerInfo struct {
ImageName string
ImageTag string
Labels map[string]string

// Human-readable identifiers (container-specific only, not K8s Pod data)
ContainerName string // Container name (not pod name)
WorkloadName string // Derived: workload name with hash stripped

// Resource limits
CPUShares *int32
CPUQuotaUs *int32
Expand Down
7 changes: 7 additions & 0 deletions internal/containers/graph/nodes.go
Original file line number Diff line number Diff line change
Expand Up @@ -39,6 +39,13 @@ func (b *Builder) createContainerNode(container *ContainerInfo) (*resourcev1.Res
// Timestamps would be set if we had them
// CreatedAt: container.CreatedAt,
// StartedAt: container.StartedAt,

// Human-readable identifiers (container-specific only)
// Pod-level fields available via Pod resources and Container→Pod relationships
ContainerName: container.ContainerName,
WorkloadName: container.WorkloadName,

// Resource limits
CpuShares: container.CPUShares,
CpuQuotaUs: container.CPUQuotaUs,
CpuPeriodUs: container.CPUPeriodUs,
Expand Down
48 changes: 48 additions & 0 deletions internal/containers/manager.go
Original file line number Diff line number Diff line change
Expand Up @@ -188,6 +188,33 @@ func (s *RuntimeSnapshot) GetContainers() []containergraph.ContainerInfo {
CgroupPath: container.CgroupPath,
}

// Extract additional metadata (image, labels, resource limits, human names)
// Use empty hostRoot since container paths are already absolute
if metadata, err := pkgcontainers.ExtractMetadata(&container, ""); err == nil {
// Image information
containerInfo.ImageName = metadata.ImageName
containerInfo.ImageTag = metadata.ImageTag

// Human-readable identifiers (container-specific only)
// Note: Pod-level fields (pod name, namespace, app) are available via
// Pod resources and Container→Pod relationships to avoid duplication
containerInfo.ContainerName = metadata.ContainerName
containerInfo.WorkloadName = metadata.WorkloadName

// Labels (full map includes all K8s/Docker metadata)
containerInfo.Labels = metadata.Labels

// Resource limits
containerInfo.CPUShares = metadata.CPUShares
containerInfo.CPUQuotaUs = metadata.CPUQuotaUs
containerInfo.CPUPeriodUs = metadata.CPUPeriodUs
containerInfo.MemoryLimitBytes = metadata.MemoryLimitBytes
containerInfo.CpusetCpus = metadata.CpusetCpus
containerInfo.CpusetMems = metadata.CpusetMems
}
// Note: Metadata extraction errors are silently ignored to allow
// container discovery to succeed even if metadata files are unavailable

containerInfos[i] = containerInfo
}

Expand Down Expand Up @@ -229,6 +256,27 @@ func (m *Manager) collectRuntimeSnapshot(ctx context.Context) (*RuntimeSnapshot,

m.logger.V(1).Info("Discovered containers", "count", len(allContainers))

// Log extracted metadata for demonstration (first 3 containers)
for i, container := range allContainers {
if i >= 3 {
break
}
if metadata, err := pkgcontainers.ExtractMetadata(&container, ""); err == nil {
m.logger.Info("Container metadata sample",
"id", container.ID[:min(12, len(container.ID))],
"runtime", container.Runtime,
// Container-specific human names
"container_name", metadata.ContainerName,
"workload_name", metadata.WorkloadName,
// Image info
"image", metadata.ImageName,
"tag", metadata.ImageTag,
// Resource limits
"has_cpu_limit", metadata.CPUQuotaUs != nil,
"has_memory_limit", metadata.MemoryLimitBytes != nil)
}
}

// For now, we'll use an empty process snapshot
// TODO: Integrate with performance manager when process collection is available
processSnapshot := &performance.ProcessSnapshot{
Expand Down
30 changes: 27 additions & 3 deletions pkg/api/antimetal/runtime/v1/linux.pb.go

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Loading
Loading