Skip to content

Commit ec4ff6e

Browse files
authored
fix bug: display with multiple devices (#34)
1 parent b7fd975 commit ec4ff6e

File tree

1 file changed

+11
-1
lines changed

1 file changed

+11
-1
lines changed

cmd/inspect/display.go

Lines changed: 11 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,7 @@ import (
99

1010
log "github.com/golang/glog"
1111
"k8s.io/api/core/v1"
12+
"k8s.io/apimachinery/pkg/types"
1213
)
1314

1415
func displayDetails(nodeInfos []*NodeInfo) {
@@ -55,24 +56,33 @@ func displayDetails(nodeInfos []*NodeInfo) {
5556
fmt.Fprintf(w, buf.String())
5657

5758
var buffer bytes.Buffer
59+
exists := map[types.UID]bool{}
5860
for i, dev := range nodeInfo.devs {
5961
usedGPUMemInNode += dev.usedGPUMem
6062
for _, pod := range dev.pods {
61-
63+
if _,ok := exists[pod.UID]; ok {
64+
continue
65+
}
6266
buffer.WriteString(fmt.Sprintf("%s\t%s\t", pod.Name, pod.Namespace))
6367
count := nodeInfo.gpuCount
6468
if nodeInfo.hasPendingGPUMemory() {
6569
count += 1
6670
}
6771

6872
for k := 0; k < count; k++ {
73+
allocation := GetAllocation(&pod)
74+
if len(allocation) != 0 {
75+
buffer.WriteString(fmt.Sprintf("%d\t", allocation[k]))
76+
continue
77+
}
6978
if k == i || (i == -1 && k == nodeInfo.gpuCount) {
7079
buffer.WriteString(fmt.Sprintf("%d\t", getGPUMemoryInPod(pod)))
7180
} else {
7281
buffer.WriteString("0\t")
7382
}
7483
}
7584
buffer.WriteString("\n")
85+
exists[pod.UID] = true
7686
}
7787
}
7888
if prtLineLen == 0 {

0 commit comments

Comments
 (0)