Skip to content

Commit 32e53aa

Browse files
committed
Clearify error message if user tries to uninstall a nonkube site.
1 parent 719c939 commit 32e53aa

File tree

3 files changed

+20
-4
lines changed

3 files changed

+20
-4
lines changed

internal/cmd/skupper/system/nonkube/system_uninstall.go

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,7 @@ package nonkube
33
import (
44
"errors"
55
"fmt"
6+
"net"
67
"os"
78
"path"
89

@@ -99,7 +100,12 @@ func (cmd *CmdSystemUninstall) Run() error {
99100
err := cmd.SystemUninstall(string(config.GetPlatform()))
100101

101102
if err != nil {
102-
return fmt.Errorf("failed to uninstall : %s", err)
103+
opErr := &net.OpError{}
104+
if errors.As(err, &opErr) {
105+
return fmt.Errorf("Unable to communicate with the Container Engine.\nRun: \"skupper system install\" to prepare the local environment and start the controller.\n\nError: %s", err)
106+
} else {
107+
return fmt.Errorf("Unable to uninstall.\nError: %s", err.Error())
108+
}
103109
}
104110

105111
return nil

internal/cmd/skupper/system/nonkube/system_uninstall_test.go

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@ package nonkube
22

33
import (
44
"fmt"
5+
"net"
56
"os"
67
"path/filepath"
78
"testing"
@@ -139,7 +140,7 @@ func TestCmdSystemUninstall_Run(t *testing.T) {
139140
{
140141
name: "disable socket fails",
141142
disableSocketFails: true,
142-
errorMessage: "failed to uninstall : disable socket fails",
143+
errorMessage: "Unable to communicate with the Container Engine.\nRun: \"skupper system install\" to prepare the local environment and start the controller.\n\nError: dial: disable socket fails",
143144
flags: &common.CommandSystemUninstallFlags{Force: false},
144145
},
145146
}
@@ -235,7 +236,11 @@ func newCmdSystemUninstallWithMocks(disableSocketFails bool) *CmdSystemUninstall
235236

236237
func mockCmdSystemUninstall(platform string) error { return nil }
237238
func mockCmdSystemUninstallDisableSocketFails(platform string) error {
238-
return fmt.Errorf("disable socket fails")
239+
errMsg := fmt.Errorf("disable socket fails")
240+
netErr := &net.OpError{
241+
Op: "dial",
242+
Err: errMsg}
243+
return netErr
239244
}
240245

241246
func mockCmdSystemUninstallThereAreStillSites() (bool, error) { return true, nil }

internal/nonkube/bootstrap/uninstall.go

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@ package bootstrap
22

33
import (
44
"fmt"
5+
"net"
56
"os"
67
"os/user"
78
"path"
@@ -44,7 +45,11 @@ func Uninstall(platform string) error {
4445

4546
cli, err := internalclient.NewCompatClient(endpoint, "")
4647
if err != nil {
47-
return fmt.Errorf("failed to create container client: %v", err)
48+
errMsg := fmt.Errorf("failed to create container client: %v", err)
49+
netErr := &net.OpError{
50+
Op: "dial",
51+
Err: errMsg}
52+
return netErr
4853
}
4954

5055
container, err := cli.ContainerInspect(containerName)

0 commit comments

Comments
 (0)