diff --git a/pkg/containerd/configure.go b/pkg/containerd/configure.go index fab3841..8466c27 100644 --- a/pkg/containerd/configure.go +++ b/pkg/containerd/configure.go @@ -41,6 +41,7 @@ func NewConfig(hostFs afero.Fs, configPath string) *Config { func (c *Config) AddRuntime(shimPath string) error { runtimeName := shim.RuntimeName(path.Base(shimPath)) + l := slog.With("runtime", runtimeName) cfg := generateConfig(shimPath, runtimeName) @@ -52,7 +53,7 @@ func (c *Config) AddRuntime(shimPath string) error { // Warn if config.toml already contains runtimeName if strings.Contains(string(data), runtimeName) { - slog.Info(fmt.Sprintf("config for runtime '%s' already exists, skipping", runtimeName)) + l.Info("runtime config already exists, skipping") return nil } @@ -74,6 +75,7 @@ func (c *Config) AddRuntime(shimPath string) error { func (c *Config) RemoveRuntime(shimPath string) (changed bool, err error) { runtimeName := shim.RuntimeName(path.Base(shimPath)) + l := slog.With("runtime", runtimeName) cfg := generateConfig(shimPath, runtimeName) @@ -85,7 +87,7 @@ func (c *Config) RemoveRuntime(shimPath string) (changed bool, err error) { // Warn if config.toml does not contain the runtimeName if !strings.Contains(string(data), runtimeName) { - slog.Warn(fmt.Sprintf("config for runtime '%s' does not exist, skipping", runtimeName)) + l.Warn("runtime config does not exist, skipping") return false, nil } diff --git a/pkg/containerd/restart.go b/pkg/containerd/restart_unix.go similarity index 93% rename from pkg/containerd/restart.go rename to pkg/containerd/restart_unix.go index e4377f3..63b9261 100644 --- a/pkg/containerd/restart.go +++ b/pkg/containerd/restart_unix.go @@ -1,3 +1,6 @@ +//go:build unix +// +build unix + /* Copyright The KWasm Authors. @@ -31,7 +34,7 @@ func (c *Config) RestartRuntime() error { if err != nil { return err } - slog.Info("found containerd pid", "pid", pid) + slog.Debug("found containerd process", "pid", pid) err = syscall.Kill(pid, syscall.SIGHUP) @@ -44,7 +47,6 @@ func (c *Config) RestartRuntime() error { func getPid() (int, error) { processes, err := psProcesses() if err != nil { - slog.Info("psProcesses() Failed, are you using windows?") return 0, fmt.Errorf("could not get processes: %+v", err) } diff --git a/pkg/containerd/restart_test.go b/pkg/containerd/restart_unix_test.go similarity index 98% rename from pkg/containerd/restart_test.go rename to pkg/containerd/restart_unix_test.go index c5cbb63..5d1fbb4 100644 --- a/pkg/containerd/restart_test.go +++ b/pkg/containerd/restart_unix_test.go @@ -1,3 +1,6 @@ +//go:build unix +// +build unix + package containerd import ( diff --git a/pkg/containerd/restart_windows.go b/pkg/containerd/restart_windows.go new file mode 100644 index 0000000..153c37e --- /dev/null +++ b/pkg/containerd/restart_windows.go @@ -0,0 +1,8 @@ +//go:build windows +// +build windows + +package containerd + +func (c *Config) RestartRuntime() error { + panic("restarting containerd not implemented") +}