Merge pull request #26973 from allencloud/change-code-in-container-restore

change code in container restore
This commit is contained in:
Sebastiaan van Stijn 2016-10-21 18:53:38 -07:00 committed by GitHub
commit a6688959b4
2 changed files with 3 additions and 59 deletions

View file

@ -52,7 +52,6 @@ import (
"github.com/docker/docker/reference"
"github.com/docker/docker/registry"
"github.com/docker/docker/runconfig"
"github.com/docker/docker/utils"
volumedrivers "github.com/docker/docker/volume/drivers"
"github.com/docker/docker/volume/local"
"github.com/docker/docker/volume/store"
@ -107,27 +106,20 @@ type Daemon struct {
func (daemon *Daemon) restore() error {
var (
debug = utils.IsDebugEnabled()
currentDriver = daemon.GraphDriverName()
containers = make(map[string]*container.Container)
)
if !debug {
logrus.Info("Loading containers: start.")
}
logrus.Info("Loading containers: start.")
dir, err := ioutil.ReadDir(daemon.repository)
if err != nil {
return err
}
containerCount := 0
for _, v := range dir {
id := v.Name()
container, err := daemon.load(id)
if !debug && logrus.GetLevel() == logrus.InfoLevel {
fmt.Print(".")
containerCount++
}
if err != nil {
logrus.Errorf("Failed to load container %v: %v", id, err)
continue
@ -352,12 +344,7 @@ func (daemon *Daemon) restore() error {
group.Wait()
if !debug {
if logrus.GetLevel() == logrus.InfoLevel && containerCount > 0 {
fmt.Println()
}
logrus.Info("Loading containers: done.")
}
logrus.Info("Loading containers: done.")
return nil
}

View file

@ -1265,49 +1265,6 @@ func (s *DockerDaemonSuite) TestDaemonLoggingDriverNoneLogsError(c *check.C) {
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) {
dir, err := ioutil.TempDir("", "socket-cleanup-test")
if err != nil {