Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

apis/nfd: empty match expression set returns no features for templates #787

Merged

Conversation

marquiz
Copy link
Contributor

@marquiz marquiz commented Mar 17, 2022

This patch changes a rare corner case of custom label rules with an
empty set of matchexpressions. The patch removes a special case where an
empty match expression set matched everything and returned all feature
elements for templates to consume. With this patch the match expression
set logically evaluates all expressions in the set and returns all
matches - if there are no expressions there are no matches and no
matched features are returned. However, the overall match result
(determining if "non-template" labels will be created) in this special
case will be "true" as before as none of the zero match expressions
failed.

The former behavior was somewhat illogical and counterintuitive: having
1 to N expressions matched and returned 1 to N features (at most), but,
having 0 expressions always matched everything and returned all
features. This was some leftover proof-of-concept functionality (for
some possible future extensions) that should have been removed before
merging.

@k8s-ci-robot k8s-ci-robot added cncf-cla: yes Indicates the PR's author has signed the CNCF CLA. size/M Denotes a PR that changes 30-99 lines, ignoring generated files. labels Mar 17, 2022
@k8s-ci-robot k8s-ci-robot added the approved Indicates a PR has been approved by an approver from all required OWNERS files. label Mar 17, 2022
@marquiz marquiz added this to the v0.11.0 milestone Mar 17, 2022
@marquiz
Copy link
Contributor Author

marquiz commented Mar 18, 2022

Still thinking about some special cases of this...
/hold

@k8s-ci-robot k8s-ci-robot added the do-not-merge/hold Indicates that a PR should not merge because someone has issued a /hold command. label Mar 18, 2022
@marquiz marquiz force-pushed the devel/empty-matchexpression branch from 0eaa28a to b0b4911 Compare March 21, 2022 13:58
@k8s-ci-robot k8s-ci-robot added size/L Denotes a PR that changes 100-499 lines, ignoring generated files. and removed size/M Denotes a PR that changes 30-99 lines, ignoring generated files. labels Mar 21, 2022
@marquiz
Copy link
Contributor Author

marquiz commented Mar 21, 2022

Updated, now I think it is better
/unhold
/retitle apis/nfd: empty match expression set returns no features for templates

@k8s-ci-robot k8s-ci-robot removed the do-not-merge/hold Indicates that a PR should not merge because someone has issued a /hold command. label Mar 21, 2022
@k8s-ci-robot k8s-ci-robot changed the title apis/nfd: empty match expression set matches nothing apis/nfd: empty match expression set returns no features for templates Mar 21, 2022
This patch changes a rare corner case of custom label rules with an
empty set of matchexpressions. The patch removes a special case where an
empty match expression set matched everything and returned all feature
elements for templates to consume. With this patch the match expression
set logically evaluates all expressions in the set and returns all
matches - if there are no expressions there are no matches and no
matched features are returned. However, the overall match result
(determining if "non-template" labels will be created) in this special
case will be "true" as before as none of the zero match expressions
failed.

The former behavior was somewhat illogical and counterintuitive: having
1 to N expressions matched and returned 1 to N features (at most), but,
having 0 expressions always matched everything and returned all
features. This was some leftover proof-of-concept functionality (for
some possible future extensions) that should have been removed before
merging.
@marquiz marquiz force-pushed the devel/empty-matchexpression branch from b0b4911 to 36341bf Compare March 24, 2022 09:51
@marquiz
Copy link
Contributor Author

marquiz commented Mar 24, 2022

/assign zvonkok ArangoGutierrez

@ArangoGutierrez
Copy link
Contributor

tested ✅

apiVersion: kustomize.config.k8s.io/v1beta1
kind: Kustomization

namespace: node-feature-discovery

images:
- name: '*'
  newName: quay.io/eduardoarango/node-feature-discovery
  newTag: v0.11.0-devel-69-g36341bf4

resources:
- deployment/overlays/default

Copy link
Contributor

@ArangoGutierrez ArangoGutierrez left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

lgtm

@k8s-ci-robot
Copy link
Contributor

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

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

@ArangoGutierrez
Copy link
Contributor

Up to Zvonko for final lgtm

@zvonkok
Copy link
Contributor

zvonkok commented Mar 25, 2022

/lgtm

@k8s-ci-robot k8s-ci-robot added the lgtm "Looks good to me", indicates that a PR is ready to be merged. label Mar 25, 2022
@k8s-ci-robot k8s-ci-robot merged commit 4a6e9c7 into kubernetes-sigs:master Mar 25, 2022
@marquiz marquiz deleted the devel/empty-matchexpression branch March 25, 2022 13:38
@marquiz marquiz mentioned this pull request Mar 28, 2022
22 tasks
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
approved Indicates a PR has been approved by an approver from all required OWNERS files. cncf-cla: yes Indicates the PR's author has signed the CNCF CLA. lgtm "Looks good to me", indicates that a PR is ready to be merged. size/L Denotes a PR that changes 100-499 lines, ignoring generated files.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

4 participants