Add support for specifying a checkpoint directory. (#245)

Signed-off-by: Ross Boucher <rboucher@gmail.com>
This commit is contained in:
Ross Boucher 2016-05-25 20:42:37 -04:00 committed by Michael Crosby
parent 76dd6710dc
commit e756ae42d1
10 changed files with 291 additions and 228 deletions

View file

@ -6,8 +6,9 @@ import "github.com/docker/containerd/runtime"
type CreateCheckpointTask struct {
baseTask
ID string
Checkpoint *runtime.Checkpoint
ID string
CheckpointDir string
Checkpoint *runtime.Checkpoint
}
func (s *Supervisor) createCheckpoint(t *CreateCheckpointTask) error {
@ -15,13 +16,14 @@ func (s *Supervisor) createCheckpoint(t *CreateCheckpointTask) error {
if !ok {
return ErrContainerNotFound
}
return i.container.Checkpoint(*t.Checkpoint)
return i.container.Checkpoint(*t.Checkpoint, t.CheckpointDir)
}
type DeleteCheckpointTask struct {
baseTask
ID string
Checkpoint *runtime.Checkpoint
ID string
CheckpointDir string
Checkpoint *runtime.Checkpoint
}
func (s *Supervisor) deleteCheckpoint(t *DeleteCheckpointTask) error {
@ -29,5 +31,5 @@ func (s *Supervisor) deleteCheckpoint(t *DeleteCheckpointTask) error {
if !ok {
return ErrContainerNotFound
}
return i.container.DeleteCheckpoint(t.Checkpoint.Name)
return i.container.DeleteCheckpoint(t.Checkpoint.Name, t.CheckpointDir)
}

View file

@ -1,6 +1,7 @@
package supervisor
import (
"path/filepath"
"time"
"github.com/docker/containerd/runtime"
@ -17,6 +18,7 @@ type StartTask struct {
Labels []string
NoPivotRoot bool
Checkpoint *runtime.Checkpoint
CheckpointDir string
Runtime string
RuntimeArgs []string
}
@ -56,7 +58,7 @@ func (s *Supervisor) start(t *StartTask) error {
Stderr: t.Stderr,
}
if t.Checkpoint != nil {
task.Checkpoint = t.Checkpoint.Name
task.CheckpointPath = filepath.Join(t.CheckpointDir, t.Checkpoint.Name)
}
s.startTasks <- task

View file

@ -13,13 +13,13 @@ type Worker interface {
}
type startTask struct {
Container runtime.Container
Checkpoint string
Stdin string
Stdout string
Stderr string
Err chan error
StartResponse chan StartResponse
Container runtime.Container
CheckpointPath string
Stdin string
Stdout string
Stderr string
Err chan error
StartResponse chan StartResponse
}
func NewWorker(s *Supervisor, wg *sync.WaitGroup) Worker {
@ -38,7 +38,7 @@ func (w *worker) Start() {
defer w.wg.Done()
for t := range w.s.startTasks {
started := time.Now()
process, err := t.Container.Start(t.Checkpoint, runtime.NewStdio(t.Stdin, t.Stdout, t.Stderr))
process, err := t.Container.Start(t.CheckpointPath, runtime.NewStdio(t.Stdin, t.Stdout, t.Stderr))
if err != nil {
logrus.WithFields(logrus.Fields{
"error": err,