Skip to content

Commit 1895e67

Browse files
authored
Merge pull request #1957 from k8s-infra-cherrypick-robot/cherry-pick-1951-to-release-1.24
[release-1.24] fix: grpc connection was not closed properly
2 parents 40cd83a + 6bcb7b4 commit 1895e67

File tree

1 file changed

+21
-12
lines changed

1 file changed

+21
-12
lines changed

pkg/blob/nodeserver.go

Lines changed: 21 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -165,20 +165,29 @@ func (d *Driver) mountBlobfuseWithProxy(args, protocol string, authEnv []string)
165165
defer cancel()
166166
klog.V(2).Infof("start connecting to blobfuse proxy, protocol: %s, args: %s", protocol, args)
167167
conn, err := grpc.DialContext(ctx, d.blobfuseProxyEndpoint, grpc.WithInsecure(), grpc.WithBlock())
168-
if err == nil {
169-
mountClient := NewMountClient(conn)
170-
mountreq := mount_azure_blob.MountAzureBlobRequest{
171-
MountArgs: args,
172-
Protocol: protocol,
173-
AuthEnv: authEnv,
174-
}
175-
klog.V(2).Infof("begin to mount with blobfuse proxy, protocol: %s, args: %s", protocol, args)
176-
resp, err = mountClient.service.MountAzureBlob(context.TODO(), &mountreq)
177-
if err != nil {
178-
klog.Error("GRPC call returned with an error:", err)
168+
if err != nil {
169+
klog.Errorf("failed to connect to blobfuse proxy: %v", err)
170+
return "", err
171+
}
172+
defer func() {
173+
if err := conn.Close(); err != nil {
174+
klog.Errorf("failed to close connection to blobfuse proxy: %v", err)
179175
}
180-
output = resp.GetOutput()
176+
}()
177+
178+
mountClient := NewMountClient(conn)
179+
mountreq := mount_azure_blob.MountAzureBlobRequest{
180+
MountArgs: args,
181+
Protocol: protocol,
182+
AuthEnv: authEnv,
183+
}
184+
klog.V(2).Infof("begin to mount with blobfuse proxy, protocol: %s, args: %s", protocol, args)
185+
resp, err = mountClient.service.MountAzureBlob(context.TODO(), &mountreq)
186+
if err != nil {
187+
klog.Error("GRPC call returned with an error:", err)
181188
}
189+
output = resp.GetOutput()
190+
182191
return output, err
183192
}
184193

0 commit comments

Comments
 (0)