Skip to content

Commit 8d09a81

Browse files
committed
Skip Huawei labels when NFD patches a default namespace
Signed-off-by: taenzeyang <[email protected]>
1 parent 04a7b9d commit 8d09a81

File tree

3 files changed

+56
-1
lines changed

3 files changed

+56
-1
lines changed
Lines changed: 36 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,36 @@
1+
{{- if .Values.nodefeaturerules }}
2+
apiVersion: nfd.k8s-sigs.io/v1alpha1
3+
kind: NodeFeatureRule
4+
metadata:
5+
name: npu
6+
spec:
7+
rules:
8+
- name: "ascend/atlas-800t-a2-arm"
9+
labels:
10+
"node-role.kubernetes.io/worker": "worker"
11+
"workerselector": "dls-worker-node"
12+
"host-arch": "huawei-arm"
13+
"accelerator": "huawei-Ascend910"
14+
matchFeatures:
15+
- feature: pci.device
16+
matchExpressions:
17+
vendor: {op: In, value: ["19e5"]}
18+
device: {op: In, value: ["d802"]}
19+
- feature: kernel.config
20+
matchExpressions:
21+
X86: {op: In, value: ["n"]}
22+
- name: "ascend/atlas-800t-a2-x86"
23+
labels:
24+
"node-role.kubernetes.io/worker": "worker"
25+
"workerselector": "dls-worker-node"
26+
"host-arch": "huawei-x86"
27+
"accelerator": "huawei-Ascend910"
28+
matchFeatures:
29+
- feature: pci.device
30+
matchExpressions:
31+
vendor: {op: In, value: ["19e5"]}
32+
device: {op: In, value: ["d802"]}
33+
- feature: kernel.config
34+
matchExpressions:
35+
X86: {op: In, value: ["y"]}
36+
{{- end }}

deployment/helm/node-feature-discovery/values.yaml

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -511,3 +511,5 @@ tls:
511511
prometheus:
512512
enable: false
513513
labels: {}
514+
515+
nodefeaturerules: true

pkg/nfd-master/nfd-master.go

Lines changed: 18 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1278,12 +1278,29 @@ func (m *nfdMaster) configure(filepath string, overrides string) error {
12781278

12791279
// addNs adds a namespace if one isn't already found from src string
12801280
func addNs(src string, nsToAdd string) string {
1281-
if strings.Contains(src, "/") {
1281+
if strings.Contains(src, "/") || containsHW(src) {
12821282
return src
12831283
}
12841284
return path.Join(nsToAdd, src)
12851285
}
12861286

1287+
// containsHW returns true if the label contains Huawei's keys
1288+
func containsHW(src string) bool {
1289+
keys := []string{
1290+
"workerselector",
1291+
"host-arch",
1292+
"accelerator",
1293+
"accelerator-type",
1294+
"servertype",
1295+
}
1296+
for _, key := range keys {
1297+
if key == src {
1298+
return true
1299+
}
1300+
}
1301+
return false
1302+
}
1303+
12871304
// splitNs splits a name into its namespace and name parts
12881305
func splitNs(fullname string) (string, string) {
12891306
split := strings.SplitN(fullname, "/", 2)

0 commit comments

Comments
 (0)