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: SidecarSet Expectations Leakage Bug #1301

Merged
merged 4 commits into from Jun 1, 2023

Conversation

wangwu50
Copy link
Contributor

fix sidecarSet expectations leakage bug when delete pod alfter update sidecarset

@kruise-bot kruise-bot requested review from Fei-Guo and zmberg May 29, 2023 06:37
@kruise-bot
Copy link

Welcome @wangwu50! It looks like this is your first PR to openkruise/kruise 🎉

@kruise-bot kruise-bot added the size/L size/L: 100-499 label May 29, 2023
@wangwu50
Copy link
Contributor Author

fixes #1293

@@ -115,9 +112,8 @@ var _ reconcile.Reconciler = &ReconcileSidecarSet{}
// ReconcileSidecarSet reconciles a SidecarSet object
type ReconcileSidecarSet struct {
client.Client
scheme *runtime.Scheme
updateExpectations expectations.UpdateExpectations
Copy link
Member

Choose a reason for hiding this comment

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

Why did you remove this filed? My understanding of the previous bug had nothing to do with this field being defined here, right?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Only updateExpectations were removed because they were initialized in utils

Copy link
Contributor Author

Choose a reason for hiding this comment

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

A utils is added so that the sidecarset handler can access it, similar to how cloneset handles it

Copy link
Member

Choose a reason for hiding this comment

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

Copy link
Contributor Author

Choose a reason for hiding this comment

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

OK, I've moved it

@codecov-commenter
Copy link

codecov-commenter commented May 29, 2023

Codecov Report

Merging #1301 (dbb13ee) into master (95e42f3) will decrease coverage by 0.03%.
The diff coverage is 59.09%.

❗ 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    #1301      +/-   ##
==========================================
- Coverage   48.60%   48.57%   -0.03%     
==========================================
  Files         151      151              
  Lines       21005    21042      +37     
==========================================
+ Hits        10210    10222      +12     
- Misses       9680     9702      +22     
- Partials     1115     1118       +3     
Flag Coverage Δ
unittests 48.57% <59.09%> (-0.03%) ⬇️

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

Impacted Files Coverage Δ
pkg/control/sidecarcontrol/util.go 53.48% <ø> (ø)
pkg/controller/sidecarset/sidecarset_controller.go 15.38% <0.00%> (+0.29%) ⬆️
...troller/sidecarset/sidecarset_pod_event_handler.go 63.63% <53.33%> (-1.46%) ⬇️
pkg/controller/sidecarset/sidecarset_processor.go 68.67% <83.33%> (+0.06%) ⬆️

... and 6 files with indirect coverage changes

📣 We’re building smart automated test selection to slash your CI/CD build times. Learn more

@@ -82,6 +102,9 @@ func (p *enqueueRequestForPod) updatePod(q workqueue.RateLimitingInterface, old,
if sidecarSet.Spec.UpdateStrategy.Type == appsv1alpha1.NotUpdateSidecarSetStrategyType {
continue
}
if newPod.DeletionTimestamp != nil {
Copy link
Member

Choose a reason for hiding this comment

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

I think you should not judge the deletionTimestamp, and use the ObserveUpdated function.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

ObserveUpdated does not determine if the pod is deleted if the pod is pending deletion

Copy link
Contributor Author

Choose a reason for hiding this comment

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

If this pod is an older version, there may be problems

@@ -57,6 +74,9 @@ func (p *enqueueRequestForPod) addPod(q workqueue.RateLimitingInterface, obj run
}

for _, sidecarSet := range sidecarSets {
if pod.DeletionTimestamp != nil {
Copy link
Member

Choose a reason for hiding this comment

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

I think it is not necessary to execute the expectation function when add pod.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

on a restart of the controller manager, it's possible a new pod shows up in a state that is already pending deletion. Prevent the pod from being a creation observation.

@wangwu50 wangwu50 force-pushed the fix/sidecarset_expectations branch from 5f868e5 to 503a149 Compare May 30, 2023 04:03
wangwu50 and others added 3 commits May 30, 2023 16:03
Signed-off-by: wangwenchao7 <wangwenchao7@xiaomi.com>
Signed-off-by: wangwenchao7 <wangwenchao7@xiaomi.com>
Signed-off-by: wangwenchao7 <wangwenchao7@xiaomi.com>
@wangwu50 wangwu50 force-pushed the fix/sidecarset_expectations branch from 7a9a37e to 79bd334 Compare May 30, 2023 08:03
@zmberg
Copy link
Member

zmberg commented May 30, 2023

/lgtm

Copy link
Member

@furykerry furykerry left a comment

Choose a reason for hiding this comment

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

/lgtm

Signed-off-by: wangwenchao7 <wangwenchao7@xiaomi.com>
@kruise-bot kruise-bot removed the lgtm label May 30, 2023
@veophi
Copy link
Member

veophi commented May 30, 2023

/lgtm

@zmberg
Copy link
Member

zmberg commented Jun 1, 2023

/approve

@kruise-bot
Copy link

[APPROVALNOTIFIER] This PR is APPROVED

This pull-request has been approved by: zmberg

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

@kruise-bot kruise-bot merged commit b7977a7 into openkruise:master Jun 1, 2023
24 checks passed
diannaowa pushed a commit to diannaowa/kruise that referenced this pull request Jun 2, 2023
* fix: SidecarSet Expectations Leakage Bug

Signed-off-by: wangwenchao7 <wangwenchao7@xiaomi.com>

* fix: Modify the code as suggested

Signed-off-by: wangwenchao7 <wangwenchao7@xiaomi.com>

* fix: use ObserveUpdated func when update

Signed-off-by: wangwenchao7 <wangwenchao7@xiaomi.com>

* fix: observeUpdated before type check
Signed-off-by: wangwenchao7 <wangwenchao7@xiaomi.com>

---------

Signed-off-by: wangwenchao7 <wangwenchao7@xiaomi.com>
Co-authored-by: wangwenchao7 <wangwenchao7@xiaomi.com>
diannaowa pushed a commit to diannaowa/kruise that referenced this pull request Jun 2, 2023
* fix: SidecarSet Expectations Leakage Bug

Signed-off-by: wangwenchao7 <wangwenchao7@xiaomi.com>

* fix: Modify the code as suggested

Signed-off-by: wangwenchao7 <wangwenchao7@xiaomi.com>

* fix: use ObserveUpdated func when update

Signed-off-by: wangwenchao7 <wangwenchao7@xiaomi.com>

* fix: observeUpdated before type check
Signed-off-by: wangwenchao7 <wangwenchao7@xiaomi.com>

---------

Signed-off-by: wangwenchao7 <wangwenchao7@xiaomi.com>
Co-authored-by: wangwenchao7 <wangwenchao7@xiaomi.com>
diannaowa pushed a commit to diannaowa/kruise that referenced this pull request Aug 29, 2023
* fix: SidecarSet Expectations Leakage Bug

Signed-off-by: wangwenchao7 <wangwenchao7@xiaomi.com>

* fix: Modify the code as suggested

Signed-off-by: wangwenchao7 <wangwenchao7@xiaomi.com>

* fix: use ObserveUpdated func when update

Signed-off-by: wangwenchao7 <wangwenchao7@xiaomi.com>

* fix: observeUpdated before type check
Signed-off-by: wangwenchao7 <wangwenchao7@xiaomi.com>

---------

Signed-off-by: wangwenchao7 <wangwenchao7@xiaomi.com>
Co-authored-by: wangwenchao7 <wangwenchao7@xiaomi.com>
lilongfeng0902 pushed a commit to lilongfeng0902/kruise that referenced this pull request Sep 12, 2023
* fix: SidecarSet Expectations Leakage Bug

Signed-off-by: wangwenchao7 <wangwenchao7@xiaomi.com>

* fix: Modify the code as suggested

Signed-off-by: wangwenchao7 <wangwenchao7@xiaomi.com>

* fix: use ObserveUpdated func when update

Signed-off-by: wangwenchao7 <wangwenchao7@xiaomi.com>

* fix: observeUpdated before type check
Signed-off-by: wangwenchao7 <wangwenchao7@xiaomi.com>

---------

Signed-off-by: wangwenchao7 <wangwenchao7@xiaomi.com>
Co-authored-by: wangwenchao7 <wangwenchao7@xiaomi.com>
ppbits pushed a commit to ppbits/kruise that referenced this pull request Apr 4, 2024
* fix: SidecarSet Expectations Leakage Bug


* fix: Modify the code as suggested


* fix: use ObserveUpdated func when update


* fix: observeUpdated before type check

---------

Co-authored-by: wangwenchao7 <wangwenchao7@xiaomi.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

6 participants