libcontainerd/client: Rename cp to checkpoint

Make the variable longer to give a hint about it's broader scope.

Signed-off-by: Paweł Gronowski <pawel.gronowski@docker.com>
This commit is contained in:
Paweł Gronowski 2023-03-01 14:25:20 +01:00
parent 0c751f904f
commit 47e9caede7
No known key found for this signature in database
GPG key ID: B85EFCFE26DEF92A

View file

@ -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)
@ -155,15 +155,15 @@ func (c *container) Start(ctx context.Context, checkpointDir string, withStdin b
// write checkpoint to the content store // write checkpoint to the content store
tar := archive.Diff(ctx, "", checkpointDir) tar := archive.Diff(ctx, "", checkpointDir)
var err error var err error
cp, err = c.client.writeContent(ctx, images.MediaTypeContainerd1Checkpoint, checkpointDir, tar) 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 { if checkpoint != nil {
err := c.client.client.ContentStore().Delete(ctx, cp.Digest) 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")
} }
} }
@ -193,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
}, },
} }