-
Notifications
You must be signed in to change notification settings - Fork 1.2k
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
🐛 fix runnable run twice issue #487
🐛 fix runnable run twice issue #487
Conversation
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.
Thanks for the PR!
pkg/manager/internal.go
Outdated
@@ -347,6 +352,7 @@ func (cm *controllerManager) startLeaderElection() (err error) { | |||
RetryPeriod: cm.retryPeriod, | |||
Callbacks: leaderelection.LeaderCallbacks{ | |||
OnStartedLeading: func(_ context.Context) { | |||
cm.isLeader = true |
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.
Setting isLeader
needs to be protected by the mutex. I might suggest moving it into startLeaderElectionRunnables
and changing its name to something like startedLeader
?
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.
yeap, that makes more sense. 👍
pkg/manager/internal.go
Outdated
cm.nonLeaderElectionRunnables = append(cm.nonLeaderElectionRunnables, r) | ||
} else { | ||
shouldStart = cm.started && (cm.isLeader || cm.resourceLock == nil) |
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.
If you take the suggestion from the other comment, this could be simplified to shouldStart = cm.startedLeader
.
5e3d91f
to
e63210a
Compare
fyi #444 |
The code looks good to me, but it would be nice to see the tests pass -- even though that failure doesn't look like your fault. |
/lgtm |
@abursavich: changing LGTM is restricted to assignees, and only kubernetes-sigs/controller-runtime repo collaborators may be assigned issues. In response to this:
Instructions for interacting with me using PR comments are available here. If you have questions or suggestions related to my behavior, please file an issue against the kubernetes/test-infra repository. |
@DirectXMan12 kind ping~ |
@mengqiy @DirectXMan12 the CI is happy, kind ping~ |
/lgtm |
[APPROVALNOTIFIER] This PR is APPROVED This pull-request has been approved by: adohe, DirectXMan12 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 |
fix #478 @DirectXMan12 @abursavich ptal