Skip to content

Commit d36bcb6

Browse files
committed
Ignore replacement errors for containerd executables on Windows
When containerd is restarted on Windows, the containers previously started by the kubelet will usually continue to run. This means that some containerd executables will still be running, too. However, unlike on Linux, you cannot simply replace executables that are still running on Windows. As a workaround, k0s will ignore such errors on Windows for the time being. Currently, this means that after a k0s update, a Windows node must be rebooted to complete the update. This is far from an optimal, but since Windows support is currently pretty broken anyway, it is a workaround with minimal impact on the existing codebase, which facilitates further testing and bug fixing. Signed-off-by: Tom Wieczorek <[email protected]>
1 parent c03b63e commit d36bcb6

File tree

1 file changed

+12
-2
lines changed

1 file changed

+12
-2
lines changed

pkg/component/worker/containerd/component.go

+12-2
Original file line numberDiff line numberDiff line change
@@ -99,9 +99,19 @@ var _ manager.Component = (*Component)(nil)
9999
func (c *Component) Init(ctx context.Context) error {
100100
g, _ := errgroup.WithContext(ctx)
101101
for _, bin := range c.binaries {
102-
b := bin
103102
g.Go(func() error {
104-
return assets.Stage(c.K0sVars.BinDir, b, constant.BinDirMode)
103+
err := assets.Stage(c.K0sVars.BinDir, bin, constant.BinDirMode)
104+
// Simply ignore the "running executable" problem on Windows for
105+
// now. Whenever there's a permission error on Windows and the
106+
// target file exists, log the error and continue.
107+
if err != nil &&
108+
runtime.GOOS == "windows" &&
109+
errors.Is(err, os.ErrPermission) &&
110+
file.Exists(filepath.Join(c.K0sVars.BinDir, bin)) {
111+
logrus.WithField("component", "containerd").WithError(err).Error("Failed to replace ", bin)
112+
return nil
113+
}
114+
return err
105115
})
106116
}
107117
if err := g.Wait(); err != nil {

0 commit comments

Comments
 (0)