Skip to content

Commit 55e948b

Browse files
committed
rdctl factory-reset now kills the app and never waits.
Signed-off-by: Eric Promislow <[email protected]>
1 parent 519b43c commit 55e948b

File tree

5 files changed

+15
-18
lines changed

5 files changed

+15
-18
lines changed

src/go/rdctl/cmd/factoryReset.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -42,6 +42,7 @@ Use the --remove-kubernetes-cache=BOOLEAN flag to also remove the cached Kuberne
4242
logrus.SetLevel(logrus.TraceLevel)
4343
}
4444
cmd.SilenceUsage = true
45+
commonShutdownSettings.WaitForShutdown = false
4546
_, err := doShutdown(&commonShutdownSettings)
4647
if err != nil {
4748
return err
@@ -54,5 +55,4 @@ func init() {
5455
rootCmd.AddCommand(factoryResetCmd)
5556
factoryResetCmd.Flags().BoolVar(&removeKubernetesCache, "remove-kubernetes-cache", false, "If specified, also removes the cached Kubernetes images.")
5657
factoryResetCmd.Flags().BoolVar(&commonShutdownSettings.Verbose, "verbose", false, "Be verbose")
57-
factoryResetCmd.Flags().BoolVar(&commonShutdownSettings.WaitForShutdown, "wait", true, "Don't wait for shutdown to be confirmed")
5858
}

src/go/rdctl/cmd/shutdown.go

Lines changed: 1 addition & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -84,9 +84,6 @@ func doShutdown(shutdownSettings *shutdownSettingsStruct) ([]byte, error) {
8484
}
8585
return nil, err
8686
}
87-
if !shutdownSettings.WaitForShutdown {
88-
return output, nil
89-
}
90-
err = shutdown.FinishShutdown()
87+
err = shutdown.FinishShutdown(shutdownSettings.WaitForShutdown)
9188
return output, err
9289
}

src/go/rdctl/pkg/factoryreset/delete_data.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -139,7 +139,7 @@ func deleteUnixLikeData(homeDir string, altAppHomePath string, configHomePath st
139139
}
140140
for _, currentPath := range pathList {
141141
if err := os.RemoveAll(currentPath); err != nil {
142-
logrus.Errorf("Error trying to remove %s: %w", currentPath, err)
142+
logrus.Errorf("Error trying to remove %s: %s", currentPath, err)
143143
}
144144
}
145145
if err := clearDockerContext(); err != nil {

src/go/rdctl/pkg/factoryreset/factory_reset_windows.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -31,7 +31,7 @@ import (
3131
)
3232

3333
func KillRancherDesktop() {
34-
cmd := exec.Command("taskkill", "/IM", "Rancher Desktop", "/T", "/F")
34+
cmd := exec.Command("taskkill", "/IM", "Rancher Desktop.exe", "/T", "/F")
3535
cmd.SysProcAttr = &syscall.SysProcAttr{CreationFlags: CREATE_NO_WINDOW}
3636
cmd.Run()
3737
}

src/go/rdctl/pkg/shutdown/shutdown.go

Lines changed: 11 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -30,24 +30,24 @@ import (
3030
"github.com/sirupsen/logrus"
3131
)
3232

33-
func FinishShutdown() error {
33+
func FinishShutdown(waitForShutdown bool) error {
3434
switch runtime.GOOS {
3535
case "darwin":
36-
doCheckWithTimeout(checkProcessQemu, pkillQemu, 15, 2, "qemu")
37-
doCheckWithTimeout(checkProcessDarwin, pkillDarwin, 5, 1, "the app")
36+
doCheckWithTimeout(checkProcessQemu, pkillQemu, waitForShutdown, 15, 2, "qemu")
37+
doCheckWithTimeout(checkProcessDarwin, pkillDarwin, waitForShutdown, 5, 1, "the app")
3838
case "linux":
39-
doCheckWithTimeout(checkProcessQemu, pkillQemu, 15, 2, "qemu")
40-
doCheckWithTimeout(checkProcessLinux, pkillLinux, 5, 1, "the app")
39+
doCheckWithTimeout(checkProcessQemu, pkillQemu, waitForShutdown, 15, 2, "qemu")
40+
doCheckWithTimeout(checkProcessLinux, pkillLinux, waitForShutdown, 5, 1, "the app")
4141
case "windows":
42-
doCheckWithTimeout(checkProcessWindows, factoryreset.KillRancherDesktop, 15, 2, "the app")
42+
doCheckWithTimeout(checkProcessWindows, factoryreset.KillRancherDesktop, waitForShutdown, 15, 2, "the app")
4343
default:
4444
return fmt.Errorf("unhandled runtime: %s", runtime.GOOS)
4545
}
4646
return nil
4747
}
4848

49-
func doCheckWithTimeout(checkFunc func() bool, killFunc func(), retryCount int, retryWait int, operation string) {
50-
for iter := 0; iter < retryCount; iter++ {
49+
func doCheckWithTimeout(checkFunc func() bool, killFunc func(), waitForShutdown bool, retryCount int, retryWait int, operation string) {
50+
for iter := 0; waitForShutdown && iter < retryCount; iter++ {
5151
if iter > 0 {
5252
logrus.Debugf("checking %s showed it's still running; sleeping %d seconds\n", operation, retryWait)
5353
time.Sleep(time.Duration(retryWait) * time.Second)
@@ -111,13 +111,13 @@ func checkProcessQemu() bool {
111111
}
112112

113113
func pkillQemu() {
114-
exec.Command("pkill", "-f", RancherDesktopQemuCommand).Run()
114+
exec.Command("pkill", "-9", "-f", RancherDesktopQemuCommand).Run()
115115
}
116116

117117
func pkillDarwin() {
118-
exec.Command("pkill", "-f", "Contents/MacOS/Rancher Desktop").Run()
118+
exec.Command("pkill", "-9", "-f", "Contents/MacOS/Rancher Desktop").Run()
119119
}
120120

121121
func pkillLinux() {
122-
exec.Command("pkill", "rancher-desktop").Run()
122+
exec.Command("pkill", "-9", "rancher-desktop").Run()
123123
}

0 commit comments

Comments
 (0)