Skip to content
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

Give scheduler a default volume, making it resilient to restarts by #1423

Merged
merged 6 commits into from
Jul 17, 2024
Merged
Show file tree
Hide file tree
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
8 changes: 2 additions & 6 deletions cmd/init.go
Original file line number Diff line number Diff line change
Expand Up @@ -171,11 +171,7 @@ dapr init --runtime-path <path-to-install-directory>
print.FailureStatusEvent(os.Stdout, "Invalid container runtime. Supported values are docker and podman.")
os.Exit(1)
}
var schedVol *string
if cmd.Flags().Changed("scheduler-volume") {
schedVol = &schedulerVolume
}
err := standalone.Init(runtimeVersion, dashboardVersion, dockerNetwork, slimMode, imageRegistryURI, fromDir, containerRuntime, imageVariant, daprRuntimePath, schedVol)
err := standalone.Init(runtimeVersion, dashboardVersion, dockerNetwork, slimMode, imageRegistryURI, fromDir, containerRuntime, imageVariant, daprRuntimePath, &schedulerVolume)
if err != nil {
print.FailureStatusEvent(os.Stderr, err.Error())
os.Exit(1)
Expand Down Expand Up @@ -224,7 +220,7 @@ func init() {
InitCmd.Flags().String("network", "", "The Docker network on which to deploy the Dapr runtime")
InitCmd.Flags().StringVarP(&fromDir, "from-dir", "", "", "Use Dapr artifacts from local directory for self-hosted installation")
InitCmd.Flags().StringVarP(&imageVariant, "image-variant", "", "", "The image variant to use for the Dapr runtime, for example: mariner")
InitCmd.Flags().StringVarP(&schedulerVolume, "scheduler-volume", "", "", "Self-hosted only. Optionally specify a volume for the scheduler service data directory. By default, scheduler data is not persisted and not resilient to restarts without this flag.")
InitCmd.Flags().StringVarP(&schedulerVolume, "scheduler-volume", "", "dapr_scheduler", "Self-hosted only. Specify a volume for the scheduler service data directory.")
InitCmd.Flags().BoolP("help", "h", false, "Print this help message")
InitCmd.Flags().StringArrayVar(&values, "set", []string{}, "set values on the command line (can specify multiple or separate values with commas: key1=val1,key2=val2)")
InitCmd.Flags().String("image-registry", "", "Custom/private docker image repository URL")
Expand Down
2 changes: 1 addition & 1 deletion cmd/uninstall.go
Original file line number Diff line number Diff line change
Expand Up @@ -99,7 +99,7 @@ func init() {
UninstallCmd.Flags().BoolVarP(&uninstallKubernetes, "kubernetes", "k", false, "Uninstall Dapr from a Kubernetes cluster")
UninstallCmd.Flags().BoolVarP(&uninstallDev, "dev", "", false, "Uninstall Dapr Redis and Zipking installations from Kubernetes cluster")
UninstallCmd.Flags().UintVarP(&timeout, "timeout", "", 300, "The timeout for the Kubernetes uninstall")
UninstallCmd.Flags().BoolVar(&uninstallAll, "all", false, "Remove .dapr directory, Redis, Placement, Scheduler, and Zipkin containers on local machine, and CRDs on a Kubernetes cluster")
UninstallCmd.Flags().BoolVar(&uninstallAll, "all", false, "Remove .dapr directory, Redis, Placement, Scheduler (and default volume in self-hosted mode), and Zipkin containers on local machine, and CRDs on a Kubernetes cluster")
UninstallCmd.Flags().String("network", "", "The Docker network from which to remove the Dapr runtime")
UninstallCmd.Flags().StringVarP(&uninstallNamespace, "namespace", "n", "dapr-system", "The Kubernetes namespace to uninstall Dapr from")
UninstallCmd.Flags().BoolP("help", "h", false, "Print this help message")
Expand Down
16 changes: 16 additions & 0 deletions pkg/standalone/uninstall.go
Original file line number Diff line number Diff line change
Expand Up @@ -63,6 +63,20 @@ func removeDockerContainer(containerErrs []error, containerName, network, runtim
return containerErrs
}

func removeSchedulerVolume(containerErrs []error, runtimeCmd string) []error {
print.InfoStatusEvent(os.Stdout, "Removing volume if it exists: dapr_scheduler")
_, err := utils.RunCmdAndWait(
runtimeCmd, "volume", "rm",
"--force",
"dapr_scheduler")
if err != nil {
containerErrs = append(
artursouza marked this conversation as resolved.
Show resolved Hide resolved
containerErrs,
fmt.Errorf("could not remove dapr_scheduler volume: %w", err))
}
return containerErrs
}

func removeDir(dirPath string) error {
_, err := os.Stat(dirPath)
if os.IsNotExist(err) {
Expand Down Expand Up @@ -117,6 +131,8 @@ func Uninstall(uninstallAll bool, dockerNetwork string, containerRuntime string,
if err != nil {
print.WarningStatusEvent(os.Stdout, "WARNING: could not delete dapr dir %s: %s", installDir, err)
}

removeSchedulerVolume(containerErrs, runtimeCmd)
}

err = errors.New("uninstall failed")
Expand Down
Loading