checkpoint: return empty image if checkpointPath exist

Signed-off-by: Ace-Tang <aceapril@126.com>
This commit is contained in:
Ace-Tang 2018-12-20 14:48:44 +08:00
parent e20ba5fa51
commit d4ecb00f6f

View File

@ -149,6 +149,8 @@ type Task interface {
// OCI Index that can be push and pulled from a remote resource. // OCI Index that can be push and pulled from a remote resource.
// //
// Additional software like CRIU maybe required to checkpoint and restore tasks // Additional software like CRIU maybe required to checkpoint and restore tasks
// NOTE: Checkpoint supports to dump task information to a directory, in this way,
// an empty OCI Index will be returned.
Checkpoint(context.Context, ...CheckpointTaskOpts) (Image, error) Checkpoint(context.Context, ...CheckpointTaskOpts) (Image, error)
// Update modifies executing tasks with updated settings // Update modifies executing tasks with updated settings
Update(context.Context, ...UpdateTaskOpts) error Update(context.Context, ...UpdateTaskOpts) error
@ -389,6 +391,8 @@ func (t *task) Resize(ctx context.Context, w, h uint32) error {
return errdefs.FromGRPC(err) return errdefs.FromGRPC(err)
} }
// NOTE: Checkpoint supports to dump task information to a directory, in this way, an empty
// OCI Index will be returned.
func (t *task) Checkpoint(ctx context.Context, opts ...CheckpointTaskOpts) (Image, error) { func (t *task) Checkpoint(ctx context.Context, opts ...CheckpointTaskOpts) (Image, error) {
ctx, done, err := t.client.WithLease(ctx) ctx, done, err := t.client.WithLease(ctx)
if err != nil { if err != nil {
@ -435,9 +439,10 @@ func (t *task) Checkpoint(ctx context.Context, opts ...CheckpointTaskOpts) (Imag
if err := t.checkpointTask(ctx, &index, request); err != nil { if err := t.checkpointTask(ctx, &index, request); err != nil {
return nil, err return nil, err
} }
// if checkpoint image path passed, jump checkpoint image // if checkpoint image path passed, jump checkpoint image,
// return an empty image
if isCheckpointPathExist(cr.Runtime.Name, i.Options) { if isCheckpointPathExist(cr.Runtime.Name, i.Options) {
return nil, nil return NewImage(t.client, images.Image{}), nil
} }
if cr.Image != "" { if cr.Image != "" {