Skip to content

fix: both atelet and ate-apiserver leak gRPC connections#480

Open
Eric Bishop (ericdbishop) wants to merge 4 commits into
agent-substrate:mainfrom
ericdbishop:conn-leak-fix
Open

fix: both atelet and ate-apiserver leak gRPC connections#480
Eric Bishop (ericdbishop) wants to merge 4 commits into
agent-substrate:mainfrom
ericdbishop:conn-leak-fix

Conversation

@ericdbishop

@ericdbishop Eric Bishop (ericdbishop) commented Jul 21, 2026

Copy link
Copy Markdown
Contributor

Fixes #470

  • Tests pass
  • Appropriate changes to documentation are included in the PR

Gen AI disclosure: Just used for adversarial review.

Comment thread cmd/atelet/main.go Outdated
if ok {
conn.Close()
}
}),

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The 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.

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The 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?

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The 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.

Comment thread cmd/atelet/main.go Outdated

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Would be nice to have a test to confirm that the connections don't leak anymore

ateletConns: lru.New(1024),
ateletConns: lru.NewWithEvictionFunc(1024, func(key lru.Key, value any) {
// Close connection when evicting from cache.
conn, ok := value.(*grpc.ClientConn)

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?

Comment thread cmd/atelet/main.go
return out
}

// AteomDialer handles gRPC connections to Ateom pods.

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Do we really need this comment?

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The 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.

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

No worries just curious

Signed-off-by: Eric Bishop <ericbish.dev@gmail.com>
Signed-off-by: Eric Bishop <ericbish.dev@gmail.com>
Signed-off-by: Eric Bishop <ericbish.dev@gmail.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Both atelet and ate-apiserver leak gRPC connections

3 participants