node-feature-discovery icon indicating copy to clipboard operation
node-feature-discovery copied to clipboard

apis/nfd: add matchName field in feature matcher terms

Open marquiz opened this issue 3 years ago • 7 comments

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"]}

marquiz avatar Mar 17 '22 16:03 marquiz

[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

Needs approval from an approver in each of these files:

Approvers can indicate their approval by writing /approve in a comment Approvers can cancel approval by writing /approve cancel in a comment

k8s-ci-robot avatar Mar 17 '22 16:03 k8s-ci-robot

Still a POC/RFC, missing e.g. documentation /hold

marquiz avatar Mar 17 '22 16:03 marquiz

still a hold?

ArangoGutierrez avatar Aug 23 '22 14:08 ArangoGutierrez

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.

marquiz avatar Aug 24 '22 04:08 marquiz

/retest

marquiz avatar Aug 30 '22 19:08 marquiz

Rebased

marquiz avatar Oct 07 '22 12:10 marquiz

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...

QR Code

Use your smartphone camera to open QR code link.

To edit notification comments on pull requests, go to your Netlify site configuration.

netlify[bot] avatar Oct 07 '22 12:10 netlify[bot]

@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.

k8s-ci-robot avatar Oct 24 '22 18:10 k8s-ci-robot

Rebased. Still RFC/POC

marquiz avatar Dec 20 '22 09:12 marquiz

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/stale is applied
  • After 30d of inactivity since lifecycle/stale was applied, lifecycle/rotten is applied
  • After 30d of inactivity since lifecycle/rotten was 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

k8s-triage-robot avatar Mar 20 '23 10:03 k8s-triage-robot

Still relevant /remove-lifecycle stale

marquiz avatar Mar 20 '23 12:03 marquiz

Still POC @marquiz ?

ArangoGutierrez avatar Oct 30 '23 10:10 ArangoGutierrez

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...

marquiz avatar Oct 30 '23 12:10 marquiz

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

marquiz avatar Nov 03 '23 08:11 marquiz

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

marquiz avatar Dec 12 '23 16:12 marquiz

/assign @ArangoGutierrez

marquiz avatar Dec 12 '23 16:12 marquiz

Ach, docs is missing 🙈 (plus unit tests fail) /hold

marquiz avatar Dec 12 '23 16:12 marquiz

Rebased. Added documentation. /unhold

marquiz avatar Dec 12 '23 17:12 marquiz

/retest

ArangoGutierrez avatar Dec 14 '23 17:12 ArangoGutierrez

/needs-rebase

ArangoGutierrez avatar Dec 14 '23 17:12 ArangoGutierrez

LGTM label has been added.

Git tree hash: 4714b3d1701ce3b7624f3ff116fc7e8d584dcaea

k8s-ci-robot avatar Dec 15 '23 11:12 k8s-ci-robot

[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

Needs approval from an approver in each of these files:
  • ~~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

k8s-ci-robot avatar Dec 15 '23 11:12 k8s-ci-robot

/hold

marquiz avatar Dec 15 '23 11:12 marquiz

Codecov Report

Merging #788 (49886ed) into master (443ff80) will decrease coverage by 0.07%. The diff coverage is 34.25%.

Additional details and impacted files

Impacted file tree graph

@@            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:

codecov[bot] avatar Dec 15 '23 11:12 codecov[bot]

Too slow 😿

marquiz avatar Dec 15 '23 11:12 marquiz

OK, see #1504

marquiz avatar Dec 15 '23 11:12 marquiz