Skip to content

Commit

Permalink
fix: stop and clean up installer container correctly
Browse files Browse the repository at this point in the history
This fixes an issue when Talos on clean shutdown after install waits for
the process to terminate, that process is `containerd-shim` which is
still running because container wasn't cleaned up correctly.

Signed-off-by: Andrey Smirnov <smirnov.andrey@gmail.com>
  • Loading branch information
smira authored and talos-bot committed Feb 24, 2021
1 parent 85d1669 commit 09369fe
Showing 1 changed file with 6 additions and 0 deletions.
6 changes: 6 additions & 0 deletions internal/app/machined/internal/install/install.go
Original file line number Diff line number Diff line change
Expand Up @@ -47,6 +47,8 @@ func RunInstallerContainer(disk, platform, ref string, reg config.Registries, op
return err
}

defer client.Close() //nolint: errcheck

var img containerd.Image

if !options.Pull {
Expand Down Expand Up @@ -121,6 +123,8 @@ func RunInstallerContainer(disk, platform, ref string, reg config.Registries, op
return err
}

defer container.Delete(ctx, containerd.WithSnapshotCleanup) //nolint: errcheck

f, err := os.OpenFile("/dev/kmsg", os.O_RDWR|unix.O_CLOEXEC|unix.O_NONBLOCK|unix.O_NOCTTY, 0o666)
if err != nil {
return fmt.Errorf("failed to open /dev/kmsg: %w", err)
Expand All @@ -137,6 +141,8 @@ func RunInstallerContainer(disk, platform, ref string, reg config.Registries, op
return err
}

defer t.Delete(ctx) //nolint: errcheck

if err = t.Start(ctx); err != nil {
return fmt.Errorf("failed to start %q task: %w", "upgrade", err)
}
Expand Down

0 comments on commit 09369fe

Please sign in to comment.