task: allow checkpoint on pause state

task.Checkpoint should check status of container before handle
checkpoint. If the container has been paused, task.Checkpoint should
handle checkpoint and leave it paused.

Signed-off-by: Wei Fu <fuweid89@gmail.com>
Signed-off-by: Baijia <baijia.wr@antfin.com>
This commit is contained in:
Wei Fu
2021-03-24 13:59:54 +08:00
parent 31a0f92df1
commit 72b7f4bab1
2 changed files with 92 additions and 3 deletions

15
task.go
View File

@@ -451,11 +451,20 @@ func (t *task) Checkpoint(ctx context.Context, opts ...CheckpointTaskOpts) (Imag
}
request.Options = any
}
// make sure we pause it and resume after all other filesystem operations are completed
if err := t.Pause(ctx); err != nil {
status, err := t.Status(ctx)
if err != nil {
return nil, err
}
defer t.Resume(ctx)
if status.Status != Paused {
// make sure we pause it and resume after all other filesystem operations are completed
if err := t.Pause(ctx); err != nil {
return nil, err
}
defer t.Resume(ctx)
}
index := v1.Index{
Versioned: is.Versioned{
SchemaVersion: 2,