-
Notifications
You must be signed in to change notification settings - Fork 157
Ensure reg.sock exists while the registrar is running #60
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -21,6 +21,7 @@ import ( | |
| "net" | ||
| "os" | ||
| "runtime" | ||
| "time" | ||
|
|
||
| "google.golang.org/grpc" | ||
|
|
||
|
|
@@ -36,6 +37,15 @@ func nodeRegister( | |
| // pluginswatcher infrastructure. Node labeling is done by kubelet's csi code. | ||
| registrar := newRegistrationServer(csiDriverName, *kubeletRegistrationPath, supportedVersions) | ||
| socketPath := fmt.Sprintf("/registration/%s-reg.sock", csiDriverName) | ||
|
|
||
| ticker := time.NewTicker(5 * time.Second) | ||
| for { | ||
| <-ticker.C | ||
| go periodicallyCheck(socketPath, registrar) | ||
| } | ||
| } | ||
|
|
||
| func periodicallyCheck(socketPath string, registrar registerapi.RegistrationServer) { | ||
|
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. This function can be called something like "reconcileSocket", to be more descriptive of what it does. |
||
| fi, err := os.Stat(socketPath) | ||
| if err == nil && (fi.Mode()&os.ModeSocket) != 0 { | ||
| // Remove any socket, stale or not, but fall through for other files | ||
|
|
@@ -44,6 +54,12 @@ func nodeRegister( | |
| os.Exit(1) | ||
| } | ||
| } | ||
|
|
||
| if err == nil && (fi.Mode()&os.ModeSocket) == 0 { | ||
|
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. if |
||
| // If listening | ||
| os.Exit(0) | ||
| } | ||
|
|
||
| if err != nil && !os.IsNotExist(err) { | ||
| klog.Errorf("failed to stat the socket %s with error: %+v", socketPath, err) | ||
| os.Exit(1) | ||
|
|
@@ -64,6 +80,7 @@ func nodeRegister( | |
| if runtime.GOOS == "linux" { | ||
| umask(oldmask) | ||
| } | ||
|
|
||
| klog.Infof("Registration Server started at: %s\n", socketPath) | ||
| grpcServer := grpc.NewServer() | ||
| // Registers kubelet plugin watcher api. | ||
|
|
||
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Do we need to spawn a new goroutine? Is there ever a case where reconciling the socket could take a long time?