Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
37 changes: 37 additions & 0 deletions config/deployments/nfd/node-feature-rules-gpu.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,34 @@ spec:
- feature: kernel.enabledmodule
matchExpressions:
xe: {op: Exists}
# Having a duplicate rule is ok. Worker will execute both and the label is generated
# if either rule matches.
- name: "intel.gpu.1200"
labels:
"intel.feature.node.kubernetes.io/gpu": "true"
matchFeatures:
- feature: pci.device
matchExpressions:
vendor: {op: In, value: ["8086"]}
class: {op: In, value: ["1200"]}
device: {op: In, value: ["674c", "674d", "674e", "674f", "6750"]}
matchAny:
- matchFeatures:
- feature: kernel.loadedmodule
matchExpressions:
i915: {op: Exists}
- matchFeatures:
- feature: kernel.enabledmodule
matchExpressions:
i915: {op: Exists}
- matchFeatures:
- feature: kernel.loadedmodule
matchExpressions:
xe: {op: Exists}
- matchFeatures:
- feature: kernel.enabledmodule
matchExpressions:
xe: {op: Exists}
- name: "intel.gpu.without-driver"
labels:
"intel.feature.node.kubernetes.io/gpu-pci": "true"
Expand All @@ -37,6 +65,15 @@ spec:
matchExpressions:
vendor: {op: In, value: ["8086"]}
class: {op: In, value: ["0300", "0380"]}
- name: "intel.gpu.without-driver.1200"
labels:
"intel.feature.node.kubernetes.io/gpu-pci": "true"
matchFeatures:
- feature: pci.device
matchExpressions:
vendor: {op: In, value: ["8086"]}
class: {op: In, value: ["1200"]}
device: {op: In, value: ["674c", "674d", "674e", "674f", "6750"]}
# Assumes there are only one model of GPU per node.
# source: https://dgpu-docs.intel.com/overview/supported-hardware/xe-driver-gpus.html
- name: "intel.gpu.pro.b50"
Expand Down
39 changes: 30 additions & 9 deletions internal/controller/misc_controller_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -116,30 +116,51 @@ func gpuNode() *core.Node {
}
}

const (
vendorString = "vendor"
classString = "class"
deviceString = "device"
)

var _ = Describe("Misc", func() {

Context("NFR creation", func() {
checkValues := func(matchSet *nfdcrd.MatchExpressionSet) {
for k, v := range *matchSet {
switch k {
case "vendor":
case vendorString:
Expect(v.Value).To(Equal(nfdcrd.MatchValue{"8086"}))
case "class":
case classString:
Expect(v.Value).To(Equal(nfdcrd.MatchValue{"0300", "0380"}))
default:
Fail("unexpected match expression key: " + k)
}
}
}

checkValues1200 := func(matchSet *nfdcrd.MatchExpressionSet) {
for k, v := range *matchSet {
switch k {
case vendorString:
Expect(v.Value).To(Equal(nfdcrd.MatchValue{"8086"}))
case classString:
Expect(v.Value).To(Equal(nfdcrd.MatchValue{"1200"}))
case deviceString:
Expect(v.Value).To(Equal(nfdcrd.MatchValue{"674c", "674d", "674e", "674f", "6750"}))
default:
Fail("unexpected match expression key: " + k)
}
}
}

checkValuesForB60 := func(rule nfdcrd.Rule) {
for k, v := range *rule.MatchFeatures[0].MatchExpressions {
switch k {
case "vendor":
case vendorString:
Expect(v.Value).To(Equal(nfdcrd.MatchValue{"8086"}))
case "class":
case classString:
Expect(v.Value).To(Equal(nfdcrd.MatchValue{"0300"}))
case "device":
case deviceString:
Expect(v.Value).To(Equal(nfdcrd.MatchValue{"e211"}))
default:
Fail("unexpected match expression key: " + k)
Expand All @@ -166,12 +187,12 @@ var _ = Describe("Misc", func() {
nfr := createNfdRule(spec, "")
Expect(nfr).NotTo(BeNil())

Expect(nfr.Spec.Rules).To(HaveLen(10))
rule := nfr.Spec.Rules[0]
Expect(nfr.Spec.Rules).To(HaveLen(12))

checkValues(rule.MatchFeatures[0].MatchExpressions)
checkValues(nfr.Spec.Rules[0].MatchFeatures[0].MatchExpressions)
checkValues1200(nfr.Spec.Rules[1].MatchFeatures[0].MatchExpressions)

b60Rule := nfr.Spec.Rules[3]
b60Rule := nfr.Spec.Rules[5]
checkValuesForB60(b60Rule)
})
})
Expand Down