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

Method Checkpoint

client/task.go:551–640  ·  view source on GitHub ↗

NOTE: Checkpoint supports to dump task information to a directory, in this way, an empty OCI Index will be returned.

(ctx context.Context, opts ...CheckpointTaskOpts)

Source from the content-addressed store, hash-verified

549// NOTE: Checkpoint supports to dump task information to a directory, in this way, an empty
550// OCI Index will be returned.
551func (t *task) Checkpoint(ctx context.Context, opts ...CheckpointTaskOpts) (Image, error) {
552 ctx, done, err := t.client.WithLease(ctx)
553 if err != nil {
554 return nil, err
555 }
556 defer done(ctx)
557 cr, err := t.client.ContainerService().Get(ctx, t.id)
558 if err != nil {
559 return nil, err
560 }
561
562 request := &tasks.CheckpointTaskRequest{
563 ContainerID: t.id,
564 }
565 i := CheckpointTaskInfo{
566 runtime: cr.Runtime.Name,
567 }
568 for _, o := range opts {
569 if err := o(&i); err != nil {
570 return nil, err
571 }
572 }
573 // set a default name
574 if i.Name == "" {
575 i.Name = fmt.Sprintf(checkpointNameFormat, t.id, time.Now().Format(checkpointDateFormat))
576 }
577 request.ParentCheckpoint = i.ParentCheckpoint.String()
578 if i.Options != nil {
579 o, err := typeurl.MarshalAnyToProto(i.Options)
580 if err != nil {
581 return nil, err
582 }
583 request.Options = o
584 }
585
586 status, err := t.Status(ctx)
587 if err != nil {
588 return nil, err
589 }
590
591 if status.Status != Paused {
592 // make sure we pause it and resume after all other filesystem operations are completed
593 if err := t.Pause(ctx); err != nil {
594 return nil, err
595 }
596 defer t.Resume(ctx)
597 }
598
599 index := v1.Index{
600 Versioned: is.Versioned{
601 SchemaVersion: 2,
602 },
603 Annotations: make(map[string]string),
604 }
605 if err := t.checkpointTask(ctx, &index, request); err != nil {
606 return nil, err
607 }
608 // if checkpoint image path passed, jump checkpoint image,

Callers

nothing calls this directly

Calls 15

StatusMethod · 0.95
PauseMethod · 0.95
ResumeMethod · 0.95
checkpointTaskMethod · 0.95
checkpointImageMethod · 0.95
checkpointRWSnapshotMethod · 0.95
isCheckpointPathExistFunction · 0.85
NewImageFunction · 0.85
writeIndexFunction · 0.85
ContainerServiceMethod · 0.80
FormatMethod · 0.80
WithLeaseMethod · 0.65

Tested by

no test coverage detected