Fix `InitialBuckets()` for statefulSetBuilder's electors (#2483)

* Not all unoppossedElector has universal bucket

Some are for StatefulSet and only owns their own

* Avoid comparing pointers which may be flaky

* Address PR feedback
This commit is contained in:
Nghia Tran 2022-04-07 09:45:44 -07:00 committed by GitHub
parent 8db11d0f9f
commit 29f716f18b
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 6 additions and 4 deletions

View File

@ -273,7 +273,7 @@ func (ue *unopposedElector) Run(ctx context.Context) {
func (ue *unopposedElector) InitialBuckets() []reconciler.Bucket {
return []reconciler.Bucket{
reconciler.UniversalBucket(),
ue.bkt,
}
}

View File

@ -384,8 +384,10 @@ func TestStandardBucketName(t *testing.T) {
}
func TestUnopposedElectorInitialBucket(t *testing.T) {
u := &unopposedElector{}
if u.InitialBuckets()[0] != reconciler.UniversalBucket() {
t.Errorf("expected the unopposedElector to return the universal bucket")
u := &unopposedElector{
bkt: reconciler.UniversalBucket(),
}
if diff := cmp.Diff(u.InitialBuckets(), []reconciler.Bucket{reconciler.UniversalBucket()}); diff != "" {
t.Errorf("unexpected u.InitialBuckets() (-want,+got): %s", diff)
}
}