-
Notifications
You must be signed in to change notification settings - Fork 231
Let the OpenshiftControllerManager service to be stopped #582
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 |
|---|---|---|
|
|
@@ -17,6 +17,7 @@ package controllers | |
|
|
||
| import ( | ||
| "context" | ||
| "errors" | ||
| "fmt" | ||
| "io" | ||
| "io/ioutil" | ||
|
|
@@ -102,12 +103,14 @@ servingInfo: | |
|
|
||
| func (s *OCPControllerManager) Run(ctx context.Context, ready chan<- struct{}, stopped chan<- struct{}) error { | ||
| defer close(stopped) | ||
| errorChannel := make(chan error, 1) | ||
|
|
||
| // run readiness check | ||
| go func() { | ||
| healthcheckStatus := util.RetryTCPConnection("127.0.0.1", "8445") | ||
| if !healthcheckStatus { | ||
| klog.Fatalf(s.Name(), fmt.Errorf("healthcheck status"), "%s failed to start") | ||
| klog.Errorf(s.Name(), fmt.Errorf("healthcheck status"), "%s failed to start") | ||
| errorChannel <- errors.New("openshift-controller-manager healthcheck status failed") | ||
| } | ||
| klog.Infof("%s is ready", s.Name()) | ||
| close(ready) | ||
|
|
@@ -116,13 +119,24 @@ func (s *OCPControllerManager) Run(ctx context.Context, ready chan<- struct{}, s | |
| if err := assets.ApplyNamespaces([]string{ | ||
| "assets/core/0000_50_cluster-openshift-controller-manager_00_namespace.yaml", | ||
| }, s.kubeconfig); err != nil { | ||
| klog.Warningf("failed to apply openshift namespaces %v", err) | ||
| klog.Errorf("failed to apply openshift namespaces %v", err) | ||
|
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. Assuming RetryTCPConnection writes an error to the chan, what's the expected sequence of events? It looks as though the err will be placed in the chan buffer, but ApplyNamespaces will be called. If ApplyNamespaces errors, then the error written to the chan is lost at the return. So the actual reason for the crash will be masked. Or: Question is: is it safe to assume the StartControllerManager routine will die gracefully and quietly (without spamming logs) if RetryTCPConnection returns an error? To be clear, it'll eventually die when the runtime handles the error and shuts down. I'm interested in how readable/debugable the shutdown will be. Secondly, resources created/opened by StartControllerManager won't have a chance to be cleaned up gracefully, since the main routine doesn't wait for subroutines to complete. |
||
| return err | ||
| } | ||
|
|
||
| options := openshift_controller_manager.OpenShiftControllerManager{Output: os.Stdout} | ||
| options.ConfigFilePath = s.ConfigFilePath | ||
| if err := options.StartControllerManager(); err != nil { | ||
| klog.Fatalf("Failed to start openshift-controller-manager %v", err) | ||
|
|
||
| go func() { | ||
| if err := options.StartControllerManager(); err != nil { | ||
| klog.Errorf("Failed to start openshift-controller-manager %v", err) | ||
| errorChannel <- err | ||
| } | ||
| }() | ||
|
|
||
| select { | ||
| case <-ctx.Done(): | ||
| return ctx.Err() | ||
| case err := <-errorChannel: | ||
| return err | ||
| } | ||
| return ctx.Err() | ||
| } | ||
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.
This log format doesn't look right. Errorf() takes a format string first, which here is passed as the last arg.
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.
oh right, I was just changing severity, but you're right.