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

work suspension: webhook validation #5282

Merged
merged 1 commit into from
Aug 7, 2024

Conversation

a7i
Copy link
Contributor

@a7i a7i commented Jul 31, 2024

What type of PR is this?
/kind feature

What this PR does / why we need it:

Which issue(s) this PR fixes:
Fixes #5118

Special notes for your reviewer:

Does this PR introduce a user-facing change?:


@karmada-bot karmada-bot added the kind/feature Categorizes issue or PR as related to a new feature. label Jul 31, 2024
@karmada-bot karmada-bot added the size/XL Denotes a PR that changes 500-999 lines, ignoring generated files. label Jul 31, 2024
@codecov-commenter
Copy link

codecov-commenter commented Jul 31, 2024

⚠️ Please install the 'codecov app svg image' to ensure uploads and comments are reliably processed by Codecov.

Codecov Report

All modified and coverable lines are covered by tests ✅

Project coverage is 28.40%. Comparing base (b4b6d69) to head (d9e174b).
Report is 408 commits behind head on master.

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

Additional details and impacted files
@@            Coverage Diff             @@
##           master    #5282      +/-   ##
==========================================
+ Coverage   28.38%   28.40%   +0.02%     
==========================================
  Files         632      632              
  Lines       43801    43810       +9     
==========================================
+ Hits        12432    12444      +12     
+ Misses      30464    30462       -2     
+ Partials      905      904       -1     
Flag Coverage Δ
unittests 28.40% <100.00%> (+0.02%) ⬆️

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.

@a7i
Copy link
Contributor Author

a7i commented Jul 31, 2024

/hold

until #4838 is merged

@karmada-bot karmada-bot added the do-not-merge/hold Indicates that a PR should not merge because someone has issued a /hold command. label Jul 31, 2024
@XiShanYongYe-Chang
Copy link
Member

/assign

@XiShanYongYe-Chang
Copy link
Member

Hi @a7i we can continue this task ^-^

@a7i a7i force-pushed the work-suspend-validation branch from bda6298 to 8e4c70c Compare August 6, 2024 16:36
@karmada-bot karmada-bot added size/M Denotes a PR that changes 30-99 lines, ignoring generated files. and removed size/XL Denotes a PR that changes 500-999 lines, ignoring generated files. labels Aug 6, 2024
@a7i
Copy link
Contributor Author

a7i commented Aug 6, 2024

/remove-hold

@karmada-bot karmada-bot removed the do-not-merge/hold Indicates that a PR should not merge because someone has issued a /hold command. label Aug 6, 2024
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.

/assign

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.

Generally looks good.

I'm surprised that this PR is not based on the latest commit, but all tests are passing. I fetched the PR on my side (by git fetch upstream pull/5282/head:5282) and it failed to compile as missing the API definition.

I'm unsure if this is due to GitHub Action changing how it fetches code.

Anyway, @a7i could you please help to rebase this and push again?

Comment on lines 71 to 76
if !ptr.Deref(suspension.Dispatching, false) {
return nil
}

if suspension.DispatchingOnClusters == nil || len(suspension.DispatchingOnClusters.ClusterNames) == 0 {
return nil
}

return field.ErrorList{
field.Invalid(fldPath.Child("suspension"), suspension, "suspension dispatching cannot co-exist with dispatchingOnClusters.clusterNames"),
}
Copy link
Member

Choose a reason for hiding this comment

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

I would prefer this straightforward style:

Suggested change
if !ptr.Deref(suspension.Dispatching, false) {
return nil
}
if suspension.DispatchingOnClusters == nil || len(suspension.DispatchingOnClusters.ClusterNames) == 0 {
return nil
}
return field.ErrorList{
field.Invalid(fldPath.Child("suspension"), suspension, "suspension dispatching cannot co-exist with dispatchingOnClusters.clusterNames"),
}
if (suspension.Dispatching != nil && *suspension.Dispatching == true) &&
(suspension.DispatchingOnClusters != nil && len(suspension.DispatchingOnClusters.ClusterNames) > 0) {
return field.ErrorList{
field.Invalid(fldPath.Child("suspension"), suspension, "suspension dispatching cannot co-exist with dispatchingOnClusters.clusterNames"),
}
}
return nil

Copy link
Contributor

Choose a reason for hiding this comment

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

the old version was easier to digest for me ... ideally 1 comment per if explaining what is going on
suggested feels a overwhelming

Copy link
Member

Choose a reason for hiding this comment

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

I'm sorry for not explaining why I'm suggesting that in detail.

Firstly the old version is great, it looks simple. But given that we need a single check on whether the two fields co-exist, I tend to a more cohesive approach to make it easier to add more checks in the future.

@a7i a7i force-pushed the work-suspend-validation branch from 8e4c70c to 1e0e0a6 Compare August 7, 2024 03:34
@a7i
Copy link
Contributor Author

a7i commented Aug 7, 2024

thanks for the review @RainbowMango

rebased and applied the suggestion

@a7i a7i force-pushed the work-suspend-validation branch from 1e0e0a6 to d9e174b Compare August 7, 2024 03:53
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 Aug 7, 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 Aug 7, 2024
@RainbowMango
Copy link
Member

/retest
The failing case seems unrelated.

@karmada-bot karmada-bot merged commit d2adb3d into karmada-io:master Aug 7, 2024
12 checks passed
@a7i a7i deleted the work-suspend-validation branch August 7, 2024 11:21
@RainbowMango RainbowMango added this to the v1.11 milestone Aug 31, 2024
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/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.

6 participants