Skip to content

Commit

Permalink
Update checkpoint/restore to match changes in latest docker.
Browse files Browse the repository at this point in the history
Docker-DCO-1.1-Signed-off-by: Ross Boucher <rboucher@gmail.com> (github: boucher)
  • Loading branch information
boucher committed Aug 11, 2015
1 parent 39ac46b commit 59c375a
Show file tree
Hide file tree
Showing 10 changed files with 30 additions and 46 deletions.
3 changes: 2 additions & 1 deletion api/client/checkpoint.go
Expand Up @@ -5,12 +5,13 @@ package client
import (
"fmt"

Cli "github.com/docker/docker/cli"
flag "github.com/docker/docker/pkg/mflag"
"github.com/docker/docker/runconfig"
)

func (cli *DockerCli) CmdCheckpoint(args ...string) error {
cmd := cli.Subcmd("checkpoint", []string{"CONTAINER [CONTAINER...]"}, "Checkpoint one or more running containers", true)
cmd := Cli.Subcmd("checkpoint", []string{"CONTAINER [CONTAINER...]"}, "Checkpoint one or more running containers", true)
cmd.Require(flag.Min, 1)

var (
Expand Down
3 changes: 2 additions & 1 deletion api/client/restore.go
Expand Up @@ -5,12 +5,13 @@ package client
import (
"fmt"

Cli "github.com/docker/docker/cli"
flag "github.com/docker/docker/pkg/mflag"
"github.com/docker/docker/runconfig"
)

func (cli *DockerCli) CmdRestore(args ...string) error {
cmd := cli.Subcmd("restore", []string{"CONTAINER [CONTAINER...]"}, "Restore one or more checkpointed containers", true)
cmd := Cli.Subcmd("restore", []string{"CONTAINER [CONTAINER...]"}, "Restore one or more checkpointed containers", true)
cmd.Require(flag.Min, 1)

var (
Expand Down
6 changes: 3 additions & 3 deletions api/server/server_experimental_unix.go
Expand Up @@ -5,12 +5,12 @@ package server
import (
"encoding/json"
"fmt"
"net/http"
"github.com/docker/docker/pkg/version"
"github.com/docker/docker/runconfig"
)
"net/http"
)

func addExperimentalRoutes(s *Server, m map[string]map[string]HttpApiFunc) {
func addExperimentalRoutes(s *Server, m map[string]map[string]HTTPAPIFunc) {
m["POST"]["/containers/{name:.*}/checkpoint"] = s.postContainersCheckpoint
m["POST"]["/containers/{name:.*}/restore"] = s.postContainersRestore
}
Expand Down
2 changes: 1 addition & 1 deletion api/server/server_stub.go
Expand Up @@ -2,7 +2,7 @@

package server

func addExperimentalRoutes(s *Server, m map[string]map[string]HttpApiFunc) {
func addExperimentalRoutes(s *Server, m map[string]map[string]HTTPAPIFunc) {

}

Expand Down
18 changes: 9 additions & 9 deletions api/types/types.go
Expand Up @@ -228,16 +228,16 @@ type ExecStartCheck struct {
// it's part of ContainerJSONBase and will return by "inspect" command
type ContainerState struct {
Running bool
Paused bool
Paused bool
Checkpointed bool
Restarting bool
OOMKilled bool
Dead bool
Pid int
ExitCode int
Error string
StartedAt string
FinishedAt string
Restarting bool
OOMKilled bool
Dead bool
Pid int
ExitCode int
Error string
StartedAt string
FinishedAt string
CheckpointedAt string `json:"-"`
}

Expand Down
4 changes: 2 additions & 2 deletions daemon/execdriver/lxc/driver.go
Expand Up @@ -561,11 +561,11 @@ func (d *Driver) Unpause(c *execdriver.Command) error {
return err
}

func (d *driver) Checkpoint(c *execdriver.Command, opts *runconfig.CriuConfig) error {
func (d *Driver) Checkpoint(c *execdriver.Command, opts *runconfig.CriuConfig) error {
return fmt.Errorf("Checkpointing lxc containers not supported yet\n")
}

func (d *driver) Restore(c *execdriver.Command, pipes *execdriver.Pipes, restoreCallback execdriver.RestoreCallback, opts *runconfig.CriuConfig, forceRestore bool) (execdriver.ExitStatus, error) {
func (d *Driver) Restore(c *execdriver.Command, pipes *execdriver.Pipes, restoreCallback execdriver.RestoreCallback, opts *runconfig.CriuConfig, forceRestore bool) (execdriver.ExitStatus, error) {
return execdriver.ExitStatus{ExitCode: 0}, fmt.Errorf("Restoring lxc containers not supported yet\n")
}

Expand Down
18 changes: 0 additions & 18 deletions daemon/execdriver/native/create.go
Expand Up @@ -113,24 +113,6 @@ func generateIfaceName() (string, error) {
return "", errors.New("Failed to find name for new interface")
}

// Re-create the container type from the image that was saved during checkpoint.
func (d *driver) createRestoreContainer(c *execdriver.Command, imageDir string) (*libcontainer.Config, error) {
// Read the container.json.
f1, err := os.Open(filepath.Join(imageDir, "container.json"))
if err != nil {
return nil, err
}
defer f1.Close()

var container *libcontainer.Config
err = json.NewDecoder(f1).Decode(&container)
if err != nil {
return nil, err
}

return container, nil
}

func (d *Driver) createNetwork(container *configs.Config, c *execdriver.Command) error {
if c.Network == nil {
return nil
Expand Down
4 changes: 2 additions & 2 deletions daemon/execdriver/native/driver.go
Expand Up @@ -313,7 +313,7 @@ func libcontainerCriuOpts(runconfigOpts *runconfig.CriuConfig) *libcontainer.Cri
}
}

func (d *driver) Checkpoint(c *execdriver.Command, opts *runconfig.CriuConfig) error {
func (d *Driver) Checkpoint(c *execdriver.Command, opts *runconfig.CriuConfig) error {
active := d.activeContainers[c.ID]
if active == nil {
return fmt.Errorf("active container for %s does not exist", c.ID)
Expand All @@ -329,7 +329,7 @@ func (d *driver) Checkpoint(c *execdriver.Command, opts *runconfig.CriuConfig) e
return nil
}

func (d *driver) Restore(c *execdriver.Command, pipes *execdriver.Pipes, restoreCallback execdriver.RestoreCallback, opts *runconfig.CriuConfig, forceRestore bool) (execdriver.ExitStatus, error) {
func (d *Driver) Restore(c *execdriver.Command, pipes *execdriver.Pipes, restoreCallback execdriver.RestoreCallback, opts *runconfig.CriuConfig, forceRestore bool) (execdriver.ExitStatus, error) {
var (
cont libcontainer.Container
err error
Expand Down
16 changes: 8 additions & 8 deletions daemon/inspect.go
Expand Up @@ -45,14 +45,14 @@ func (daemon *Daemon) getInspectData(container *Container) (*types.ContainerJSON
Running: container.State.Running,
Paused: container.State.Paused,
Checkpointed: container.State.Checkpointed,
Restarting: container.State.Restarting,
OOMKilled: container.State.OOMKilled,
Dead: container.State.Dead,
Pid: container.State.Pid,
ExitCode: container.State.ExitCode,
Error: container.State.Error,
StartedAt: container.State.StartedAt.Format(time.RFC3339Nano),
FinishedAt: container.State.FinishedAt.Format(time.RFC3339Nano),
Restarting: container.State.Restarting,
OOMKilled: container.State.OOMKilled,
Dead: container.State.Dead,
Pid: container.State.Pid,
ExitCode: container.State.ExitCode,
Error: container.State.Error,
StartedAt: container.State.StartedAt.Format(time.RFC3339Nano),
FinishedAt: container.State.FinishedAt.Format(time.RFC3339Nano),
CheckpointedAt: container.State.CheckpointedAt.Format(time.RFC3339Nano),
}

Expand Down
2 changes: 1 addition & 1 deletion docker/docker.go
Expand Up @@ -3,6 +3,7 @@ package main
import (
"fmt"
"os"
"sort"

"github.com/Sirupsen/logrus"
"github.com/docker/docker/api/client"
Expand Down Expand Up @@ -35,7 +36,6 @@ func main() {

help := "\nCommands:\n"

// TODO(tiborvass): no need to sort if we ensure dockerCommands is sorted
allCommands := append(dockerCommands, experimentalCommands...)
sort.Sort(byName(allCommands))

Expand Down

0 comments on commit 59c375a

Please sign in to comment.