Skip to content

Commit 119e2a3

Browse files
authored
Merge pull request #788 from marquiz/devel/wildcard-rule-ng
apis/nfd: add matchName field in feature matcher terms
2 parents 443ff80 + 49886ed commit 119e2a3

25 files changed

+901
-66
lines changed

deployment/base/nfd-crds/cr-sample.yaml

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -94,6 +94,13 @@ spec:
9494
vendor: {op: In, value: ["8086"]}
9595
class: {op: In, value: ["02"]}
9696

97+
- name: "avx wildcard rule"
98+
labels:
99+
"my-avx-feature": "true"
100+
matchFeatures:
101+
- feature: cpu.cpuid
102+
matchName: {op: InRegexp, value: ["^AVX512"]}
103+
97104
# The following features demonstreate label templating capabilities
98105
- name: "my system template feature"
99106
labelsTemplate: |
@@ -143,3 +150,11 @@ spec:
143150
matchExpressions:
144151
my.kernel.feature: {op: IsTrue}
145152
my.dummy.var: {op: Gt, value: ["0"]}
153+
154+
- name: "kconfig template rule"
155+
labelsTemplate: |
156+
{{ range .kernel.config }}kconfig-{{ .Name }}={{ .Value }}
157+
{{ end }}
158+
matchFeatures:
159+
- feature: kernel.config
160+
matchName: {op: In, value: ["SWAP", "X86", "ARM"]}

deployment/base/nfd-crds/nfd-api-crds.yaml

Lines changed: 76 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -190,6 +190,8 @@ spec:
190190
in the feature set.
191191
properties:
192192
feature:
193+
description: Feature is the name of the feature
194+
set to match against.
193195
type: string
194196
matchExpressions:
195197
additionalProperties:
@@ -229,13 +231,46 @@ spec:
229231
required:
230232
- op
231233
type: object
232-
description: MatchExpressionSet contains a set of
233-
MatchExpressions, each of which is evaluated against
234-
a set of input values.
234+
description: MatchExpressions is the set of per-element
235+
expressions evaluated. These match against the
236+
value of the specified elements.
237+
type: object
238+
matchName:
239+
description: MatchName in an expression that is
240+
matched against the name of each element in the
241+
feature set.
242+
properties:
243+
op:
244+
description: Op is the operator to be applied.
245+
enum:
246+
- In
247+
- NotIn
248+
- InRegexp
249+
- Exists
250+
- DoesNotExist
251+
- Gt
252+
- Lt
253+
- GtLt
254+
- IsTrue
255+
- IsFalse
256+
type: string
257+
value:
258+
description: Value is the list of values that
259+
the operand evaluates the input against. Value
260+
should be empty if the operator is Exists,
261+
DoesNotExist, IsTrue or IsFalse. Value should
262+
contain exactly one element if the operator
263+
is Gt or Lt and exactly two elements if the
264+
operator is GtLt. In other cases Value should
265+
contain at least one element.
266+
items:
267+
type: string
268+
type: array
269+
required:
270+
- op
235271
type: object
236272
required:
237273
- feature
238-
- matchExpressions
239274
type: object
240275
type: array
241276
required:
@@ -251,6 +286,8 @@ spec:
251286
are evaluated against each element in the feature set.
252287
properties:
253288
feature:
289+
description: Feature is the name of the feature set to
290+
match against.
254291
type: string
255292
matchExpressions:
256293
additionalProperties:
@@ -288,12 +325,44 @@ spec:
288325
required:
289326
- op
290327
type: object
291-
description: MatchExpressionSet contains a set of MatchExpressions,
292-
each of which is evaluated against a set of input values.
328+
description: MatchExpressions is the set of per-element
329+
expressions evaluated. These match against the value
330+
of the specified elements.
331+
type: object
332+
matchName:
333+
description: MatchName in an expression that is matched
334+
against the name of each element in the feature set.
335+
properties:
336+
op:
337+
description: Op is the operator to be applied.
338+
enum:
339+
- In
340+
- NotIn
341+
- InRegexp
342+
- Exists
343+
- DoesNotExist
344+
- Gt
345+
- Lt
346+
- GtLt
347+
- IsTrue
348+
- IsFalse
349+
type: string
350+
value:
351+
description: Value is the list of values that the
352+
operand evaluates the input against. Value should
353+
be empty if the operator is Exists, DoesNotExist,
354+
IsTrue or IsFalse. Value should contain exactly
355+
one element if the operator is Gt or Lt and exactly
356+
two elements if the operator is GtLt. In other cases
357+
Value should contain at least one element.
358+
items:
359+
type: string
360+
type: array
361+
required:
362+
- op
293363
type: object
294364
required:
295365
- feature
296-
- matchExpressions
297366
type: object
298367
type: array
299368
name:

