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

add verify for customized dependencies response #4982

Conversation

XiShanYongYe-Chang
Copy link
Member

What type of PR is this?

/kind feature

What this PR does / why we need it:

After the user customizes interpretation behavior, the Dependencies returned by the InterpretDependency interpreter are verified to prevent incorrect return values ​​from penetrating into subsequent use logic.

Which issue(s) this PR fixes:
Fixes #

Special notes for your reviewer:

Does this PR introduce a user-facing change?:

NONE

@karmada-bot karmada-bot added the kind/feature Categorizes issue or PR as related to a new feature. label May 23, 2024
@XiShanYongYe-Chang
Copy link
Member Author

/cc @chaunceyjiang @whitewindmills

@karmada-bot karmada-bot added the size/M Denotes a PR that changes 30-99 lines, ignoring generated files. label May 23, 2024
@whitewindmills
Copy link
Member

/assign

@chaunceyjiang
Copy link
Member

/assign

@chaunceyjiang
Copy link
Member

It's just a question, how did you discover that optimization could be done here?

@XiShanYongYe-Chang
Copy link
Member Author

I've been working on the #1741 issue recently. I read the code of the dependencies distributor module and found some confusing naming. So I submitted PR #4980.

In the #4980, there is an error info output:

return fmt.Errorf("the Name and LabelSelector in the DependentObjectReference of object (kind=%s %s/%s) cannot be empty at the same time", resource.Kind, resource.Namespace, resource.Name)

I think this error message should be discovered much earlier, so I submitted this PR

@whitewindmills
Copy link
Member

thanks for your quick response.
/lgtm

@karmada-bot karmada-bot added the lgtm Indicates that a PR is ready to be merged. label May 24, 2024
@codecov-commenter
Copy link

codecov-commenter commented May 24, 2024

Codecov Report

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

Project coverage is 53.32%. Comparing base (d676996) to head (8ec02ca).

Files Patch % Lines
pkg/resourceinterpreter/default/native/default.go 0.00% 4 Missing ⚠️
...sourceinterpreter/default/thirdparty/thirdparty.go 0.00% 3 Missing ⚠️

❗ Your organization needs to install the Codecov GitHub app to enable full functionality.

Additional details and impacted files
@@           Coverage Diff           @@
##           master    #4982   +/-   ##
=======================================
  Coverage   53.31%   53.32%           
=======================================
  Files         252      253    +1     
  Lines       20539    20554   +15     
=======================================
+ Hits        10951    10960    +9     
- Misses       8862     8869    +7     
+ Partials      726      725    -1     
Flag Coverage Δ
unittests 53.32% <56.25%> (+<0.01%) ⬆️

Flags with carried forward coverage won't be shown. Click here to find out more.

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

Copy link
Member

@chaunceyjiang chaunceyjiang left a comment

Choose a reason for hiding this comment

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

/lgtm

@XiShanYongYe-Chang
Copy link
Member Author

/cc @RainbowMango

Copy link
Member

@RainbowMango RainbowMango left a comment

Choose a reason for hiding this comment

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

Some nits, and a question:
Why not verify the dependencies returned from the default interpreters?

pkg/resourceinterpreter/customized/validate/validate.go Outdated Show resolved Hide resolved
pkg/resourceinterpreter/customized/validate/validate.go Outdated Show resolved Hide resolved
pkg/resourceinterpreter/customized/validate/validate.go Outdated Show resolved Hide resolved
pkg/resourceinterpreter/customized/validate/validate.go Outdated Show resolved Hide resolved
pkg/resourceinterpreter/customized/validate/validate.go Outdated Show resolved Hide resolved
@XiShanYongYe-Chang
Copy link
Member Author

Why not verify the dependencies returned from the default interpreters?

I think that the return body of external requests should be verified. The default interpreter does not involve external requests. It should be determined that the code is normal when it is written.

@RainbowMango
Copy link
Member

@chaunceyjiang what's your opinion on this?

@karmada-bot karmada-bot removed the lgtm Indicates that a PR is ready to be merged. label May 28, 2024
@chaunceyjiang
Copy link
Member

Why not verify the dependencies returned from the default interpreters?

Good question! I believe third-party interpreters also need this.

@RainbowMango
Copy link
Member

Yes, that's exactly the reason why I'm asking.

@XiShanYongYe-Chang
Copy link
Member Author

Validation for the InterpretDependency operation has been added for all interpreters.

@karmada-bot karmada-bot 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 May 28, 2024
…tion

Signed-off-by: changzhen <changzhen5@huawei.com>
Copy link
Member

@RainbowMango RainbowMango left a comment

Choose a reason for hiding this comment

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

/lgtm
/approve

@karmada-bot karmada-bot added the lgtm Indicates that a PR is ready to be merged. label May 28, 2024
@karmada-bot
Copy link
Collaborator

[APPROVALNOTIFIER] This PR is APPROVED

This pull-request has been approved by: RainbowMango

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

@karmada-bot karmada-bot added the approved Indicates a PR has been approved by an approver from all required OWNERS files. label May 28, 2024
@karmada-bot karmada-bot merged commit 6fbdd9e into karmada-io:master May 28, 2024
12 checks passed
@XiShanYongYe-Chang XiShanYongYe-Chang deleted the add-verify-dependencies-response branch June 7, 2024 08:46
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. kind/feature Categorizes issue or PR as related to a new feature. lgtm 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

6 participants