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

Bugfixes for image compatibility feature #2010

Merged
merged 4 commits into from
Jan 10, 2025

Conversation

mfranczy
Copy link
Contributor

@mfranczy mfranczy commented Jan 8, 2025

Bugfixes:

  • Always pull the latest compatibility artifact
  • Handle missing compatibility matches to avoid panic
  • Continue procesing the rule if the feature is missing

@k8s-ci-robot k8s-ci-robot added the cncf-cla: yes Indicates the PR's author has signed the CNCF CLA. label Jan 8, 2025
@k8s-ci-robot
Copy link
Contributor

Hi @mfranczy. 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 /ok-to-test on its own line. Until that is done, I will not automatically test new commits in this PR, but the usual testing commands by org members will still work. Regular contributors should join the org to skip this step.

Once the patch is verified, the new status will be reflected by the ok-to-test label.

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-sigs/prow repository.

@k8s-ci-robot k8s-ci-robot added needs-ok-to-test Indicates a PR that requires an org member to verify it is safe to test. size/M Denotes a PR that changes 30-99 lines, ignoring generated files. labels Jan 8, 2025
Copy link

netlify bot commented Jan 8, 2025

Deploy Preview for kubernetes-sigs-nfd ready!

Name Link
🔨 Latest commit 8db03fe
🔍 Latest deploy log https://app.netlify.com/sites/kubernetes-sigs-nfd/deploys/677f940414a5730008764506
😎 Deploy Preview https://deploy-preview-2010--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.

@mfranczy
Copy link
Contributor Author

mfranczy commented Jan 8, 2025

@k8s-ci-robot
Copy link
Contributor

@mfranczy: GitHub didn't allow me to request PR reviews from the following users: ChaoyiHuang.

Note that only kubernetes-sigs members and repo collaborators can review this PR, and authors cannot review their own PRs.

In response to this:

/cc @marquiz @ArangoGutierrez @ChaoyiHuang

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-sigs/prow repository.

@marquiz
Copy link
Contributor

marquiz commented Jan 8, 2025

/cherry-pick release-0.17

@k8s-infra-cherrypick-robot

@marquiz: once the present PR merges, I will cherry-pick it on top of release-0.17 in a new PR and assign it to you.

In response to this:

/cherry-pick release-0.17

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-sigs/prow repository.

@marquiz
Copy link
Contributor

marquiz commented Jan 8, 2025

/ok-to-test

@k8s-ci-robot k8s-ci-robot added ok-to-test Indicates a non-member PR verified by an org member that is safe to test. and removed needs-ok-to-test Indicates a PR that requires an org member to verify it is safe to test. labels Jan 8, 2025
@mfranczy
Copy link
Contributor Author

mfranczy commented Jan 8, 2025

/test pull-node-feature-discovery-build-image-cross-generic

@@ -97,6 +97,7 @@ func (nv *nodeValidator) Execute(ctx context.Context) ([]*CompatibilityStatus, e
}

