Skip to content

fix: reuse healthy connections in CSIAddonsNode reconciler#1022

Open
black-dragon74 wants to merge 1 commit intocsi-addons:mainfrom
black-dragon74:reuse-conn
Open

fix: reuse healthy connections in CSIAddonsNode reconciler#1022
black-dragon74 wants to merge 1 commit intocsi-addons:mainfrom
black-dragon74:reuse-conn

Conversation

@black-dragon74
Copy link
Copy Markdown
Member

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.

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>
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)
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

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.

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

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

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 :)

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.

2 participants