-
Notifications
You must be signed in to change notification settings - Fork 219
Fail loudly when renew-certificate --restart cannot restart the control plane; include scheduler
#1670
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
base: master
Are you sure you want to change the base?
Fail loudly when renew-certificate --restart cannot restart the control plane; include scheduler
#1670
Changes from 2 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 |
|---|---|---|
|
|
@@ -132,9 +132,8 @@ dapr mtls renew-cert -k --valid-until <no of days> --restart | |
| "Certificate rotation is successful! Your new certicate is valid through "+expiry.Format(time.RFC1123)) | ||
|
|
||
| if restartDaprServices { | ||
| restartControlPlaneService() | ||
| if err != nil { | ||
| print.FailureStatusEvent(os.Stdout, err.Error()) | ||
| if err := restartControlPlaneService(); err != nil { | ||
| print.FailureStatusEvent(os.Stderr, "%s", err.Error()) | ||
| os.Exit(1) | ||
| } | ||
| } | ||
|
|
@@ -170,15 +169,21 @@ func logErrorAndExit(err error) { | |
| } | ||
|
|
||
| func restartControlPlaneService() error { | ||
| namespace, err := kubernetes.GetDaprNamespace() | ||
| if err != nil { | ||
| return fmt.Errorf("failed to fetch Dapr namespace: %w", err) | ||
| } | ||
|
|
||
| controlPlaneServices := []string{ | ||
| "deploy/dapr-sentry", | ||
| "deploy/dapr-sidecar-injector", | ||
| "deploy/dapr-operator", | ||
| "statefulsets/dapr-placement-server", | ||
| } | ||
| namespace, err := kubernetes.GetDaprNamespace() | ||
| if err != nil { | ||
| print.FailureStatusEvent(os.Stdout, "Failed to fetch Dapr namespace") | ||
| // The scheduler control plane service only exists for runtime 1.14 onwards, | ||
| // so restart it only when it is present in the cluster. | ||
| if _, err := utils.RunCmdAndWait("kubectl", "get", "statefulsets/dapr-scheduler-server", "-n", namespace); err == nil { | ||
| controlPlaneServices = append(controlPlaneServices, "statefulsets/dapr-scheduler-server") | ||
| } | ||
|
Comment on lines
+183
to
194
Member
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. I think this is a good one, can you include it?
Contributor
Author
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. Good catch, thanks both - done in dc167c6. The probe now uses --ignore-not-found -o name, so absence is the only case that skips the scheduler; any other kubectl failure (RBAC, transient API error) propagates and fails the restart loudly. |
||
|
|
||
| errs := make([]error, len(controlPlaneServices)) | ||
|
|
@@ -190,12 +195,12 @@ func restartControlPlaneService() error { | |
| print.InfoStatusEvent(os.Stdout, fmt.Sprintf("Restarting %s..", name)) | ||
| _, err := utils.RunCmdAndWait("kubectl", "rollout", "restart", "-n", namespace, name) | ||
| if err != nil { | ||
| errs[i] = fmt.Errorf("error in restarting deployment %s. Error is %w", name, err) | ||
| errs[i] = fmt.Errorf("error in restarting %s. Error is %w", name, err) | ||
| return | ||
| } | ||
| _, err = utils.RunCmdAndWait("kubectl", "rollout", "status", "-n", namespace, name) | ||
| if err != nil { | ||
| errs[i] = fmt.Errorf("error in checking status for deployment %s. Error is %w", name, err) | ||
| errs[i] = fmt.Errorf("error in checking rollout status for %s. Error is %w", name, err) | ||
| return | ||
| } | ||
| }(i, name) | ||
|
|
||
Uh oh!
There was an error while loading. Please reload this page.
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.
Done in 339975f - reworded both errors to be resource-agnostic since the list now includes statefulsets.