Skip to content
Open
Changes from all 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
26 changes: 19 additions & 7 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,28 @@ 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()
// The scheduler control plane service only exists for runtime 1.14 onwards,
// so restart it only when it is present in the cluster. --ignore-not-found
// makes absence the only non-error outcome with empty output: any other
// probe failure (RBAC, transient API error) must fail the restart loudly
// rather than silently skipping the scheduler.
out, err := utils.RunCmdAndWait("kubectl", "get", "statefulsets/dapr-scheduler-server", "-n", namespace, "--ignore-not-found", "-o", "name")
if err != nil {
print.FailureStatusEvent(os.Stdout, "Failed to fetch Dapr namespace")
return fmt.Errorf("failed to check for dapr-scheduler-server statefulset: %w", err)
}
if strings.TrimSpace(out) != "" {
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.


errs := make([]error, len(controlPlaneServices))
Expand All @@ -190,12 +202,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
Loading