8000 Fix `InitialBuckets()` for statefulSetBuilder's electors by tcnghia · Pull Request #2483 · knative/pkg · GitHub
[go: up one dir, main page]
More Web Proxy on the site http://driver.im/
Skip to content

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

Merged
merged 3 commits into from
Apr 7, 2022

Conversation

tcnghia
Copy link
Contributor
@tcnghia tcnghia commented Apr 7, 2022

Changes

  • 🐛 Fix the bug where all statefulSetBuilder's electors get promote to own the universal bucket.

Release Note

NONE

Docs

NONE

Some are for StatefulSet and only owns their own
@knative-prow knative-prow bot added size/XS Denotes a PR that changes 0-9 lines, ignoring generated files. approved Indicates a PR has been approved by an approver from all required OWNERS files. labels Apr 7, 2022
@knative-prow knative-prow 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 Apr 7, 2022
@codecov
Copy link
codecov bot commented Apr 7, 2022

Codecov Report

Merging #2483 (732e24c) into main (c2f1f3e) will increase coverage by 0.59%.
The diff coverage is 100.00%.

@@            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     
Impacted Files Coverage Δ
leaderelection/context.go 90.12% <100.00%> (-2.06%) ⬇️
webhook/certificates/resources/secret.go 81.25% <0.00%> (-4.47%) ⬇️
injection/informers.go 64.70% <0.00%> (-4.05%) ⬇️
metrics/workqueue.go 80.82% <0.00%> (-2.90%) ⬇️
apis/duck/v1alpha1/binding_types.go 90.47% <0.00%> (-2.86%) ⬇️
metrics/config.go 75.55% <0.00%> (-2.80%) ⬇️
webhook/certificates/resources/certs.go 58.92% <0.00%> (-2.70%) ⬇️
configmap/hash-gen/main.go 62.96% <0.00%> (-2.50%) ⬇️
apis/duck/v1/podspec_types.go 93.10% <0.00%> (-2.14%) ⬇️
... and 154 more

Continue to review full report at Codecov.

Legend - Click here to learn more
Δ = absolute <relative> (impact), ø = not affected, ? = missing data
Powered by Codecov. Last update dcd5d7c...732e24c. Read the comment docs.

Comment on lines 275 to 280
bkt := ue.bkt
if bkt == nil {
bkt = reconciler.UniversalBucket()
}
return []reconciler.Bucket{
reconciler.UniversalBucket(),
bkt,
Copy link
Member
@dprotaso dprotaso Apr 7, 2022

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:

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.

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

// 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

Copy link
Contributor Author

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()

Copy link
Member

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.

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 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.

Copy link
Member

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.

Copy link
Contributor

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.

Copy link
Contributor Author

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 :)

Copy link
Contributor Author

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.

@dprotaso
Copy link
Member
dprotaso commented Apr 7, 2022

/lgtm
/approve

@knative-prow knative-prow bot added the lgtm Indicates that a PR is ready to be merged. label Apr 7, 2022
@knative-prow
Copy link
knative-prow bot commented Apr 7, 2022

[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 /approve in a comment
Approvers can cancel approval by writing /approve cancel in a comment

@knative-prow knative-prow bot merged commit 29f716f into knative:main Apr 7, 2022
afrittoli added a commit to afrittoli/pipeline that referenced this pull request May 12, 2022
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-robot pushed a commit to tektoncd/pipeline that referenced this pull request May 12, 2022
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>
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. lgtm Indicates that a PR is ready to be merged. size/S Denotes a PR that changes 10-29 lines, ignoring generated files.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants
0