From 228e5bea5e0fe014551f9c793901cbd133afb5b4 Mon Sep 17 00:00:00 2001 From: Yaron Schneider Date: Tue, 12 Nov 2019 14:29:52 -0800 Subject: [PATCH] remove Dapr placement image on uninstall and init (#204) --- cmd/init.go | 1 + cmd/uninstall.go | 2 +- pkg/standalone/uninstall.go | 11 +++++++++++ 3 files changed, 13 insertions(+), 1 deletion(-) diff --git a/cmd/init.go b/cmd/init.go index e2c8a898f..c087e3f7d 100644 --- a/cmd/init.go +++ b/cmd/init.go @@ -33,6 +33,7 @@ var InitCmd = &cobra.Command{ } print.SuccessStatusEvent(os.Stdout, "Success! Dapr has been installed. To verify, run 'kubectl get pods -w' in your terminal") } else { + standalone.Uninstall(false, dockerNetwork) err := standalone.Init(runtimeVersion, dockerNetwork) if err != nil { print.FailureStatusEvent(os.Stdout, err.Error()) diff --git a/cmd/uninstall.go b/cmd/uninstall.go index 1e92ee9fe..23a60aedd 100644 --- a/cmd/uninstall.go +++ b/cmd/uninstall.go @@ -44,7 +44,7 @@ var UninstallCmd = &cobra.Command{ func init() { UninstallCmd.Flags().BoolVar(&uninstallKubernetes, "kubernetes", false, "Uninstall Dapr from a Kubernetes cluster") - UninstallCmd.Flags().BoolVar(&uninstallAll, "all", false, "Remove the redis container as well") + UninstallCmd.Flags().BoolVar(&uninstallAll, "all", false, "Remove Redis container in addition to actor placement container") UninstallCmd.Flags().StringVarP(&uninstallDockerNetwork, "network", "", "", "The Docker network from which to remove the Dapr runtime") RootCmd.AddCommand(UninstallCmd) } diff --git a/pkg/standalone/uninstall.go b/pkg/standalone/uninstall.go index 50b3151c3..5473ee5e6 100644 --- a/pkg/standalone/uninstall.go +++ b/pkg/standalone/uninstall.go @@ -2,6 +2,7 @@ package standalone import ( "errors" + "fmt" "github.com/dapr/cli/utils" ) @@ -17,6 +18,16 @@ func Uninstall(uninstallAll bool, dockerNetwork string) error { errorMessage += "Could not delete Dapr Placement Container - it may not have been running " } + err = utils.RunCmdAndWait( + "docker", "rmi", + "--force", + daprDockerImageName) + + errorMessage = "" + if err != nil { + errorMessage += fmt.Sprintf("Could not delete image %s - it may not be present on the host", daprDockerImageName) + } + if uninstallAll { err = utils.RunCmdAndWait( "docker", "rm",