-
Notifications
You must be signed in to change notification settings - Fork 39k
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
Switch statefulset controller to shared informers #41482
Switch statefulset controller to shared informers #41482
Conversation
@@ -114,28 +110,33 @@ func NewStatefulSetController(podInformer cache.SharedIndexInformer, kubeClient | |||
}, | |||
DeleteFunc: ssc.enqueueStatefulSet, | |||
}, | |||
statefulSetResyncPeriod, |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
We should be able to switch to the default resync period but probably not before adding a pvc cache ... Add a TODO
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@Kargakis do you want me to plumb in using a PVC informer now?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Not necessary I think but an issue to extend the resync period and also add the PVC informer would be nice.
@k8s-bot kubemark e2e test this, infra flake
|
@ncdc The code only mutates the StatefulSet.Status.Replicas field. The relevant code is here. The mutation is performed on a deep copy. The supplied *apps.StatefulSet parameter is treated as an inout parameter, and it is mutated, but it is only mutated when it successfully commits its current status API server. The value of the deep copy is re-assigned to the input parameter. |
Reviewed 7 of 7 files at r1. pkg/controller/statefulset/stateful_set.go, line 34 at r1 (raw file):
space between client-go and kubernetes? Comments from Reviewable |
We're still combining everything under |
@kow3ns ok, thanks. So I'll need to fix this in my PR, since the reassignment of the parameter results in changing the data in the shared cache. |
FWIW I'm probably not the right person to be assigned this PR, I'm not in any of the OWNERS files. cc'ing the approvers listed at cmd/kube-controller-manager/OWNERS |
I've added a new commit that stops mutating the stateful sets and pods retrieved from the shared informer caches. PTAL. |
@k8s-bot cvm gke e2e test this |
@@ -726,6 +915,11 @@ func scaleDownStatefulSetControl(set *apps.StatefulSet, ssc StatefulSetControlIn | |||
spc.podsIndexer.Delete(pods[ordinal]) | |||
} | |||
if err := ssc.UpdateStatefulSet(set, pods); err != nil { | |||
fmt.Printf("ANDY3: %v\n", err) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
debug output
6669ab9
to
f6dbfbd
Compare
Rebased, squashed, debugging removed |
Reviewed 2 of 4 files at r2, 3 of 4 files at r3. pkg/controller/statefulset/stateful_pod_control.go, line 38 at r3 (raw file):
Update comments to address changes made to the interface contract with respect to the mutation of the parameter. pkg/controller/statefulset/stateful_pod_control.go, line 91 at r3 (raw file):
Does this ever stop retrying. We will now have a backoff in the workqueue and here, what are the implications? pkg/controller/statefulset/stateful_set_control.go, line 103 at r3 (raw file):
Move the StatefulSet deep copy into UpdateStatefulSetReplicas or move the pod deep copy out of UpdateStatefulPod for consistency. Comments from Reviewable |
ced85b3
to
20f1a71
Compare
Updated to look up the stateful set from the cache in the event of a failed update of the set's replica count. |
You'll want to deep-copy that or you'll make @deads2k sad. Also there is a pod read call in the other retry func that can be turned into a cache lookup. I just don't know if we want to go all-in with our caches... :) |
And me too :-(. Will fix.
I'll update that too. Thanks. |
20f1a71
to
74afebf
Compare
@Kargakis updated |
@kow3ns please review the latest update when you get a chance. Thanks! |
@k8s-bot cvm gce e2e test this |
Reviewed 1 of 1 files at r7, 3 of 3 files at r8. Comments from Reviewable |
@k8s-bot cvm gce e2e test this |
74afebf
to
f6a186b
Compare
[APPROVALNOTIFIER] This PR is APPROVED The following people have approved this PR: ncdc, smarterclayton Needs approval from an approver in each of these OWNERS Files:
You can indicate your approval by writing |
Anyone have any other comments? |
@k8s-bot non-cri e2e test this |
The non-cri e2e failure looks like the recently-created #41889. I don't think it's unique to this PR. |
lgtm |
Green tests 😄 |
/lgtm |
Automatic merge from submit-queue (batch tested with PRs 41146, 41486, 41482, 41538, 41784) |
Automatic merge from submit-queue (batch tested with PRs 41714, 41510, 42052, 41918, 31515) Switch scheduler to use generated listers/informers Where possible, switch the scheduler to use generated listers and informers. There are still some places where it probably makes more sense to use one-off reflectors/informers (listing/watching just a single node, listing/watching scheduled & unscheduled pods using a field selector). I think this can wait until master is open for 1.7 pulls, given that we're close to the 1.6 freeze. After this and #41482 go in, the only code left that references legacylisters will be federation, and 1 bit in a stateful set unit test (which I'll clean up in a follow-up). @resouer I imagine this will conflict with your equivalence class work, so one of us will be doing some rebasing 😄 cc @wojtek-t @gmarek @timothysc @jayunit100 @smarterclayton @deads2k @liggitt @sttts @derekwaynecarr @kubernetes/sig-scheduling-pr-reviews @kubernetes/sig-scalability-pr-reviews
Originally part of #40097
I think the controller currently makes a deep copy of a StatefulSet before it mutates it, but I'm not 100% sure. For those who are most familiar with this code, could you please confirm?
@Beeps @smarterclayton @ingvagabund @sttts @liggitt @deads2k @kubernetes/sig-apps-pr-reviews @kubernetes/sig-scalability-pr-reviews @timothysc @gmarek @wojtek-t