From 54d04041ab1242de4fe335ff8a36bdce03a4c5a3 Mon Sep 17 00:00:00 2001 From: zhucan Date: Mon, 16 Dec 2019 11:38:13 +0800 Subject: [PATCH] Ensure reg.sock exists while the registrar is running Signed-off-by: zhuc --- cmd/csi-node-driver-registrar/node_register.go | 14 +++++++++++--- 1 file changed, 11 insertions(+), 3 deletions(-) diff --git a/cmd/csi-node-driver-registrar/node_register.go b/cmd/csi-node-driver-registrar/node_register.go index 47efd349a..9c8d92e52 100644 --- a/cmd/csi-node-driver-registrar/node_register.go +++ b/cmd/csi-node-driver-registrar/node_register.go @@ -44,9 +44,17 @@ func nodeRegister( os.Exit(1) } } - if err != nil && !os.IsNotExist(err) { - klog.Errorf("failed to stat the socket %s with error: %+v", socketPath, err) - os.Exit(1) + + if err != nil { + if !os.IsNotExist(err) { + klog.Errorf("failed to stat the socket %s with error: %+v", socketPath, err) + os.Exit(1) + } else { + if _, err := os.Create(socketPath); err != nil { + klog.Errorf("failed to create the socket %s with error: %+v", socketPath, err) + os.Exit(1) + } + } } var oldmask int