Skip to content

Commit cd16a63

Browse files
committed
let uninstall exit with 0
1 parent ff5edbd commit cd16a63

File tree

3 files changed

+16
-19
lines changed

3 files changed

+16
-19
lines changed

cmd/node-installer/uninstall.go

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -39,8 +39,10 @@ var uninstallCmd = &cobra.Command{
3939
restarter := containerd.NewRestarter()
4040

4141
if err := RunUninstall(config, rootFs, hostFs, restarter); err != nil {
42-
slog.Error("failed to uninstall", "error", err)
43-
os.Exit(1)
42+
slog.Error("failed to uninstall shim", "error", err)
43+
44+
// Exiting with 0 to prevent Kubernetes Jobs from running repetitively
45+
os.Exit(0)
4446
}
4547
},
4648
}
@@ -50,7 +52,7 @@ func init() {
5052
}
5153

5254
func RunUninstall(config Config, rootFs, hostFs afero.Fs, restarter containerd.Restarter) error {
53-
slog.Info("uninstall called")
55+
slog.Info("uninstall called", "shim", config.Runtime.Name)
5456
shimName := config.Runtime.Name
5557
runtimeName := path.Join(config.Kwasm.Path, "bin", shimName)
5658

internal/shim/uninstall.go

Lines changed: 1 addition & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,6 @@ package shim
33
import (
44
"errors"
55
"fmt"
6-
"log/slog"
76
"os"
87

98
"github.com/spinkube/runtime-class-manager/internal/state"
@@ -16,18 +15,14 @@ func (c *Config) Uninstall(shimName string) (string, error) {
1615
}
1716
s, ok := st.Shims[shimName]
1817
if !ok {
19-
slog.Error("shim not installed", "shim", shimName)
20-
os.Exit(0)
2118
return "", fmt.Errorf("shim %s not installed", shimName)
2219
}
2320
filePath := s.Path
2421

2522
err = c.hostFs.Remove(filePath)
2623
if err != nil {
2724
if !errors.Is(err, os.ErrNotExist) {
28-
slog.Error("shim binary did not exist, nothing to delete")
29-
os.Exit(0)
30-
return "", fmt.Errorf("shim binary did not exist, nothing to delete")
25+
return "", fmt.Errorf("shim binary at %s does not exist, nothing to delete", filePath)
3126
}
3227
}
3328
st.RemoveShim(shimName)

internal/shim/uninstall_test.go

Lines changed: 10 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -38,16 +38,16 @@ func TestConfig_Uninstall(t *testing.T) {
3838
want string
3939
wantErr bool
4040
}{
41-
// {
42-
// "shim not installed",
43-
// fields{
44-
// tests.FixtureFs("../../testdata/node-installer/shim"),
45-
// "/opt/kwasm",
46-
// },
47-
// args{"not-existing-shim"},
48-
// "",
49-
// false,
50-
// },
41+
{
42+
"shim not installed",
43+
fields{
44+
tests.FixtureFs("../../testdata/node-installer/shim"),
45+
"/opt/kwasm",
46+
},
47+
args{"not-existing-shim"},
48+
"",
49+
true,
50+
},
5151
{
5252
"missing shim binary",
5353
fields{

0 commit comments

Comments
 (0)