-
Notifications
You must be signed in to change notification settings - Fork 160
fix: both atelet and ate-apiserver leak gRPC connections #480
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
base: main
Are you sure you want to change the base?
Changes from 1 commit
5b11a10
7ec609e
ea71d91
6a05325
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -102,7 +102,13 @@ func main() { | |
| go serverboot.StartMetricsServer(ctx, serverboot.MetricsServerOptions{Addr: *metricsListenAddr}) | ||
|
|
||
| ateomDialer := &AteomDialer{ | ||
| conns: lru.New(256), | ||
| conns: lru.NewWithEvictionFunc(256, func(key lru.Key, value any) { | ||
| // Close connection when evicting from cache. | ||
| conn, ok := value.(*grpc.ClientConn) | ||
| if ok { | ||
| conn.Close() | ||
|
ericdbishop marked this conversation as resolved.
Outdated
|
||
| } | ||
| }), | ||
|
Contributor
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Assuming this looks ok, not sure if there is a common util file I could move this function to so it's not duplicated across files.
Collaborator
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. If we blindly close on eviction, can this close a connection which is already in use?
Contributor
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Yes, how long lived are these connections? Maybe a delayed close might help? I also was considering if we should make the cache size configurable for both dialers. |
||
| } | ||
|
|
||
| var gcpRegistryAuthn authn.Authenticator | ||
|
|
@@ -806,6 +812,7 @@ func toAteomReadyz(in *ateletpb.Readyz) *ateompb.Readyz { | |
| return out | ||
| } | ||
|
|
||
| // AteomDialer handles gRPC connections to Ateom pods. | ||
|
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Do we really need this comment?
Contributor
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I had just seen a similar comment in the ateapi file: https://github.com/ericdbishop/substrate/blob/5b11a10073e97f0c425bb7bee23955b2d5762dc3/cmd/ateapi/internal/controlapi/dialer.go#L31. I could remove it if preferred. There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. No worries just curious |
||
| type AteomDialer struct { | ||
| conns *lru.Cache | ||
| } | ||
|
|
||
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.
nit: should we log when either the assertion or Close() fails?