mirror of https://github.com/dapr/cli.git
Give scheduler a default volume, making it resilient to restarts by (#1423)
* Give scheduler a default volume, making it resilient to restarts by default Signed-off-by: joshvanl <me@joshvanl.dev> * Remove dapr_scheduler volume on uninstall, gated by `--all` Signed-off-by: joshvanl <me@joshvanl.dev> * Fix containerErrs in standaone.go Signed-off-by: joshvanl <me@joshvanl.dev> * Do not attempt to delete scheduler volume if no container runtime Signed-off-by: joshvanl <me@joshvanl.dev> * Increase upgrade test timeout to 40m Signed-off-by: joshvanl <me@joshvanl.dev> --------- Signed-off-by: joshvanl <me@joshvanl.dev> Co-authored-by: Artur Souza <artursouza.ms@outlook.com>
This commit is contained in:
parent
ddf43a5f55
commit
29d29ab549
2
Makefile
2
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 #
|
||||
|
|
|
@ -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)
|
||||
|
@ -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")
|
||||
|
|
|
@ -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")
|
||||
|
|
|
@ -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")
|
||||
|
|
Loading…
Reference in New Issue