deployment/components/worker-config/nfd-worker.conf.example

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -174,6 +174,13 @@
174174
# vendor: {op: In, value: ["8086"]}
175175
# class: {op: In, value: ["02"]}
176176
#
177+
# - name: "avx wildcard rule"
178+
# labels:
179+
# "my-avx-feature": "true"
180+
# matchFeatures:
181+
# - feature: cpu.cpuid
182+
# matchName: {op: InRegexp, value: ["^AVX512"]}
183+
#
177184
# # The following features demonstreate label templating capabilities
178185
# - name: "my template rule"
179186
# labelsTemplate: |
@@ -224,3 +231,10 @@
224231
# vendor.io/my.kernel.feature: {op: IsTrue}
225232
# my.dummy.var: {op: Gt, value: ["0"]}
226233
#
234+
# - name: "kconfig template rule"
235+
# labelsTemplate: |
236+
# {{ range .kernel.config }}kconfig-{{ .Name }}={{ .Value }}
237+
# {{ end }}
238+
# matchFeatures:
239+
# - feature: kernel.config
240+
# matchName: {op: In, value: ["SWAP", "X86", "ARM"]}

deployment/helm/node-feature-discovery/crds/nfd-api-crds.yaml

Lines changed: 76 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -190,6 +190,8 @@ spec:
190190
in the feature set.
191191
properties:
192192
feature:
193+
description: Feature is the name of the feature
194+
set to match against.
193195
type: string
194196
matchExpressions:
195197
additionalProperties:
@@ -229,13 +231,46 @@ spec:
229231
required:
230232
- op
231233
type: object
232-
description: MatchExpressionSet contains a set of
233-
MatchExpressions, each of which is evaluated against
234-
a set of input values.
234+
description: MatchExpressions is the set of per-element
235+
expressions evaluated. These match against the
236+
value of the specified elements.
237+
type: object
238+
matchName:
239+
description: MatchName in an expression that is
240+
matched against the name of each element in the
241+
feature set.
242+
properties:
243+
op:
244+
description: Op is the operator to be applied.
245+
enum:
246+
- In
247+
- NotIn
248+
- InRegexp
249+
- Exists
250+
- DoesNotExist
251+
- Gt
252+
- Lt
253+
- GtLt
254+
- IsTrue
255+
- IsFalse
256+
type: string
257+
value:
258+
description: Value is the list of values that
259+
the operand evaluates the input against. Value
260+
should be empty if the operator is Exists,
261+
DoesNotExist, IsTrue or IsFalse. Value should
262+
contain exactly one element if the operator
263+
is Gt or Lt and exactly two elements if the
264+
operator is GtLt. In other cases Value should
265+
contain at least one element.
266+
items:
267+
type: string
268+
type: array
269+
required:
270+
- op
235271
type: object
236272
required:
237273
- feature
238-
- matchExpressions
239274
type: object
240275
type: array
241276
required:
@@ -251,6 +286,8 @@ spec:
251286
are evaluated against each element in the feature set.
252287
properties:
253288
feature:
289+
description: Feature is the name of the feature set to
290+
match against.
254291
type: string
255292
matchExpressions:
256293
additionalProperties:
@@ -288,12 +325,44 @@ spec:
288325
required:
289326
- op
290327
type: object
291-
description: MatchExpressionSet contains a set of MatchExpressions,
292-
each of which is evaluated against a set of input values.
328+
description: MatchExpressions is the set of per-element
329+
expressions evaluated. These match against the value
330+
of the specified elements.
331+
type: object
332+
matchName:
333+
description: MatchName in an expression that is matched
334+
against the name of each element in the feature set.
335+
properties:
336+
op:
337+
description: Op is the operator to be applied.
338+
enum:
339+
- In
340+
- NotIn
341+
- InRegexp
342+
- Exists
343+
- DoesNotExist
344+
- Gt
345+
- Lt
346+
- GtLt
347+
- IsTrue
348+
- IsFalse
349+
type: string
350+
value:
351+
description: Value is the list of values that the
352+
operand evaluates the input against. Value should
353+
be empty if the operator is Exists, DoesNotExist,
354+
IsTrue or IsFalse. Value should contain exactly
355+
one element if the operator is Gt or Lt and exactly
356+
two elements if the operator is GtLt. In other cases
357+
Value should contain at least one element.
358+
items:
359+
type: string
360+
type: array
361+
required:
362+
- op
293363
type: object
294364
required:
295365
- feature
296-
- matchExpressions
297366
type: object
298367
type: array
299368
name:

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

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -312,6 +312,13 @@ worker:
312312
# vendor: {op: In, value: ["8086"]}
313313
# class: {op: In, value: ["02"]}
314314
#
315+
# - name: "avx wildcard rule"
316+
# labels:
317+
# "my-avx-feature": "true"
318+
# matchFeatures:
319+
# - feature: cpu.cpuid
320+
# matchName: {op: InRegexp, value: ["^AVX512"]}
321+
#
315322
# # The following features demonstreate label templating capabilities
316323
# - name: "my template rule"
317324
# labelsTemplate: |
@@ -362,6 +369,13 @@ worker:
362369
# vendor.io/my.kernel.feature: {op: IsTrue}
363370
# my.dummy.var: {op: Gt, value: ["0"]}
364371
#
372+
# - name: "kconfig template rule"
373+
# labelsTemplate: |
374+
# {{ range .kernel.config }}kconfig-{{ .Name }}={{ .Value }}
375+
# {{ end }}
376+
# matchFeatures:
377+
# - feature: kernel.config
378+
# matchName: {op: In, value: ["SWAP", "X86", "ARM"]}
365379
### <NFD-WORKER-CONF-END-DO-NOT-REMOVE>
366380

367381
metricsPort: 8081

0 commit comments

Comments
 (0)