mirror of
https://github.com/moby/moby.git
synced 2022-11-09 12:21:53 -05:00
Merge pull request #26973 from allencloud/change-code-in-container-restore
change code in container restore
This commit is contained in:
commit
a6688959b4
2 changed files with 3 additions and 59 deletions
|
@ -52,7 +52,6 @@ import (
|
||||||
"github.com/docker/docker/reference"
|
"github.com/docker/docker/reference"
|
||||||
"github.com/docker/docker/registry"
|
"github.com/docker/docker/registry"
|
||||||
"github.com/docker/docker/runconfig"
|
"github.com/docker/docker/runconfig"
|
||||||
"github.com/docker/docker/utils"
|
|
||||||
volumedrivers "github.com/docker/docker/volume/drivers"
|
volumedrivers "github.com/docker/docker/volume/drivers"
|
||||||
"github.com/docker/docker/volume/local"
|
"github.com/docker/docker/volume/local"
|
||||||
"github.com/docker/docker/volume/store"
|
"github.com/docker/docker/volume/store"
|
||||||
|
@ -107,27 +106,20 @@ type Daemon struct {
|
||||||
|
|
||||||
func (daemon *Daemon) restore() error {
|
func (daemon *Daemon) restore() error {
|
||||||
var (
|
var (
|
||||||
debug = utils.IsDebugEnabled()
|
|
||||||
currentDriver = daemon.GraphDriverName()
|
currentDriver = daemon.GraphDriverName()
|
||||||
containers = make(map[string]*container.Container)
|
containers = make(map[string]*container.Container)
|
||||||
)
|
)
|
||||||
|
|
||||||
if !debug {
|
logrus.Info("Loading containers: start.")
|
||||||
logrus.Info("Loading containers: start.")
|
|
||||||
}
|
|
||||||
dir, err := ioutil.ReadDir(daemon.repository)
|
dir, err := ioutil.ReadDir(daemon.repository)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return err
|
return err
|
||||||
}
|
}
|
||||||
|
|
||||||
containerCount := 0
|
|
||||||
for _, v := range dir {
|
for _, v := range dir {
|
||||||
id := v.Name()
|
id := v.Name()
|
||||||
container, err := daemon.load(id)
|
container, err := daemon.load(id)
|
||||||
if !debug && logrus.GetLevel() == logrus.InfoLevel {
|
|
||||||
fmt.Print(".")
|
|
||||||
containerCount++
|
|
||||||
}
|
|
||||||
if err != nil {
|
if err != nil {
|
||||||
logrus.Errorf("Failed to load container %v: %v", id, err)
|
logrus.Errorf("Failed to load container %v: %v", id, err)
|
||||||
continue
|
continue
|
||||||
|
@ -352,12 +344,7 @@ func (daemon *Daemon) restore() error {
|
||||||
|
|
||||||
group.Wait()
|
group.Wait()
|
||||||
|
|
||||||
if !debug {
|
logrus.Info("Loading containers: done.")
|
||||||
if logrus.GetLevel() == logrus.InfoLevel && containerCount > 0 {
|
|
||||||
fmt.Println()
|
|
||||||
}
|
|
||||||
logrus.Info("Loading containers: done.")
|
|
||||||
}
|
|
||||||
|
|
||||||
return nil
|
return nil
|
||||||
}
|
}
|
||||||
|
|
|
@ -1265,49 +1265,6 @@ func (s *DockerDaemonSuite) TestDaemonLoggingDriverNoneLogsError(c *check.C) {
|
||||||
c.Assert(out, checker.Contains, expected)
|
c.Assert(out, checker.Contains, expected)
|
||||||
}
|
}
|
||||||
|
|
||||||
func (s *DockerDaemonSuite) TestDaemonDots(c *check.C) {
|
|
||||||
if err := s.d.StartWithBusybox(); err != nil {
|
|
||||||
c.Fatal(err)
|
|
||||||
}
|
|
||||||
|
|
||||||
// Now create 4 containers
|
|
||||||
if _, err := s.d.Cmd("create", "busybox"); err != nil {
|
|
||||||
c.Fatalf("Error creating container: %q", err)
|
|
||||||
}
|
|
||||||
if _, err := s.d.Cmd("create", "busybox"); err != nil {
|
|
||||||
c.Fatalf("Error creating container: %q", err)
|
|
||||||
}
|
|
||||||
if _, err := s.d.Cmd("create", "busybox"); err != nil {
|
|
||||||
c.Fatalf("Error creating container: %q", err)
|
|
||||||
}
|
|
||||||
if _, err := s.d.Cmd("create", "busybox"); err != nil {
|
|
||||||
c.Fatalf("Error creating container: %q", err)
|
|
||||||
}
|
|
||||||
|
|
||||||
s.d.Stop()
|
|
||||||
|
|
||||||
s.d.Start("--log-level=debug")
|
|
||||||
s.d.Stop()
|
|
||||||
content, _ := ioutil.ReadFile(s.d.logFile.Name())
|
|
||||||
if strings.Contains(string(content), "....") {
|
|
||||||
c.Fatalf("Debug level should not have ....\n%s", string(content))
|
|
||||||
}
|
|
||||||
|
|
||||||
s.d.Start("--log-level=error")
|
|
||||||
s.d.Stop()
|
|
||||||
content, _ = ioutil.ReadFile(s.d.logFile.Name())
|
|
||||||
if strings.Contains(string(content), "....") {
|
|
||||||
c.Fatalf("Error level should not have ....\n%s", string(content))
|
|
||||||
}
|
|
||||||
|
|
||||||
s.d.Start("--log-level=info")
|
|
||||||
s.d.Stop()
|
|
||||||
content, _ = ioutil.ReadFile(s.d.logFile.Name())
|
|
||||||
if !strings.Contains(string(content), "....") {
|
|
||||||
c.Fatalf("Info level should have ....\n%s", string(content))
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
func (s *DockerDaemonSuite) TestDaemonUnixSockCleanedUp(c *check.C) {
|
func (s *DockerDaemonSuite) TestDaemonUnixSockCleanedUp(c *check.C) {
|
||||||
dir, err := ioutil.TempDir("", "socket-cleanup-test")
|
dir, err := ioutil.TempDir("", "socket-cleanup-test")
|
||||||
if err != nil {
|
if err != nil {
|
||||||
|
|
Loading…
Add table
Reference in a new issue