fix: reuse healthy connections in CSIAddonsNode reconciler#1022
Open
black-dragon74 wants to merge 1 commit intocsi-addons:mainfrom
Open
fix: reuse healthy connections in CSIAddonsNode reconciler#1022black-dragon74 wants to merge 1 commit intocsi-addons:mainfrom
black-dragon74 wants to merge 1 commit intocsi-addons:mainfrom
Conversation
The reconciler created a new gRPC connection on every requeue(1hr) closing the existing one via ConnPool.Put(). This disrupted sidecars using that connect with ExitOnConnectionLoss causing restarts. This patches fixes the issue by ensuring that a new connection is only created when the pool has no entry, the endpoint changed, or the existing connection is unhealthy. Signed-off-by: Niraj Yadav <niryadav@redhat.com>
nixpanic
reviewed
Apr 16, 2026
| logger.Info("Connecting to sidecar") | ||
| newConn, err := connection.NewConnection(ctx, endPoint, nodeID, driverName, csiAddonsNode.Namespace, csiAddonsNode.Name, r.EnableAuth) | ||
| // Check if we already have a connection for this endpoint | ||
| newConn := r.ConnPool.GetByKey(key) |
Member
There was a problem hiding this comment.
is there a good reason to do all the connection handling here, and not immediately in connection.NewConnection()? That could return an existing connection in case it is healthy. It feels cleaner to do all the connection checking inside the connection package.
Member
Author
There was a problem hiding this comment.
I thought of it initially but then NewConnection becomes misleading as it should always return a "new" connection, created from the scratch?
Moreover, this quirk is specific to CSIAddonsNode reconciler.
I am happy to move things around if required :)
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
The reconciler created a new gRPC connection on every requeue(1hr) closing the existing one via ConnPool.Put().
This disrupted sidecars using that connect with ExitOnConnectionLoss causing restarts.
This patches fixes the issue by ensuring that a new connection is only created when the pool has no entry, the endpoint changed, or the existing connection is unhealthy.