Skip to content

Commit d6ac89c

Browse files
committed
bugfix-222 Driver should check socket parent directory before trying to bind it
1 parent ba2ada3 commit d6ac89c

File tree

1 file changed

+8
-0
lines changed

1 file changed

+8
-0
lines changed

pkg/gce-pd-csi-driver/server.go

+8
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,7 @@ import (
1818
"net"
1919
"net/url"
2020
"os"
21+
"path/filepath"
2122
"sync"
2223

2324
"google.golang.org/grpc"
@@ -92,6 +93,13 @@ func (s *nonBlockingGRPCServer) serve(endpoint string, ids csi.IdentityServer, c
9293
klog.Fatalf("%v endpoint scheme not supported", u.Scheme)
9394
}
9495

96+
if u.Scheme == "unix" {
97+
listenDir, _ := filepath.Split(addr)
98+
if _, err := os.Stat(listenDir); err != nil {
99+
klog.Fatalf("Failed to stat %s, error: %s", listenDir, err.Error())
100+
}
101+
}
102+
95103
klog.V(4).Infof("Start listening with scheme %v, addr %v", u.Scheme, addr)
96104
listener, err := net.Listen(u.Scheme, addr)
97105
if err != nil {

0 commit comments

Comments
 (0)