From bbf32e0f1cc58723715ecd43e1085d82cef8a8b1 Mon Sep 17 00:00:00 2001 From: Eric Weber Date: Thu, 8 Aug 2024 14:59:26 +0000 Subject: [PATCH] fix(datconn): don't orphan client goroutine when remote is closed Longhorn 8711 Signed-off-by: Eric Weber --- pkg/backend/remote/remote.go | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/pkg/backend/remote/remote.go b/pkg/backend/remote/remote.go index e39a6f28e..a594c94b5 100644 --- a/pkg/backend/remote/remote.go +++ b/pkg/backend/remote/remote.go @@ -51,6 +51,12 @@ type Remote struct { func (r *Remote) Close() error { logrus.Infof("Closing: %s", r.name) + + // Close the dataconn client to avoid orphaning goroutines. + if dataconnClient, ok := r.ReaderWriterUnmapperAt.(*dataconn.Client); ok { + dataconnClient.Close() + } + conn, err := grpc.NewClient(r.replicaServiceURL, grpc.WithTransportCredentials(insecure.NewCredentials()), interceptor.WithIdentityValidationClientInterceptor(r.volumeName, "")) if err != nil {