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.
The leader lost was not being invoked properly, by moving
leaderelection.RunOrDie
out of a goroutine will ensure that a new leader is elected as soon as the existing leader pod exits, making any Operator restarts snappier.You can confirm that the Leader lost was not being reported by Operator on SIGTERM because the log line
leader lost: minio-operator-<pod id>
was not printed, ergoOnStoppedLeading
was not invoked.https://github.com/minio/operator/blob/37194d9ad52edae98f2c3ec3295cf916c113ac73/pkg/controller/main-controller.go#L600C5-L603
Now, by waiting for the
RunOrDie
to exit we can guarantee theOnStoppedLeading
is executed, the Operator logs show the log message to confirm it, and more important, a new leader is elected in matter of seconds instead of having to wait for the lease to expire.Example output: