Skip to content

Commit 0212e79

Browse files
authored
feat: reset, not uninstall (#408)
reset, not uninstall
1 parent 55bd1fa commit 0212e79

File tree

8 files changed

+16
-15
lines changed

8 files changed

+16
-15
lines changed

cmd/embedded-cluster/install.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -333,7 +333,7 @@ var installCommand = &cli.Command{
333333
logrus.Errorf("An installation has been detected on this machine.")
334334
logrus.Infof("If you want to reinstall you need to remove the existing installation")
335335
logrus.Infof("first. You can do this by running the following command:")
336-
logrus.Infof("\n sudo ./%s uninstall\n", binName)
336+
logrus.Infof("\n sudo ./%s reset\n", binName)
337337
return ErrNothingElseToAdd
338338
}
339339
metrics.ReportApplyStarted(c)

cmd/embedded-cluster/join.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -111,7 +111,7 @@ var joinCommand = &cli.Command{
111111
logrus.Errorf("An installation has been detected on this machine.")
112112
logrus.Infof("If you want to reinstall you need to remove the existing installation")
113113
logrus.Infof("first. You can do this by running the following command:")
114-
logrus.Infof("\n sudo ./%s uninstall\n", binName)
114+
logrus.Infof("\n sudo ./%s reset\n", binName)
115115
return ErrNothingElseToAdd
116116
}
117117

cmd/embedded-cluster/main.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -32,7 +32,7 @@ func main() {
3232
nodeCommands,
3333
versionCommand,
3434
joinCommand,
35-
uninstallCommand,
35+
resetCommand,
3636
},
3737
}
3838
if err := app.RunContext(ctx, os.Args); err != nil {

cmd/embedded-cluster/node.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,6 @@ var nodeCommands = &cli.Command{
1010
Hidden: true, // this has been replaced by top-level commands
1111
Subcommands: []*cli.Command{
1212
joinCommand,
13-
uninstallCommand,
13+
resetCommand,
1414
},
1515
}

cmd/embedded-cluster/uninstall.go

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -194,7 +194,7 @@ func (h *hostInfo) checkResetSafety(c *cli.Context) (bool, string, error) {
194194
}
195195
}
196196
if len(workers) > 0 && len(controllers) == 1 {
197-
message := fmt.Sprintf("Cannot uninstall the last %s node when there are other nodes in the cluster.", h.RoleName)
197+
message := fmt.Sprintf("Cannot reset the last %s node when there are other nodes in the cluster.", h.RoleName)
198198
return false, message, nil
199199
}
200200
return true, "", nil
@@ -284,19 +284,19 @@ func checkErrPrompt(c *cli.Context, err error) bool {
284284
if c.Bool("force") {
285285
return true
286286
}
287-
logrus.Info("An error occurred while trying to uninstall this node.")
287+
logrus.Info("An error occurred while trying to reset this node.")
288288
if c.Bool("no-prompt") {
289289
return false
290290
}
291291
logrus.Info("Continuing may leave the cluster in an unexpected state.")
292292
return prompts.New().Confirm("Do you want to continue anyway?", false)
293293
}
294294

295-
var uninstallCommand = &cli.Command{
296-
Name: "uninstall",
295+
var resetCommand = &cli.Command{
296+
Name: "reset",
297297
Before: func(c *cli.Context) error {
298298
if os.Getuid() != 0 {
299-
return fmt.Errorf("uninstall command must be run as root")
299+
return fmt.Errorf("reset command must be run as root")
300300
}
301301
return nil
302302
},
@@ -309,14 +309,14 @@ var uninstallCommand = &cli.Command{
309309
},
310310
&cli.BoolFlag{
311311
Name: "force",
312-
Usage: "Ignore errors encountered when uninstalling the node (implies --no-prompt)",
312+
Usage: "Ignore errors encountered when resetting the node (implies --no-prompt)",
313313
Value: false,
314314
},
315315
},
316316
Usage: fmt.Sprintf("Uninstall %s from the current node", binName),
317317
Action: func(c *cli.Context) error {
318318
logrus.Info("This will remove this node from the cluster and completely reset it.")
319-
logrus.Info("Do not uninstall another node until this is complete.")
319+
logrus.Info("Do not reset another node until this is complete.")
320320
if !c.Bool("force") && !c.Bool("no-prompt") && !prompts.New().Confirm("Do you want to continue?", false) {
321321
return fmt.Errorf("Aborting")
322322
}

e2e/reset_test.go

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -104,7 +104,7 @@ func TestMultiNodeReset(t *testing.T) {
104104
bin := strings.Split(command, " ")[0]
105105
// reset worker node
106106
t.Logf("%s: resetting worker node", time.Now().Format(time.RFC3339))
107-
stdout, stderr, err = RunCommandOnNode(t, tc, 3, []string{bin, "uninstall", "--no-prompt"})
107+
stdout, stderr, err = RunCommandOnNode(t, tc, 3, []string{bin, "reset", "--no-prompt"})
108108
if err != nil {
109109
t.Logf("stdout: %s\nstderr: %s", stdout, stderr)
110110
t.Fatalf("fail to reset worker node")
@@ -114,7 +114,7 @@ func TestMultiNodeReset(t *testing.T) {
114114
// reset a controller node
115115
// this should fail with a prompt to override
116116
t.Logf("%s: resetting controller node", time.Now().Format(time.RFC3339))
117-
stdout, stderr, err = RunCommandOnNode(t, tc, 2, []string{bin, "uninstall", "--no-prompt"})
117+
stdout, stderr, err = RunCommandOnNode(t, tc, 2, []string{bin, "reset", "--no-prompt"})
118118
if err != nil {
119119
t.Logf("stdout: %s\nstderr: %s", stdout, stderr)
120120
t.Fatalf("fail to remove controller node %s:", err)

e2e/scripts/reset-installation.sh

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22
set -euo pipefail
33

44
main() {
5-
if ! embedded-cluster uninstall --no-prompt | tee /tmp/log ; then
5+
if ! embedded-cluster reset --no-prompt | tee /tmp/log ; then
66
echo "Failed to uninstall embedded-cluster"
77
exit 1
88
fi

e2e/sudo_test.go

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -26,7 +26,8 @@ func TestCommandsRequireSudo(t *testing.T) {
2626
for _, cmd := range [][]string{
2727
{"embedded-cluster", "node", "join", "https://test", "token"},
2828
{"embedded-cluster", "join", "https://test", "token"},
29-
{"embedded-cluster", "uninstall", "--force"},
29+
{"embedded-cluster", "reset", "--force"},
30+
{"embedded-cluster", "node", "reset", "--force"},
3031
{"embedded-cluster", "shell"},
3132
{"embedded-cluster", "install", "--no-prompt"},
3233
} {

0 commit comments

Comments
 (0)