@@ -96,20 +96,21 @@ func collectMetrics(w http.ResponseWriter, r *http.Request) {
96
96
log .Printf ("Found %d processes on GPU %d" , len (processes ), i )
97
97
for _ , process := range processes {
98
98
containerId := getContainerId (process .Pid )
99
- container := containerMap [containerId ]
100
- log .Printf ("Using %s Found container %+v for process: %d" , containerId , container , process .Pid )
101
- collected = append (collected , metric {
102
- Pid : process .Pid ,
103
- UsedGpuMemory : process .UsedGpuMemory ,
104
- GpuIndex : i ,
105
- GpuUUID : getDeviceUUID (d ),
106
- Node : container .Node ,
107
- Namespace : container .Namespace ,
108
- Pod : container .Pod ,
109
- PodUid : container .PodUid ,
110
- Container : container .Container ,
111
- ContainerId : container .ContainerId ,
112
- })
99
+ if container , ok := containerMap [strings .TrimSpace (containerId )]; ok {
100
+ log .Printf ("Using %s Found container %+v for process: %d" , containerId , container , process .Pid )
101
+ collected = append (collected , metric {
102
+ Pid : process .Pid ,
103
+ UsedGpuMemory : process .UsedGpuMemory ,
104
+ GpuIndex : i ,
105
+ GpuUUID : getDeviceUUID (d ),
106
+ Node : container .Node ,
107
+ Namespace : container .Namespace ,
108
+ Pod : container .Pod ,
109
+ PodUid : container .PodUid ,
110
+ Container : container .Container ,
111
+ ContainerId : container .ContainerId ,
112
+ })
113
+ }
113
114
}
114
115
}
115
116
0 commit comments