MCPcopy
hub / github.com/containerd/containerd / Checkpoint

Method Checkpoint

client/container.go:415–477  ·  view source on GitHub ↗
(ctx context.Context, ref string, opts ...CheckpointOpts)

Source from the content-addressed store, hash-verified

413}
414
415func (c *container) Checkpoint(ctx context.Context, ref string, opts ...CheckpointOpts) (Image, error) {
416 index := &ocispec.Index{
417 Versioned: ver.Versioned{
418 SchemaVersion: 2,
419 },
420 Annotations: make(map[string]string),
421 }
422 copts := &options.CheckpointOptions{
423 Exit: false,
424 OpenTcp: false,
425 ExternalUnixSockets: false,
426 Terminal: false,
427 FileLocks: true,
428 EmptyNamespaces: nil,
429 }
430 info, err := c.Info(ctx)
431 if err != nil {
432 return nil, err
433 }
434
435 img, err := c.Image(ctx)
436 if err != nil {
437 return nil, err
438 }
439
440 ctx, done, err := c.client.WithLease(ctx)
441 if err != nil {
442 return nil, err
443 }
444 defer done(ctx)
445
446 // add image name to manifest
447 index.Annotations[ocispec.AnnotationRefName] = img.Name()
448 // add runtime info to index
449 index.Annotations[checkpointRuntimeNameLabel] = info.Runtime.Name
450 // add snapshotter info to index
451 index.Annotations[checkpointSnapshotterNameLabel] = info.Snapshotter
452
453 // process remaining opts
454 for _, o := range opts {
455 if err := o(ctx, c.client, &info, index, copts); err != nil {
456 err = errgrpc.ToNative(err)
457 if !errdefs.IsAlreadyExists(err) {
458 return nil, err
459 }
460 }
461 }
462
463 desc, err := writeIndex(ctx, index, c.client, c.ID()+"index")
464 if err != nil {
465 return nil, err
466 }
467 i := images.Image{
468 Name: ref,
469 Target: desc,
470 }
471 checkpoint, err := c.client.ImageService().Create(ctx, i)
472 if err != nil {

Callers

nothing calls this directly

Calls 9

InfoMethod · 0.95
ImageMethod · 0.95
IDMethod · 0.95
writeIndexFunction · 0.85
NewImageFunction · 0.85
WithLeaseMethod · 0.65
NameMethod · 0.65
CreateMethod · 0.65
ImageServiceMethod · 0.65

Tested by

no test coverage detected