diff --git a/shim/checkpoint.go b/shim/checkpoint.go index ba6c15d..4433ea6 100644 --- a/shim/checkpoint.go +++ b/shim/checkpoint.go @@ -52,7 +52,7 @@ func (c *Container) kill(ctx context.Context) error { return nil } -func (c *Container) checkpoint(ctx context.Context) error { +func (c *Container) checkpoint(ctx context.Context) (retErr error) { c.checkpointRestore.Lock() defer c.checkpointRestore.Unlock() @@ -107,6 +107,13 @@ func (c *Container) checkpoint(ctx context.Context) error { opts.ImagePath = nodev1.SnapshotPath(c.ID()) beforeCheckpoint := time.Now() + c.setScaledDownFlag(true) + defer func() { + if retErr != nil { + c.setScaledDownFlag(false) + } + }() + if err := initProcess.Runtime().Checkpoint(ctx, c.ID(), opts); err != nil { log.G(ctx).Errorf("error checkpointing container: %s", err) b, err := os.ReadFile(path.Join(workDir, "dump.log")) diff --git a/shim/container.go b/shim/container.go index 95e0d54..718a9b4 100644 --- a/shim/container.go +++ b/shim/container.go @@ -218,6 +218,10 @@ func (c *Container) setPhaseNotify(phase v1.ContainerPhase, duration time.Durati c.sendEvent(c.Status()) } +func (c *Container) setScaledDownFlag(flag bool) { + c.scaledDown = flag +} + func (c *Container) SetSkipStart(skip bool) { c.skipStart = skip }