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 bug: avoid updating directly cached resource template #3879

Merged
merged 1 commit into from
Aug 3, 2023

Conversation

whitewindmills
Copy link
Member

@whitewindmills whitewindmills commented Aug 2, 2023

What type of PR is this?
/kind bug

What this PR does / why we need it:
avoid updating directly cached resource template.

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

Special notes for your reviewer:

Does this PR introduce a user-facing change?:

`karmada-controller-manager`: Avoid updating directly cached resource templates.

@karmada-bot karmada-bot added the kind/bug Categorizes issue or PR as related to a bug. label Aug 2, 2023
@karmada-bot karmada-bot added the size/XS Denotes a PR that changes 0-9 lines, ignoring generated files. label Aug 2, 2023
@codecov-commenter
Copy link

Codecov Report

Merging #3879 (931f1e4) into master (d916d87) will decrease coverage by 0.02%.
Report is 2 commits behind head on master.
The diff coverage is 0.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    #3879      +/-   ##
==========================================
- Coverage   54.98%   54.97%   -0.02%     
==========================================
  Files         228      228              
  Lines       21786    21791       +5     
==========================================
  Hits        11980    11980              
- Misses       9167     9172       +5     
  Partials      639      639              
Flag Coverage Δ
unittests 54.97% <0.00%> (-0.02%) ⬇️

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

Files Changed Coverage Δ
pkg/detector/detector.go 0.00% <0.00%> (ø)
pkg/detector/policy.go 0.00% <0.00%> (ø)

Copy link
Member

@XiShanYongYe-Chang XiShanYongYe-Chang left a comment

Choose a reason for hiding this comment

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

Thanks a lot.

In order to prevent other places where the utility methods are called from modifying the objects in the cache, I think it would be better to directly make modifications within the utility methods.

Furthermore, this issue indicates that we do not have an end-to-end (E2E) coverage for this scenario. If possible, could you please provide an additional E2E use case or create an issue to track this task?

@whitewindmills
Copy link
Member Author

I think it would be better to directly make modifications within the utility methods.

The number of resources may be huge, and the calling frequency of this utility function is very high. It is obviously not necessary to perform a deep copy every time we read a resource through this utility function. We only make a deep copy in a few places that need to be modified.

Furthermore, this issue indicates that we do not have an end-to-end (E2E) coverage for this scenario. If possible, could you please provide an additional E2E use case or create an issue to track this task?

good suggestion.
tracked issue: #3884

@XiShanYongYe-Chang
Copy link
Member

The number of resources may be huge, and the calling frequency of this utility function is very high. It is obviously not necessary to perform a deep copy every time we read a resource through this utility function. We only make a deep copy in a few places that need to be modified.

In this case, should we consider adding some comments in the utility func to indicate the need for attention when modifying cache issues, so as to prevent overlooking this factor when using it in new places?

@whitewindmills
Copy link
Member Author

In this case, should we consider adding some comments in the utility func to indicate the need for attention when modifying cache issues, so as to prevent overlooking this factor when using it in new places?

👍

@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 Aug 3, 2023
@whitewindmills
Copy link
Member Author

Copy link
Member

@XiShanYongYe-Chang XiShanYongYe-Chang left a comment

Choose a reason for hiding this comment

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

Thanks
/lgtm

@karmada-bot karmada-bot added the lgtm Indicates that a PR is ready to be merged. label Aug 3, 2023
for clean up policy

Signed-off-by: whitewindmills <jayfantasyhjh@gmail.com>
@karmada-bot karmada-bot added size/M Denotes a PR that changes 30-99 lines, ignoring generated files. and removed lgtm Indicates that a PR is ready to be merged. size/S Denotes a PR that changes 10-29 lines, ignoring generated files. labels Aug 3, 2023
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

@karmada-bot karmada-bot added the lgtm Indicates that a PR is ready to be merged. label Aug 3, 2023
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

@XiShanYongYe-Chang
Copy link
Member

@whitewindmills can you help update the release note? Maybe we need to cherry-pick it to the previous branch.

@whitewindmills
Copy link
Member Author

done

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.

/approve

@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 3, 2023
@karmada-bot karmada-bot merged commit e5277b6 into karmada-io:master Aug 3, 2023
12 checks passed
@whitewindmills whitewindmills deleted the detector-resource branch August 3, 2023 09:23
@whitewindmills
Copy link
Member Author

@XiShanYongYe-Chang @RainbowMango should we cherry-pick it to the previous branch?

@XiShanYongYe-Chang
Copy link
Member

@XiShanYongYe-Chang @RainbowMango should we cherry-pick it to the previous branch?

I think it is necessary.

@RainbowMango
Copy link
Member

+1

karmada-bot added a commit that referenced this pull request Aug 4, 2023
…-#3879-upstream-release-1.5

Automated cherry pick of #3879: avoid updating directly cached resource template for clean up
karmada-bot added a commit that referenced this pull request Aug 4, 2023
…-#3879-upstream-release-1.4

Automated cherry pick of #3879: avoid updating directly cached resource template for clean up
karmada-bot added a commit that referenced this pull request Aug 7, 2023
…-#3879-upstream-release-1.6

Automated cherry pick of #3879: avoid updating directly cached resource template for clean up
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/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.

Resource template cannot be reconciled again due to cache modification
6 participants