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

fix: failed to sync work when binding's target clusters are empty #5818

Open
wants to merge 1 commit into
base: master
Choose a base branch
from

Conversation

vie-serendipity
Copy link
Contributor

What type of PR is this?

/kind bug
What this PR does / why we need it:
For now, when binding is not scheduled, which means clusters field is empty, work will still be synced. And this log will be printed.
Sync work of resourceBinding(%s/%s) successful
But actually no work is created. I think it's necessary to check whether clusters field of binding is empty. I'not sure this should be added to predicates of controller or just put it into syncbinding function, like my current pr code. I think the latter is better, in this way, users can see scheduling encounter some problems.

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/bug Categorizes issue or PR as related to a bug. label Nov 14, 2024
@karmada-bot karmada-bot added the size/XS Denotes a PR that changes 0-9 lines, ignoring generated files. label Nov 14, 2024
@karmada-bot karmada-bot added size/M Denotes a PR that changes 30-99 lines, ignoring generated files. and removed size/XS Denotes a PR that changes 0-9 lines, ignoring generated files. labels Nov 14, 2024
@XiShanYongYe-Chang
Copy link
Member

Hi @vie-serendipity thanks for your feedback. We can really decide whether to reconcile the ResourceBinding based on whether the scheduling has been completed (the ClusterResourceBinding has the same processing logic), which can save some unnecessary tuning. Therefore, I understand that this should be an optimization, not a bug fix.

In addition, we can judge whether the scheduling is completed in this way: obj.Status.SchedulerObservedGeneration == obj.Generation, this can cover the situation where there is no scheduling result.

@vie-serendipity
Copy link
Contributor Author

We can really decide whether to reconcile the ResourceBinding based on whether the scheduling has been completed (the ClusterResourceBinding has the same processing logic), which can save some unnecessary tuning.

For now, I find the logic to reconcile depends on WithEventFilter(predicate.GenerationChangedPredicate{}). I didn't find any other logic to prevent reconciliation (if any, please remind me). But in my case, my scheduler crashed, and after the binding was updated, I directly saw Sync work of resourceBinding(%s/%s) successful in controller manager's log. So I think this is unexpected.

We can add obj.Status.SchedulerObservedGeneration == obj.Generation to predicates, not only generationchanged?

@XiShanYongYe-Chang
Copy link
Member

For now, I find the logic to reconcile depends on WithEventFilter(predicate.GenerationChangedPredicate{}). I didn't find any other logic to prevent reconciliation (if any, please remind me).

You are right.

But in my case, my scheduler crashed

Does this mean the component crashed and restarted?

I directly saw Sync work of resourceBinding(%s/%s) successful in controller manager's log.

I think this operation has no negative impact, am I right?

We can add obj.Status.SchedulerObservedGeneration == obj.Generation to predicates, not only generationchanged?

According to the information you describe, I think so, we can save unnecessary reconcile.

@vie-serendipity
Copy link
Contributor Author

Does this mean the component crashed and restarted?

The scheduler failed to pull the image, so it doesn't do scheduling.

I think this operation has no negative impact, am I right?

Yes, I think so. I will update code in my pr.

@XiShanYongYe-Chang
Copy link
Member

The scheduler failed to pull the image, so it doesn't do scheduling.

Thanks for your quick response.

Now, I want to make sure that if the image is correctly pulled, can you find the log you're referring to?

@vie-serendipity
Copy link
Contributor Author

Actually, I see this log in controller manager's log. Because my scheduler is not ready, I think this log is unexpected. And I can't find log because I am testing and the environment changes significantly.
Sync work of resourceBinding(%s/%s) successful

@XiShanYongYe-Chang
Copy link
Member

Actually, I see this log in controller manager's log. Because my scheduler is not ready, I think this log is unexpected. And I can't find log because I am testing and the environment changes significantly. Sync work of resourceBinding(%s/%s) successful

You can check whether the log exists after adjusting the environment.

@vie-serendipity
Copy link
Contributor Author

The controller manager pod restarts, so the log doesn't exist.

Signed-off-by: vie-serendipity <2733147505@qq.com>
@karmada-bot
Copy link
Collaborator

[APPROVALNOTIFIER] This PR is NOT APPROVED

This pull-request has been approved by:
Once this PR has been reviewed and has the lgtm label, please assign chaunceyjiang for approval. For more information see the Kubernetes Code Review Process.

The full list of commands accepted by this bot can be found 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

@codecov-commenter
Copy link

⚠️ 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 40 lines in your changes missing coverage. Please review.

Project coverage is 46.16%. Comparing base (6795dba) to head (9f6bf68).
Report is 33 commits behind head on master.

Files with missing lines Patch % Lines
pkg/controllers/binding/binding_controller.go 0.00% 20 Missing ⚠️
...ers/binding/cluster_resource_binding_controller.go 0.00% 20 Missing ⚠️

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

Additional details and impacted files
@@            Coverage Diff             @@
##           master    #5818      +/-   ##
==========================================
+ Coverage   46.02%   46.16%   +0.14%     
==========================================
  Files         660      663       +3     
  Lines       53987    54618     +631     
==========================================
+ Hits        24848    25216     +368     
- Misses      27521    27779     +258     
- Partials     1618     1623       +5     
Flag Coverage Δ
unittests 46.16% <0.00%> (+0.14%) ⬆️

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.


🚨 Try these New Features:

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
kind/bug Categorizes issue or PR as related to a bug. 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.

4 participants