diff --git a/config/deployments/nfd/node-feature-rules-gpu.yaml b/config/deployments/nfd/node-feature-rules-gpu.yaml index f33361f..c83129a 100644 --- a/config/deployments/nfd/node-feature-rules-gpu.yaml +++ b/config/deployments/nfd/node-feature-rules-gpu.yaml @@ -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" @@ -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" diff --git a/internal/controller/misc_controller_test.go b/internal/controller/misc_controller_test.go index e0cf549..4145f64 100644 --- a/internal/controller/misc_controller_test.go +++ b/internal/controller/misc_controller_test.go @@ -116,15 +116,21 @@ 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) @@ -132,14 +138,29 @@ var _ = Describe("Misc", func() { } } + 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) @@ -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) }) })