Skip to content

Commit b8ac63a

Browse files
committed
Add driver version support for Node Labeller
Change-Id: I0b94e9d90c427bcc70cf827a758e3dafa8debbe2
1 parent e00c0b4 commit b8ac63a

File tree

2 files changed

+34
-0
lines changed

2 files changed

+34
-0
lines changed

cmd/k8s-node-labeller/README.md

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -21,6 +21,8 @@ The Labeller currently creates node label for the following AMD GPU properties:
2121

2222
* Device ID (-device-id)
2323
* Product Name (-product-name)
24+
* Driver Version (-driver-version)
25+
* Driver Source Version (-driveri-src-version)
2426
* VRAM Size (-vram)
2527
* Number of SIMD (-simd-count)
2628
* Number of Compute Unit (-cu-count)

cmd/k8s-node-labeller/main.go

Lines changed: 32 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -91,6 +91,38 @@ var labelGenerators = map[string]func(map[string]map[string]int) map[string]stri
9191
}
9292
return results
9393
},
94+
"driver-version": func(gpus map[string]map[string]int) map[string]string {
95+
version := ""
96+
for _, v := range gpus {
97+
versionPath := fmt.Sprintf("/sys/class/drm/card%d/device/driver/module/version", v["card"])
98+
b, err := ioutil.ReadFile(versionPath)
99+
if err != nil {
100+
log.Error(err, versionPath)
101+
continue
102+
}
103+
version = strings.TrimSpace(string(b))
104+
break
105+
}
106+
107+
pfx := createLabelPrefix("driver-version", true)
108+
return map[string]string{pfx: version}
109+
},
110+
"driver-src-version": func(gpus map[string]map[string]int) map[string]string {
111+
version := ""
112+
for _, v := range gpus {
113+
versionPath := fmt.Sprintf("/sys/class/drm/card%d/device/driver/module/srcversion", v["card"])
114+
b, err := ioutil.ReadFile(versionPath)
115+
if err != nil {
116+
log.Error(err, versionPath)
117+
continue
118+
}
119+
version = strings.TrimSpace(string(b))
120+
break
121+
}
122+
123+
pfx := createLabelPrefix("driver-src-version", true)
124+
return map[string]string{pfx: version}
125+
},
94126
"device-id": func(gpus map[string]map[string]int) map[string]string {
95127
counts := map[string]int{}
96128

0 commit comments

Comments
 (0)