Skip to content
Open
Changes from 2 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
21 changes: 13 additions & 8 deletions cmd/renew_certificate.go
Original file line number Diff line number Diff line change
Expand Up @@ -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)
}
}
Expand Down Expand Up @@ -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

@Mukuwul Mukuwul Jul 18, 2026

Copy link
Copy Markdown
Contributor Author

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.

Comment on lines +183 to 194

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think this is a good one, can you include it?

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The 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))
Expand All @@ -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)
Expand Down