|
@@ -145,7 +145,7 @@ func (c *client) NewContainer(ctx context.Context, id string, ociSpec *specs.Spe
|
|
// Start create and start a task for the specified containerd id
|
|
// Start create and start a task for the specified containerd id
|
|
func (c *container) Start(ctx context.Context, checkpointDir string, withStdin bool, attachStdio libcontainerdtypes.StdioCallback) (libcontainerdtypes.Task, error) {
|
|
func (c *container) Start(ctx context.Context, checkpointDir string, withStdin bool, attachStdio libcontainerdtypes.StdioCallback) (libcontainerdtypes.Task, error) {
|
|
var (
|
|
var (
|
|
- cp *types.Descriptor
|
|
|
|
|
|
+ checkpoint *types.Descriptor
|
|
t containerd.Task
|
|
t containerd.Task
|
|
rio cio.IO
|
|
rio cio.IO
|
|
stdinCloseSync = make(chan containerd.Process, 1)
|
|
stdinCloseSync = make(chan containerd.Process, 1)
|
|
@@ -154,15 +154,16 @@ func (c *container) Start(ctx context.Context, checkpointDir string, withStdin b
|
|
if checkpointDir != "" {
|
|
if checkpointDir != "" {
|
|
// write checkpoint to the content store
|
|
// write checkpoint to the content store
|
|
tar := archive.Diff(ctx, "", checkpointDir)
|
|
tar := archive.Diff(ctx, "", checkpointDir)
|
|
- cp, err := c.client.writeContent(ctx, images.MediaTypeContainerd1Checkpoint, checkpointDir, tar)
|
|
|
|
|
|
+ var err error
|
|
|
|
+ checkpoint, err = c.client.writeContent(ctx, images.MediaTypeContainerd1Checkpoint, checkpointDir, tar)
|
|
// remove the checkpoint when we're done
|
|
// remove the checkpoint when we're done
|
|
defer func() {
|
|
defer func() {
|
|
- if cp != nil {
|
|
|
|
- err := c.client.client.ContentStore().Delete(ctx, cp.Digest)
|
|
|
|
|
|
+ if checkpoint != nil {
|
|
|
|
+ err := c.client.client.ContentStore().Delete(ctx, checkpoint.Digest)
|
|
if err != nil {
|
|
if err != nil {
|
|
c.client.logger.WithError(err).WithFields(logrus.Fields{
|
|
c.client.logger.WithError(err).WithFields(logrus.Fields{
|
|
"ref": checkpointDir,
|
|
"ref": checkpointDir,
|
|
- "digest": cp.Digest,
|
|
|
|
|
|
+ "digest": checkpoint.Digest,
|
|
}).Warnf("failed to delete temporary checkpoint entry")
|
|
}).Warnf("failed to delete temporary checkpoint entry")
|
|
}
|
|
}
|
|
}
|
|
}
|
|
@@ -192,7 +193,7 @@ func (c *container) Start(ctx context.Context, checkpointDir string, withStdin b
|
|
|
|
|
|
taskOpts := []containerd.NewTaskOpts{
|
|
taskOpts := []containerd.NewTaskOpts{
|
|
func(_ context.Context, _ *containerd.Client, info *containerd.TaskInfo) error {
|
|
func(_ context.Context, _ *containerd.Client, info *containerd.TaskInfo) error {
|
|
- info.Checkpoint = cp
|
|
|
|
|
|
+ info.Checkpoint = checkpoint
|
|
return nil
|
|
return nil
|
|
},
|
|
},
|
|
}
|
|
}
|