-
Notifications
You must be signed in to change notification settings - Fork 238
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
Fix templates for NodeFeatureRule with MatchAny #865
Conversation
test that NodeFeatureRule templates work with empty MatchFeatures, but with MatchAny. this test would fail, higligting an issue which is fixed in next commit. see kubernetes-sigs#864. Signed-off-by: Viktor Oreshkin <imselfish@stek29.rocks>
Welcome @stek29! |
Hi @stek29. Thanks for your PR. I'm waiting for a kubernetes-sigs member to verify that this patch is reasonable to test. If it is, they should reply with Once the patch is verified, the new status will be reflected by the I understand the commands that are listed here. 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. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Wov, thanks for the patch @stek29! This is indeed broken. And great that you updated the unit tests, too 👍
I had one suggestion, though.
/ok-to-test
pkg/apis/nfd/v1alpha1/rule.go
Outdated
if r.labelsTemplate == nil { | ||
// No templating so we stop here (further matches would just | ||
// produce the same labels) | ||
break | ||
} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
It is still useful to check if the templates have been defined. If there would be 10 items under MatchAny
and the first matches (and no templates are specified) there is no use to evaluate the 9 remaining items.
My suggestion to change/fix this instead
if r.LabelsTemplate == "" && r.VarsTemplate == "" {
// No templating so we stop here (further matches would just
// produce the same labels / vars)
break
}
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
sure, will do
...and seems that somebody's really using the templating functionality 😊 /cherry-pick release-0.11 |
@marquiz: once the present PR merges, I will cherry-pick it on top of release-0.11 in a new PR and assign it to you. In response to this:
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. |
PING @stek29 |
Signed-off-by: Viktor Oreshkin <imselfish@stek29.rocks>
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Looks good to me now 👌
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
/lgtm
[APPROVALNOTIFIER] This PR is APPROVED This pull-request has been approved by: ArangoGutierrez, marquiz, stek29 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 |
@marquiz: new pull request created: #872 In response to this:
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. |
When
MatchAny
is matched, template existence is checked withr.labelsTemplate == nil
, and if it's nil - templating is skipped.This is wrong because:
vars
templates too, not onlylabels
templateslabelsTemplate
is initialized fromLabelsTemplate
whenexecuteLabelsTemplate
is called first time, so it would always be nil unless Rule hasMatchFeatures
in addition toMatchAny
, and was executed already.LabelsTemplate
should be checked instead oflabelsTemplate
(same for vars) to see if there's template – butexecuteLabelsTemplate
already does that.So the check should be removed completely.
I've also added a test case which catches this issue.
Fixes #864.