diff --git a/Makefile b/Makefile index 3bcc674c1..298c35d2d 100644 --- a/Makefile +++ b/Makefile @@ -174,7 +174,7 @@ e2e-build-run-k8s: build test-e2e-k8s ################################################################################ .PHONY: test-e2e-upgrade test-e2e-upgrade: test-deps - gotestsum --jsonfile $(TEST_OUTPUT_FILE) --format standard-verbose -- -timeout 30m -count=1 -tags=e2e ./tests/e2e/upgrade/... + gotestsum --jsonfile $(TEST_OUTPUT_FILE) --format standard-verbose -- -timeout 40m -count=1 -tags=e2e ./tests/e2e/upgrade/... ################################################################################ # Build, E2E Tests for Kubernetes Upgrade # diff --git a/cmd/init.go b/cmd/init.go index c3c4133cd..e3b5c0d6e 100644 --- a/cmd/init.go +++ b/cmd/init.go @@ -171,11 +171,7 @@ dapr init --runtime-path 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) @@ -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") diff --git a/cmd/uninstall.go b/cmd/uninstall.go index b8b672a11..a2c91085b 100644 --- a/cmd/uninstall.go +++ b/cmd/uninstall.go @@ -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") diff --git a/pkg/standalone/uninstall.go b/pkg/standalone/uninstall.go index 0162cbe43..7eb9fecbc 100644 --- a/pkg/standalone/uninstall.go +++ b/pkg/standalone/uninstall.go @@ -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( + 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) { @@ -117,6 +131,10 @@ 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) } + + if containerRuntimeAvailable { + containerErrs = removeSchedulerVolume(containerErrs, runtimeCmd) + } } err = errors.New("uninstall failed")