-
Notifications
You must be signed in to change notification settings - Fork 1.1k
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
[WIP] 🐛 Avoid deadlock on start #1689
[WIP] 🐛 Avoid deadlock on start #1689
Conversation
[APPROVALNOTIFIER] This PR is NOT APPROVED This pull-request has been approved by: fabriziopandini The full list of commands accepted by this bot can be found here.
Needs approval from an approver in each of these files:
Approvers can indicate their approval by writing |
pkg/manager/internal.go
Outdated
@@ -535,8 +550,11 @@ func (cm *controllerManager) engageStopProcedure(stopComplete <-chan struct{}) e | |||
if cm.gracefulShutdownTimeout == 0 { | |||
return nil | |||
} | |||
cm.mu.Lock() | |||
defer cm.mu.Unlock() | |||
cm.addMu.RLock() |
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.
I think this needs to be the WriteLock
, because it writes to cm.stopProcedureEngaged
.
Also it seems it is not allowed to call waitgroup.Add()
during a running waitgroup.Wait()
, if I understand the race in CI correctly. Unfortunately you get to debug the locking here now 🙃
@fabriziopandini: The following test failed, say
Full PR test history. Your PR dashboard. Please help us cut down on flakes by linking to an open issue when you hit one in your PR. 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. I understand the commands that are listed here. |
If there are no objections, I would close this PR in favour of #1690 |
/close |
@fabriziopandini: Closed this PR. 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. |
This PR tries to avoid deadlock in the start sequence when
startLeaderElectionRunnables()
gets stuck inwaitForCache
, but the cache can't start due the webhook not yet started, and the webhook with are run instartNonLeaderElectionRunnables()
can't run due to to the mutex.The implementation follow the suggestion in #1685 (comment) and:
startLeaderElectionRunnables()
andstartNonLeaderElectionRunnables()
and for other serve func thus allowing parallel runwaitForCache
to be executed two times concurrentlyNote. Given this is my first PR in this area, I have commented all the reasoning about locks and possible concurrency issues, looking forward for comments.