Remove start/die event when fail to start container
If contaner start fail of (say) "command not found", the container actually didn't start at all, we shouldn't log start and die event for it, because that doesnt actually happen. Signed-off-by: Zhang Wei <zhangwei555@huawei.com> Upstream-commit: 5548966c37147875fb5e07f4ba7f633dd882c782 Component: engine
This commit is contained in:
@ -107,10 +107,6 @@ func (daemon *Daemon) containerStart(container *container.Container) (err error)
|
||||
}
|
||||
container.ToDisk()
|
||||
daemon.Cleanup(container)
|
||||
attributes := map[string]string{
|
||||
"exitCode": fmt.Sprintf("%d", container.ExitCode),
|
||||
}
|
||||
daemon.LogContainerEventWithAttributes(container, "die", attributes)
|
||||
}
|
||||
}()
|
||||
|
||||
@ -149,8 +145,6 @@ func (daemon *Daemon) containerStart(container *container.Container) (err error)
|
||||
|
||||
container.Reset(false)
|
||||
|
||||
// start event is logged even on error
|
||||
daemon.LogContainerEvent(container, "start")
|
||||
return err
|
||||
}
|
||||
|
||||
|
||||
@ -95,8 +95,16 @@ func (s *DockerSuite) TestEventsContainerFailStartDie(c *check.C) {
|
||||
dieEvent = true
|
||||
}
|
||||
}
|
||||
c.Assert(startEvent, checker.True, check.Commentf("Start event not found: %v\n%v", actions, events))
|
||||
c.Assert(dieEvent, checker.True, check.Commentf("Die event not found: %v\n%v", actions, events))
|
||||
|
||||
// Windows platform is different from Linux, it will start container whatever
|
||||
// so Windows can get start/die event but Linux can't
|
||||
if daemonPlatform == "windows" {
|
||||
c.Assert(startEvent, checker.True, check.Commentf("Start event not found: %v\n%v", actions, events))
|
||||
c.Assert(dieEvent, checker.True, check.Commentf("Die event not found: %v\n%v", actions, events))
|
||||
} else {
|
||||
c.Assert(startEvent, checker.False, check.Commentf("Start event not expected: %v\n%v", actions, events))
|
||||
c.Assert(dieEvent, checker.False, check.Commentf("Die event not expected: %v\n%v", actions, events))
|
||||
}
|
||||
}
|
||||
|
||||
func (s *DockerSuite) TestEventsLimit(c *check.C) {
|
||||
|
||||
Reference in New Issue
Block a user