Skip to content

Commit 1e102d7

Browse files
committed
Get container id prefix
Signed-off-by: ghokun <[email protected]>
1 parent 195f823 commit 1e102d7

File tree

2 files changed

+4
-3
lines changed

2 files changed

+4
-3
lines changed

manifests/device-plugin.yml

+1-1
Original file line numberDiff line numberDiff line change
@@ -45,7 +45,7 @@ spec:
4545
capabilities:
4646
add: ["SYS_ADMIN"]
4747
containers:
48-
- image: ghcr.io/kuartis/kuartis-virtual-gpu-device-plugin:0.4.6
48+
- image: ghcr.io/kuartis/kuartis-virtual-gpu-device-plugin:0.4.7
4949
name: kuartis-virtual-gpu-device-plugin-ctr
5050
command:
5151
- /usr/bin/virtual-gpu-device-plugin

pkg/gpu/nvidia/metrics.go

+3-2
Original file line numberDiff line numberDiff line change
@@ -77,13 +77,14 @@ func collectMetrics(w http.ResponseWriter, r *http.Request) {
7777
log.Printf("Found %d containers", len(containers.Containers))
7878
containerMap := make(map[string]containerInfo)
7979
for _, container := range containers.GetContainers() {
80+
log.Printf("Found container %s", container.GetId())
8081
containerMap[container.Id] = containerInfo{
8182
Node: node,
8283
Namespace: container.Labels["io.kubernetes.pod.namespace"],
8384
Pod: container.Labels["io.kubernetes.pod.name"],
8485
PodUid: container.Labels["io.kubernetes.pod.uid"],
8586
Container: container.Metadata.Name,
86-
ContainerId: container.Id,
87+
ContainerId: container.GetId(),
8788
}
8889
}
8990
collected := []metric{}
@@ -95,7 +96,7 @@ func collectMetrics(w http.ResponseWriter, r *http.Request) {
9596
log.Printf("Found %d processes on GPU %d", len(processes), i)
9697
for _, process := range processes {
9798
containerId := getContainerId(process.Pid)
98-
container := containerMap[containerId]
99+
container := containerMap[containerId[:13]]
99100
collected = append(collected, metric{
100101
Pid: process.Pid,
101102
UsedGpuMemory: process.UsedGpuMemory,

0 commit comments

Comments
 (0)