Restore sandboxes on daemon restart

Signed-off-by: Maksym Pavlenko <pavlenko.maksym@gmail.com>
This commit is contained in:
Maksym Pavlenko
2022-01-27 14:00:42 -08:00
parent 0c5e5c3579
commit 0d165e6544
12 changed files with 165 additions and 53 deletions

View File

@@ -148,6 +148,8 @@ var removeCommand = cli.Command{
}
defer cancel()
force := context.Bool("force")
for _, id := range context.Args() {
sandbox, err := client.LoadSandbox(ctx, id)
if err != nil {
@@ -155,7 +157,15 @@ var removeCommand = cli.Command{
continue
}
err = sandbox.Shutdown(ctx, context.Bool("force"))
err = sandbox.Stop(ctx)
if err != nil {
log.G(ctx).WithError(err).Errorf("failed to stop sandbox %s", id)
if !force {
continue
}
}
err = sandbox.Delete(ctx)
if err != nil {
log.G(ctx).WithError(err).Errorf("failed to shutdown sandbox %s", id)
continue