node-feature-discovery
node-feature-discovery copied to clipboard
apis/nfd: add matchName field in feature matcher terms
Extend the format of feature matcher terms (the elements specified under under matchFeatures) with new matchName field. This field contains an expression that is evaluated against the names of features (i.e. keys in the set of feature elements) instead of their values (which is accomplished with the matchExpressions field).
The matchName field is useful e.g. in template rules for creating per-feature-element labels based on feature names (instead of values) and in "normal" (non-template) rules for checking if (at least) one of certain feature element names are present.
If both matchExpressions and matchName for certain feature matcher term is specified, they both must match in order to get an overall match. Also, in this case the list of matched features (used in templating) is the union of the results from matchExpressions and matchName.
An example of creating an "avx512" label if any AVX512* CPUID feature is present:
- name: "avx wildcard rule"
labels:
avx512: "true"
matchFeatures:
- feature: cpu.cpuid
matchName: {op: InRegexp, value: ["^AVX512"]}
An example of a template rule creating a dynamic set of labels based on the existence of certain kconfig options.
- name: "kconfig template rule"
labelsTemplate: |
{{ range .kernel.config }}kconfig-{{ .Name }}={{ .Value }}
{{ end }}
matchFeatures:
- feature: kernel.config
matchName: {op: In, value: ["SWAP", "X86", "ARM"]}
[APPROVALNOTIFIER] This PR is APPROVED
This pull-request has been approved by: marquiz
The full list of commands accepted by this bot can be found here.
The pull request process is described here
- ~~OWNERS~~ [marquiz]
Approvers can indicate their approval by writing /approve in a comment
Approvers can cancel approval by writing /approve cancel in a comment
Still a POC/RFC, missing e.g. documentation /hold
still a hold?
still a hold?
Heh, I'm still a bit unsure do we need this, if anybody wants this 😄 OTOH, it would make it possible to turn all "built-in" labels into NodeFeatureRules 🧐
In addition, docs are still missing.
/retest
Rebased
Deploy Preview for kubernetes-sigs-nfd ready!
| Name | Link |
|---|---|
| Latest commit | 49886ed6358570478a39856516c5534742da431f |
| Latest deploy log | https://app.netlify.com/sites/kubernetes-sigs-nfd/deploys/657c1d4ea48f910008af4ab5 |
| Deploy Preview | https://deploy-preview-788--kubernetes-sigs-nfd.netlify.app |
| Preview on mobile | Toggle QR Code...Use your smartphone camera to open QR code link. |
To edit notification comments on pull requests, go to your Netlify site configuration.
@marquiz: PR needs rebase.
Instructions for interacting with me using PR comments are available here. If you have questions or suggestions related to my behavior, please file an issue against the kubernetes/test-infra repository.
Rebased. Still RFC/POC
The Kubernetes project currently lacks enough contributors to adequately respond to all PRs.
This bot triages PRs according to the following rules:
- After 90d of inactivity,
lifecycle/staleis applied - After 30d of inactivity since
lifecycle/stalewas applied,lifecycle/rottenis applied - After 30d of inactivity since
lifecycle/rottenwas applied, the PR is closed
You can:
- Mark this PR as fresh with
/remove-lifecycle stale - Close this PR with
/close - Offer to help out with Issue Triage
Please send feedback to sig-contributor-experience at kubernetes/community.
/lifecycle stale
Still relevant /remove-lifecycle stale
Still POC @marquiz ?
Still POC @marquiz ?
Yeah, I'm still a bit unsure about the naming, for example. I have one potential use case in mind but will keep this in hold for now...
I added a patch that adds sample NodeFeatureRules that correspond the built-in labels created by nfd-worker (with its default configuration).
These samples demonstrate how to utilize NodeFeatureRules. Maybe we could replace the whole nfd-worker side label generation with NodeFeatureRules at some point in the future...
ping @ArangoGutierrez
Update:
- rebased
- fixed a bug where the matchNames never failed
- added e2e tests
I think this would be ready for review, no reason to keep it hanging open forever. At least should not have any effect (cause problems) if not used 😉 /unhold
/assign @ArangoGutierrez
Ach, docs is missing 🙈 (plus unit tests fail) /hold
Rebased. Added documentation. /unhold
/retest
/needs-rebase
LGTM label has been added.
[APPROVALNOTIFIER] This PR is APPROVED
This pull-request has been approved by: ArangoGutierrez, marquiz
The full list of commands accepted by this bot can be found here.
The pull request process is described here
- ~~OWNERS~~ [ArangoGutierrez,marquiz]
Approvers can indicate their approval by writing /approve in a comment
Approvers can cancel approval by writing /approve cancel in a comment
/hold
Codecov Report
Merging #788 (49886ed) into master (443ff80) will decrease coverage by
0.07%. The diff coverage is34.25%.
Additional details and impacted files
@@ Coverage Diff @@
## master #788 +/- ##
==========================================
- Coverage 31.39% 31.33% -0.07%
==========================================
Files 59 59
Lines 7555 7647 +92
==========================================
+ Hits 2372 2396 +24
- Misses 4939 5001 +62
- Partials 244 250 +6
| Files | Coverage Δ | |
|---|---|---|
| pkg/apis/nfd/v1alpha1/zz_generated.deepcopy.go | 26.14% <57.89%> (+0.25%) |
:arrow_up: |
| pkg/apis/nfd/v1alpha1/rule.go | 78.12% <64.28%> (-2.95%) |
:arrow_down: |
| pkg/apis/nfd/v1alpha1/expression.go | 66.66% <13.11%> (-10.12%) |
:arrow_down: |
Too slow 😿
OK, see #1504