-
Notifications
You must be signed in to change notification settings - Fork 369
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 panic when updating the envoy-gateway-config configMap #5066
base: main
Are you sure you want to change the base?
Conversation
75c7eed
to
72475f4
Compare
Codecov ReportAttention: Patch coverage is
Additional details and impacted files@@ Coverage Diff @@
## main #5066 +/- ##
==========================================
+ Coverage 66.79% 66.89% +0.09%
==========================================
Files 211 211
Lines 32928 32932 +4
==========================================
+ Hits 21995 22029 +34
+ Misses 9601 9580 -21
+ Partials 1332 1323 -9 ☔ View full report in Codecov by Sentry. |
e1c233c
to
7dcfe0f
Compare
d9edb07
to
36b31e2
Compare
Signed-off-by: Huabing Zhao <[email protected]>
@@ -128,6 +128,10 @@ func getConfigByPath(cfgPath string) (*config.Server, error) { | |||
// setupRunners starts all the runners required for the Envoy Gateway to | |||
// fulfill its tasks. | |||
func setupRunners(ctx context.Context, cfg *config.Server) (err error) { | |||
// The Elected channel is used to block the tasks that are waiting for the leader to be elected. | |||
// It will be closed once the leader is elected in the controller manager. | |||
cfg.Elected = make(chan struct{}) |
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.
we cannot use one channel to block multiple threads (status updater and infra runner)
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.
The channel is closed after an EG instance is elected, so all the blocked threads will be notified.
@zhaohuabing can you help explain why can't we use a waitgroup anymore ? |
A Using a channel allows the blocked goroutines select on both the |
thanks for the explaination @zhaohuabing , can we achieve the same by
cc @zirain |
There will be two issues in this approach:
Goroutine leaks. Channel is a common approach for blocking multiple goroutines while they wait for a signal. This allows these goroutines to exit gracefully when the associated context is canceled. The k8s controller manager also uses a similar approach to broadcast the |
Fixes #5065
Release Notes: Yes