Driver should check socket parent directory before trying to bind it
@@ -87,19 +87,22 @@ func (s *nonBlockingGRPCServer) serve(endpoint string, ids csi.IdentityServer, c
if err := os.Remove(addr); err != nil && !os.IsNotExist(err) {
klog.Fatalf("Failed to remove %s, error: %s", addr, err.Error())
}
- } else if u.Scheme == "tcp" {
- addr = u.Host
- } else {
- klog.Fatalf("%v endpoint scheme not supported", u.Scheme)
- }
- if u.Scheme == "unix" {
- listenDir, _ := filepath.Split(addr)
+ listenDir := filepath.Dir(addr)
if _, err := os.Stat(listenDir); err != nil {
+ if os.IsNotExist(err) {
+ klog.Fatalf("Expected Kubelet plugin watcher to create parent dir %s but did not find such a dir", listenDir)
+ } else {
klog.Fatalf("Failed to stat %s, error: %s", listenDir, err.Error())
}
}
+ } else if u.Scheme == "tcp" {
+ addr = u.Host
+ } else {
+ klog.Fatalf("%v endpoint scheme not supported", u.Scheme)
+ }
+
klog.V(4).Infof("Start listening with scheme %v, addr %v", u.Scheme, addr)
listener, err := net.Listen(u.Scheme, addr)
if err != nil {
