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

apis/nfd: allow different types of features of the same name

Open marquiz opened this issue 1 year ago β€’ 6 comments

This patch changes the handling of NodeFeatureRules so that one feature name (say "cpu.cpuid") can hold different types of features (flags, attributes and/or instances). Requiring features to choose one single type has not been a limitation of the API itself (and there has been no validation on this) but an implementation decision.

The new evalutation logic of match expressions is such that "flags" and "attributes" are basically evaluated as an union - they are both maps but "flags" just don't have any value associated with the key. However, "instances" are handled separately as that is basically an array of maps and needs to be evaluated in a different way (loop over the array of instances and evaluate expressions against the attributes of each). Because of this difference care must be taken if mixing "instance" features with "flag" and/or "attribute" features.

Note that the API types or their validation is not changed - just the implementation of how the NodeFeatureRules are evaluated.

marquiz avatar Apr 24 '24 11:04 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 Apr 24 '24 11:04 k8s-ci-robot

Deploy Preview for kubernetes-sigs-nfd ready!

Name Link
Latest commit bb565c094919352c7e05904ecc166abf2c07a34e
Latest deploy log https://app.netlify.com/sites/kubernetes-sigs-nfd/deploys/665069b10d12d50008674b32
Deploy Preview https://deploy-preview-1671--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 Apr 24 '24 11:04 netlify[bot]

Cherry-picked #1672 here to make this buildable

marquiz avatar Apr 24 '24 12:04 marquiz

Rebased. Test coverage increased.

/assign @ArangoGutierrez

marquiz avatar Apr 30 '24 13:04 marquiz

Codecov Report

Attention: Patch coverage is 84.95575% with 17 lines in your changes are missing coverage. Please review.

Project coverage is 40.37%. Comparing base (c2e3de6) to head (e32d43d).

:exclamation: Current head e32d43d differs from pull request most recent head c693f61. Consider uploading reports for the commit c693f61 to get more accurate results

Additional details and impacted files

Impacted file tree graph

@@            Coverage Diff             @@
##           master    #1671      +/-   ##
==========================================
+ Coverage   39.84%   40.37%   +0.52%     
==========================================
  Files          80       80              
  Lines        6841     6913      +72     
==========================================
+ Hits         2726     2791      +65     
- Misses       3861     3867       +6     
- Partials      254      255       +1     
Files Coverage Ξ”
pkg/apis/nfd/nodefeaturerule/rule.go 86.25% <100.00%> (+4.22%) :arrow_up:
source/source.go 38.33% <ΓΈ> (+1.82%) :arrow_up:
pkg/apis/nfd/nodefeaturerule/expression.go 80.79% <83.16%> (-0.91%) :arrow_down:

codecov[bot] avatar Apr 30 '24 14:04 codecov[bot]

ping @ArangoGutierrez

marquiz avatar May 13 '24 07:05 marquiz

LGTM label has been added.

Git tree hash: eb12b95fa18456c3695a076c8d713879209af1c4

k8s-ci-robot avatar May 24 '24 10:05 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 May 24 '24 10:05 k8s-ci-robot

Codecov Report

Attention: Patch coverage is 84.54545% with 17 lines in your changes are missing coverage. Please review.

Project coverage is 39.60%. Comparing base (c2e3de6) to head (bb565c0). Report is 39 commits behind head on master.

Additional details and impacted files

Impacted file tree graph

@@            Coverage Diff             @@
##           master    #1671      +/-   ##
==========================================
- Coverage   39.84%   39.60%   -0.25%     
==========================================
  Files          80       80              
  Lines        6841     7141     +300     
==========================================
+ Hits         2726     2828     +102     
- Misses       3861     4054     +193     
- Partials      254      259       +5     
Files Coverage Ξ”
pkg/apis/nfd/nodefeaturerule/rule.go 74.59% <100.00%> (-7.43%) :arrow_down:
source/source.go 38.33% <ΓΈ> (+1.82%) :arrow_up:
pkg/apis/nfd/nodefeaturerule/expression.go 81.70% <83.16%> (+<0.01%) :arrow_up:

... and 9 files with indirect coverage changes

codecov[bot] avatar May 24 '24 10:05 codecov[bot]