-
Notifications
You must be signed in to change notification settings - Fork 334
Fix InitialBuckets()
for statefulSetBuilder's electors
#2483
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
Conversation
Some are for StatefulSet and only owns their own
Codecov Report
@@ Coverage Diff @@
## main #2483 +/- ##
==========================================
+ Coverage 81.32% 81.91% +0.59%
==========================================
Files 163 163
Lines 6499 9619 +3120
==========================================
+ Hits 5285 7879 +2594
- Misses 981 1505 +524
- Partials 233 235 +2
Continue to review full report at Codecov.
|
leaderelection/context.go
Outdated
bkt := ue.bkt | ||
if bkt == nil { | ||
bkt = reconciler.UniversalBucket() | ||
} | ||
return []reconciler.Bucket{ | ||
reconciler.UniversalBucket(), | ||
bkt, |
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.
I think you can simply return ue.bkt
since the universal bucket is configured here:
Lines 101 to 109 in 8db11d0
return &unopposedElector{ | |
la: la, | |
bkt: reconciler.UniversalBucket(), | |
// The UniversalBucket owns everything, so there is never a need to | |
// enqueue things (no possible state change). We pass nil here to | |
// avoid filling the queue for an extra resynce at startup along | |
// this path. | |
enq: nil, | |
}, nil |
One thing to note - Promote is called twice
Here when the initial buckets are seeded. It uses a nil
enq function since we're not processing items yet and don't need to re-enqueue stuff.
Lines 471 to 477 in 8db11d0
if ib, ok := le.(kle.ElectorWithInitialBuckets); ok { | |
for _, b := range ib.InitialBuckets() { | |
// No need to provide an enq function since the controller | |
// is not processing items | |
la.Promote(b, nil) | |
} | |
} |
The other promote happens during the Run() call
Lines 269 to 272 in 8db11d0
// Run implements Elector | |
func (ue *unopposedElector) Run(ctx context.Context) { | |
ue.la.Promote(ue.bkt, ue.enq) | |
} |
I was thinking of dropping this but it changes the behaviour of this package - ie. clients need to know to call Promote themselves.
The notable thing about this promote it pass the enq function - so I'm unsure if this has side effects for statefulset electors
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.
I see, we could dedup simply by checking if the enq
is nil
in RunContext()
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.
I’m not super concerned about multiple promotions if there aren’t enq side effects. Another alternative is my original suggestion to call Promote immediately on the code path where we use the unopposed elector with the universal bucket.
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.
Ok based on what you both say here I am going to simplify the InitialBuckets()
func as recommended and let 2x la.Promote()
be since there is no side-effect.
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.
Another alternative is my original suggestion to call Promote immediately on the code path where we use the unopposed elector with the universal bucket.
Yeah - I didn't do it this way because promoting a bucket during the elector build
seemed like a weird side-effect.
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.
I'm not sure when the original bug went in, but if there's been a release cut since, well, even without it, I'd suggest adding a release note.
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.
@vaikas no there hasn't been a release cut since then. release cut is next week :)
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.
@dprotaso I simplified the InitialBuckets()
func as suggested.
/lgtm |
[APPROVALNOTIFIER] This PR is APPROVED This pull-request has been approved by: dprotaso, tcnghia 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 |
Tekton uses a version of knative/pkg in between a regression on the HA via StatefulSet and its fix. Cherry-pick the patch for a minor release. We shall pick-up a newer version of knative/pkg for the next major release instead. Original Knative PR: knative/pkg#2483 Tekton Issue: tektoncd#3404 Signed-off-by: Andrea Frittoli <andrea.frittoli@uk.ibm.com>
Tekton uses a version of knative/pkg in between a regression on the HA via StatefulSet and its fix. Cherry-pick the patch for a minor release. We shall pick-up a newer version of knative/pkg for the next major release instead. Original Knative PR: knative/pkg#2483 Tekton Issue: #3404 Signed-off-by: Andrea Frittoli <andrea.frittoli@uk.ibm.com>
Changes
statefulSetBuilder
's electors get promote to own the universal bucket.Release Note
Docs