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

reduce unnecessary update when processing in the workstatus controller #3804

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

Conversation

XiShanYongYe-Chang
Copy link
Member

What type of PR is this?

/kind cleanup

What this PR does / why we need it:

In the workstatus-controller, when collecting the work status, it will check if there are any changes in the resources propagated by Karmada on the member clusters. At this time, it is necessary to check for changes in annotations and labels on the resources because we allow users to add new annotations and labels to the resources. Therefore, we only need to check those annotations and labels controlled by Karmada.

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

Special notes for your reviewer:

Does this PR introduce a user-facing change?:

NONE

Signed-off-by: changzhen <changzhen5@huawei.com>
@karmada-bot karmada-bot added the kind/cleanup Categorizes issue or PR as related to cleaning up code, process, or technical debt. label Jul 18, 2023
@karmada-bot
Copy link
Collaborator

[APPROVALNOTIFIER] This PR is NOT APPROVED

This pull-request has been approved by:
To complete the pull request process, please assign kevin-wangzefeng after the PR has been reviewed.
You can assign the PR to them by writing /assign @kevin-wangzefeng in a comment when ready.

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

@karmada-bot karmada-bot added the size/L Denotes a PR that changes 100-499 lines, ignoring generated files. label Jul 18, 2023
@XiShanYongYe-Chang
Copy link
Member Author

@karmada-bot
Copy link
Collaborator

@XiShanYongYe-Chang: GitHub didn't allow me to request PR reviews from the following users: MingZhang-YBPS.

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

In response to this:

/cc @chaunceyjiang @RainbowMango @MingZhang-YBPS

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/test-infra repository.

@codecov-commenter
Copy link

Codecov Report

Merging #3804 (83b3e67) into master (8388314) will increase coverage by 0.04%.
The diff coverage is 100.00%.

❗ Your organization is not using the GitHub App Integration. As a result you may experience degraded service beginning May 15th. Please install the Github App Integration for your organization. Read more.

@@            Coverage Diff             @@
##           master    #3804      +/-   ##
==========================================
+ Coverage   55.65%   55.70%   +0.04%     
==========================================
  Files         225      225              
  Lines       21319    21348      +29     
==========================================
+ Hits        11865    11891      +26     
- Misses       8821     8824       +3     
  Partials      633      633              
Flag Coverage Δ
unittests 55.70% <100.00%> (+0.04%) ⬆️

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

Impacted Files Coverage Δ
pkg/util/lifted/objectwatcher.go 98.18% <100.00%> (+2.02%) ⬆️

... and 1 file with indirect coverage changes


return !(propagateAnnotationsChanged(desiredObj.GetAnnotations(), clusterObj.GetAnnotations()) ||
propagateLabelsChange(desiredObj.GetLabels(), clusterObj.GetLabels(),
strings.Split(clusterObj.GetAnnotations()[workv1alpha2.ManagedLabels], ",")))
Copy link
Contributor

Choose a reason for hiding this comment

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

use a new line for strings.Split() would be better


keysStr, exist := clusterMaps[workv1alpha2.ManagedAnnotation]
if !exist {
_, exist = desireMaps[workv1alpha2.ManagedAnnotation]
Copy link
Contributor

Choose a reason for hiding this comment

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

desireMaps -> desiredAnnotations

@zach593
Copy link
Contributor

zach593 commented Jul 28, 2023

Strongly recommend move related codes out of lifted package and use util.RetainAnnotations() and util.RetainLabels() to ensure the consistency of comparison and update logic.

@XiShanYongYe-Chang
Copy link
Member Author

XiShanYongYe-Chang commented Jul 29, 2023

Thanks @zach593, I will do it later than #3808

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
kind/cleanup Categorizes issue or PR as related to cleaning up code, process, or technical debt. 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.

Why only labels are checked, but annotations are not checked.
4 participants