mirror of
https://github.com/moby/moby.git
synced 2022-11-09 12:21:53 -05:00
"Fix" checkpoint on v2 runtime
Checkpoint/Restore is horribly broken all around. But on the, now default, v2 runtime it's even more broken. This at least makes checkpoint equally broken on both runtimes. Signed-off-by: Brian Goff <cpuguy83@gmail.com>
This commit is contained in:
parent
9c15e82f19
commit
f14aea63c9
1 changed files with 27 additions and 14 deletions
|
@ -511,26 +511,39 @@ func (c *client) Status(ctx context.Context, containerID string) (containerd.Pro
|
||||||
return s.Status, nil
|
return s.Status, nil
|
||||||
}
|
}
|
||||||
|
|
||||||
|
func (c *client) getCheckpointOptions(id string, exit bool) containerd.CheckpointTaskOpts {
|
||||||
|
return func(r *containerd.CheckpointTaskInfo) error {
|
||||||
|
if r.Options == nil {
|
||||||
|
c.v2runcoptionsMu.Lock()
|
||||||
|
_, isV2 := c.v2runcoptions[id]
|
||||||
|
c.v2runcoptionsMu.Unlock()
|
||||||
|
|
||||||
|
if isV2 {
|
||||||
|
r.Options = &v2runcoptions.CheckpointOptions{Exit: exit}
|
||||||
|
} else {
|
||||||
|
r.Options = &runctypes.CheckpointOptions{Exit: exit}
|
||||||
|
}
|
||||||
|
return nil
|
||||||
|
}
|
||||||
|
|
||||||
|
switch opts := r.Options.(type) {
|
||||||
|
case *v2runcoptions.CheckpointOptions:
|
||||||
|
opts.Exit = exit
|
||||||
|
case *runctypes.CheckpointOptions:
|
||||||
|
opts.Exit = exit
|
||||||
|
}
|
||||||
|
|
||||||
|
return nil
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
func (c *client) CreateCheckpoint(ctx context.Context, containerID, checkpointDir string, exit bool) error {
|
func (c *client) CreateCheckpoint(ctx context.Context, containerID, checkpointDir string, exit bool) error {
|
||||||
p, err := c.getProcess(ctx, containerID, libcontainerdtypes.InitProcessName)
|
p, err := c.getProcess(ctx, containerID, libcontainerdtypes.InitProcessName)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return err
|
return err
|
||||||
}
|
}
|
||||||
|
|
||||||
opts := []containerd.CheckpointTaskOpts{}
|
opts := []containerd.CheckpointTaskOpts{c.getCheckpointOptions(containerID, exit)}
|
||||||
if exit {
|
|
||||||
opts = append(opts, func(r *containerd.CheckpointTaskInfo) error {
|
|
||||||
if r.Options == nil {
|
|
||||||
r.Options = &runctypes.CheckpointOptions{
|
|
||||||
Exit: true,
|
|
||||||
}
|
|
||||||
} else {
|
|
||||||
opts, _ := r.Options.(*runctypes.CheckpointOptions)
|
|
||||||
opts.Exit = true
|
|
||||||
}
|
|
||||||
return nil
|
|
||||||
})
|
|
||||||
}
|
|
||||||
img, err := p.(containerd.Task).Checkpoint(ctx, opts...)
|
img, err := p.(containerd.Task).Checkpoint(ctx, opts...)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return wrapError(err)
|
return wrapError(err)
|
||||||
|
|
Loading…
Reference in a new issue