func evaluateRuleStatus(rule *nfdv1alpha1.Rule, matchStatus *nodefeaturerule.MatchStatus) ProcessedRuleStatus {
Copy link
Contributor

Choose a reason for hiding this comment

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

could this function be a function of (nv *nodeValidator). and the function refactory will enhance the readbility

Copy link
Contributor

Choose a reason for hiding this comment

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

We could add the refactoring stuff as TODO notes and/or create a GitHub issue for tracking and concentrate solely on bugfixes in this PR. WDYT?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

I agree. I plan to do refactoring but in a different PR, in this specific one I would prefer only to concentrate on the bugfixes I provided.

Copy link
Contributor

Choose a reason for hiding this comment

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

TODO notes sounds good

@@ -97,6 +97,7 @@ func (nv *nodeValidator) Execute(ctx context.Context) ([]*CompatibilityStatus, e
}

func evaluateRuleStatus(rule *nfdv1alpha1.Rule, matchStatus *nodefeaturerule.MatchStatus) ProcessedRuleStatus {
var matchedFeatureTerms nfdv1alpha1.FeatureMatcher
out := ProcessedRuleStatus{Name: rule.Name, IsMatch: matchStatus.IsMatch}

evaluateFeatureMatcher := func(featureMatcher, matchedFeatureTerms nfdv1alpha1.FeatureMatcher) []MatchedExpression {
Copy link
Contributor

@ChaoyiHuang ChaoyiHuang Jan 9, 2025

Choose a reason for hiding this comment

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

nested evaluateFeatureMatcher function make it become a little long for evaluateRuleStatus. could the evaluateFeatureMatcher become a function of (nv *nodeValidator)

and in the evaluateFeatureMatcher nested function, processedTerm := range matchedFeatureTerms where matchedFeatureTerms comes from the function parameter in expression condition, and processedTerm := range matchStatus.MatchedFeaturesTerms where the processedTerm comes from the parent function parameter.

the evaluateFeatureMatcher will process two condition, it can be divided into two function, which handle expression or name separately, or one function with same parameters, but processing according to evaluation on expression or name.

obviously that the processedTerm have multiple sources, so we can handle it two function layer:

one is to handle various sources, the other layer to handle proecssedTerm

Copy link
Contributor Author

@mfranczy mfranczy Jan 9, 2025

Choose a reason for hiding this comment

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

@ChaoyiHuang I will provide the refactored code but in a different PR. I would prefer that it doesn't grow too much that we can merge the fixes fast.

Copy link
Contributor

@marquiz marquiz Jan 9, 2025

Choose a reason for hiding this comment

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

Also, doing refactoring in a separate PR makes backporting to release branch cleaner and less risky

EDIT: meaning if possible we only backport the bugfixes but not the refactoring

@@ -163,11 +164,17 @@ func evaluateRuleStatus(rule *nfdv1alpha1.Rule, matchStatus *nodefeaturerule.Mat
}

if matchFeatures := rule.MatchFeatures; matchFeatures != nil {
out.MatchedExpressions = evaluateFeatureMatcher(matchFeatures, matchStatus.MatchedFeaturesTerms)
if matchStatus.MatchFeatureStatus != nil {
Copy link
Contributor

Choose a reason for hiding this comment

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

non supported features in nfd could be added as some test cases. the tool should deal with unrecognized feature name or expression as well. in the future may check whether non-supported features are in image-compatibility artifact

Copy link
Contributor Author

Choose a reason for hiding this comment

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

I have added a unit test to check the behaviour. Currently, it's allowed to add any feature to the spec, if it doesn't exist the rule will fail. The user will get a log about it (in debug mode). In the future, we can think of additional behaviours (like stopping the execution if the feature doesn't exist etc.).

Copy link
Contributor

@marquiz marquiz left a comment

Choose a reason for hiding this comment

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

Looks good to go from my pov.

@ChaoyiHuang WDYT?

@k8s-ci-robot
Copy link
Contributor

[APPROVALNOTIFIER] This PR is APPROVED

This pull-request has been approved by: marquiz, mfranczy

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 k8s-ci-robot added the approved Indicates a PR has been approved by an approver from all required OWNERS files. label Jan 9, 2025
@marquiz marquiz mentioned this pull request Jan 9, 2025
16 tasks
@ChaoyiHuang
Copy link
Contributor

Looks good to go from my pov.

@ChaoyiHuang WDYT?

LGTM

@marquiz
Copy link
Contributor

marquiz commented Jan 10, 2025

/lgtm

@k8s-ci-robot k8s-ci-robot added the lgtm "Looks good to me", indicates that a PR is ready to be merged. label Jan 10, 2025
@k8s-ci-robot
Copy link
Contributor

LGTM label has been added.

Git tree hash: 1bca56f2209f55853fae1b45f9d8dff338bc0019

@k8s-ci-robot k8s-ci-robot merged commit feea0e3 into kubernetes-sigs:master Jan 10, 2025
10 checks passed
@k8s-infra-cherrypick-robot

@marquiz: new pull request created: #2016

In response to this:

/cherry-pick release-0.17

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-sigs/prow repository.

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. ok-to-test Indicates a non-member PR verified by an org member that is safe to test. size/M Denotes a PR that changes 30-99 lines, ignoring generated files.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

5 participants