This repository was archived by the owner on Mar 20, 2026. It is now read-only.
fix: multi controller run concurrently after leadership lost - #2309
Merged
Conversation
Member
|
Why would you manually make another operator leader? |
Contributor
Author
|
@harshavardhana, that's to simulate an unstable k8s apiserver. |
Contributor
Author
|
I believe the leadership changes happen frequently when the Kubernetes API server is unstable. This has occurred a few times in my environment. @harshavardhana |
pjuarezd
force-pushed
the
fix-multi-replica
branch
from
September 6, 2024 02:09
3d21c92 to
33c0531
Compare
pjuarezd
requested review from
dvaldivia,
harshavardhana,
jiuker and
pjuarezd
September 6, 2024 02:10
pjuarezd
approved these changes
Sep 6, 2024
* stop sync handler and queue when no longer leader
* bugfix: `for select` was trying to evaluate if the upgrade and sts webservers had an error (which is not, is just leader lost) and need to restart, resulted in NPE.
```
goroutine 30 [running]:
github.com/minio/operator/pkg/controller.leaderRun({0x1f1ec28, 0x4000a8a370}, 0x4000958b00, 0x2, 0x40005b4380, 0x40005b4ee0)
github.com/minio/operator/pkg/controller/main-controller.go:495 +0x6c4
github.com/minio/operator/pkg/controller.(*Controller).Start.func2({0x1f1ec28?, 0x4000a8a370?})
github.com/minio/operator/pkg/controller/main-controller.go:584 +0x34
created by k8s.io/client-go/tools/leaderelection.(*LeaderElector).Run in goroutine 1
k8s.io/client-go@v0.30.2/tools/leaderelection/leaderelection.go:213 +0xe4
Stream closed EOF for minio-operator/minio-operator-787db96fd4-cfd4b (minio-operator)
```
Signed-off-by: pjuarezd <pjuarezd@users.noreply.github.com>
lint: we don't need an additional method called shutdown to invoke SIGTERM
Signed-off-by: pjuarezd <pjuarezd@users.noreply.github.com>
pjuarezd
force-pushed
the
fix-multi-replica
branch
from
September 11, 2024 06:23
33c0531 to
98f7ee0
Compare
pjuarezd
approved these changes
Sep 11, 2024
harshavardhana
approved these changes
Sep 11, 2024
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to subscribe to this conversation on GitHub.
Already have an account?
Sign in.
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Reproduction Steps:
At this point, the logs for minio-operator-1 show the following:

The main-controller continues to run even after losing leadership.
After the PR
Follow the same steps as above.
Now, the logs for minio-operator-1 show the following:

minio-operator-1 stops and exits. If we run it in Kubernetes, the container will restart and attempt to acquire the lease. It will then detect that minio-operator-2 has become the leader and will remain inactive with no controller running. That's what we want.