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

skip the filter if the cluster is already in the list of scheduling result even if the API is missed #5216

Merged
merged 1 commit into from
Sep 18, 2024

Conversation

yanfeng1992
Copy link
Member

@yanfeng1992 yanfeng1992 commented Jul 18, 2024

Signed-off-by: huangyanfeng [email protected]

What type of PR is this?
/kind bug

What this PR does / why we need it:

Because when obtaining APIEnablements, it may be empty or partial.
This will cause the scheduler to delete the scheduling results, resulting in incorrect deletion

So if the cluster is already in the list of scheduling results, even if the API is not hit, skip the filter

apiEnables, err := getAPIEnablements(clusterClient)
if len(apiEnables) == 0 {
klog.Errorf("Failed to get any APIs installed in Cluster %s. Error: %v.", cluster.GetName(), err)
} else if err != nil {
klog.Warningf("Maybe get partial(%d) APIs installed in Cluster %s. Error: %v.", len(apiEnables), cluster.GetName(), err)
}
currentClusterStatus.APIEnablements = apiEnables

Which issue(s) this PR fixes:
Fixes #

Special notes for your reviewer:

Does this PR introduce a user-facing change?:

`karmada-scheduler`: Avoid filtering out clusters if the API enablement is incomplete during re-scheduling.

@karmada-bot karmada-bot added the kind/bug Categorizes issue or PR as related to a bug. label Jul 18, 2024
@karmada-bot karmada-bot added the size/XS Denotes a PR that changes 0-9 lines, ignoring generated files. label Jul 18, 2024
@yanfeng1992
Copy link
Member Author

/retest

@codecov-commenter
Copy link

codecov-commenter commented Jul 18, 2024

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

Codecov Report

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

Project coverage is 34.14%. Comparing base (e76ce63) to head (4c416ce).
Report is 4 commits behind head on master.

Files with missing lines Patch % Lines
.../framework/plugins/apienablement/api_enablement.go 0.00% 7 Missing ⚠️

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

Additional details and impacted files
@@            Coverage Diff             @@
##           master    #5216      +/-   ##
==========================================
- Coverage   34.14%   34.14%   -0.01%     
==========================================
  Files         643      643              
  Lines       44522    44527       +5     
==========================================
+ Hits        15204    15205       +1     
- Misses      28162    28166       +4     
  Partials     1156     1156              
Flag Coverage Δ
unittests 34.14% <0.00%> (-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.

@XiShanYongYe-Chang
Copy link
Member

Thanks for your feedback @yanfeng1992

Because when obtaining APIEnablements, it may be empty or partial.

When will that happen?

@chaunceyjiang
Copy link
Member

When will that happen?

I guess it's when the status of AA is false?

@yanfeng1992
Copy link
Member Author

When will that happen?

I guess it's when the status of AA is false?

When the AA status is false and the cluster status is healthy

@XiShanYongYe-Chang
Copy link
Member

Thanks @chaunceyjiang @yanfeng1992 , I get it.

@@ -55,8 +55,12 @@ func (p *APIEnablement) Filter(
cluster *clusterv1alpha1.Cluster,
) *framework.Result {
if !helper.IsAPIEnabled(cluster.Status.APIEnablements, bindingSpec.Resource.APIVersion, bindingSpec.Resource.Kind) {
klog.V(2).Infof("Cluster(%s) not fit as missing API(%s, kind=%s)", cluster.Name, bindingSpec.Resource.APIVersion, bindingSpec.Resource.Kind)
return framework.NewResult(framework.Unschedulable, "cluster(s) did not have the API resource")
if !bindingSpec.TargetContains(cluster.Name) {
Copy link
Member

Choose a reason for hiding this comment

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

The core meaning of your PR is: If the binding has already been scheduled to a certain cluster, then we should ignore this apienablement plugin, right?

I have a question: If the AA service is no longer healthy, can it still create corresponding resources?

Copy link
Member

Choose a reason for hiding this comment

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

Can we determine whether the cluster status needs to be updated based on the returned error?

apiEnables, err := getAPIEnablements(clusterClient)
if len(apiEnables) == 0 {
klog.Errorf("Failed to get any APIs installed in Cluster %s. Error: %v.", cluster.GetName(), err)
} else if err != nil {
klog.Warningf("Maybe get partial(%d) APIs installed in Cluster %s. Error: %v.", len(apiEnables), cluster.GetName(), err)
}
currentClusterStatus.APIEnablements = apiEnables

Only when the err description indicates that some APIs fail to be installed, the returned apiEnables will be updated to the cluster status.

@yanfeng1992
Copy link
Member Author

/assign @XiShanYongYe-Chang

@karmada-bot karmada-bot added size/S Denotes a PR that changes 10-29 lines, ignoring generated files. and removed size/XS Denotes a PR that changes 0-9 lines, ignoring generated files. labels Sep 14, 2024
@whitewindmills
Copy link
Member

@RainbowMango @XiShanYongYe-Chang
since #5400 has been merged, could you help move this forward?

@XiShanYongYe-Chang
Copy link
Member

Of course, let me take a review.

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
I want to take a look.

@karmada-bot karmada-bot added size/XS Denotes a PR that changes 0-9 lines, ignoring generated files. and removed size/S Denotes a PR that changes 10-29 lines, ignoring generated files. labels Sep 18, 2024
@RainbowMango
Copy link
Member

It seems not the one I suggested.

…omplete to prevent accidental removal.

Signed-off-by: huangyanfeng <[email protected]>
@karmada-bot karmada-bot added size/S Denotes a PR that changes 10-29 lines, ignoring generated files. and removed size/XS Denotes a PR that changes 0-9 lines, ignoring generated files. labels Sep 18, 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.

/lgtm

@yanfeng1992 Have you tested it?

@karmada-bot karmada-bot added the lgtm Indicates that a PR is ready to be merged. label Sep 18, 2024
@yanfeng1992
Copy link
Member Author

yanfeng1992 commented Sep 18, 2024

@yanfeng1992 Have you tested it?

step1. stop karmada-controller-manager and patch cluster
kubectl patch cluster cluster5715 --type='merge' -p "{ \"status\": { \"apiEnablements\": [], \"conditions\": [ { \"message\": \"test\", \"reason\": \"Empty\", \"status\": \"False\", \"type\": \"CompleteAPIEnablements\", \"lastTransitionTime\": \"$CURRENT_TIME\" } ] } }" --kubeconfig /etc/karmada/karmada-apiserver.config

step2: edit crb add label for test

log:

clusterResourceBinding(test-clusterrolebinding) scheduled to clusters [{cluster5715 0}]

@RainbowMango
Copy link
Member

/approve
Thanks. I assume @whitewindmills has no further comments.

@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 Sep 18, 2024
@karmada-bot karmada-bot merged commit ec0521a into karmada-io:master Sep 18, 2024
12 checks passed
@yanfeng1992 yanfeng1992 deleted the fix-apienables branch September 26, 2024 08:08
karmada-bot added a commit that referenced this pull request Dec 11, 2024
…k-of-#5400-upstream-release-1.9

Automated cherry pick of #5400, #5216
karmada-bot added a commit that referenced this pull request Dec 11, 2024
…k-of-#5400-upstream-release-1.10

Automated cherry pick of #5400, #5216
karmada-bot added a commit that referenced this pull request Dec 11, 2024
…k-of-#5400-upstream-release-1.11

Automated cherry pick of #5400, #5216
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/bug Categorizes issue or PR as related to a bug. lgtm Indicates that a PR is ready to be merged. size/S Denotes a PR that changes 10-29 lines, ignoring generated files.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

7 participants