mirror of
https://github.com/clearlinux/docker.git
synced 2026-08-28 13:25:42 +00:00
Merge pull request #8315 from dqminh/save-start-error
Save start error into State.Error when the container fails to start
This commit is contained in:
@@ -297,6 +297,8 @@ func (container *Container) Start() (err error) {
|
||||
// setup has been cleaned up properly
|
||||
defer func() {
|
||||
if err != nil {
|
||||
container.setError(err)
|
||||
container.toDisk()
|
||||
container.cleanup()
|
||||
}
|
||||
}()
|
||||
|
||||
@@ -15,6 +15,7 @@ type State struct {
|
||||
Restarting bool
|
||||
Pid int
|
||||
ExitCode int
|
||||
Error string // contains last known error when starting the container
|
||||
StartedAt time.Time
|
||||
FinishedAt time.Time
|
||||
waitChan chan struct{}
|
||||
@@ -137,6 +138,7 @@ func (s *State) SetRunning(pid int) {
|
||||
}
|
||||
|
||||
func (s *State) setRunning(pid int) {
|
||||
s.Error = ""
|
||||
s.Running = true
|
||||
s.Paused = false
|
||||
s.Restarting = false
|
||||
@@ -179,6 +181,13 @@ func (s *State) SetRestarting(exitCode int) {
|
||||
s.Unlock()
|
||||
}
|
||||
|
||||
// setError sets the container's error state. This is useful when we want to
|
||||
// know the error that occurred when container transits to another state
|
||||
// when inspecting it
|
||||
func (s *State) setError(err error) {
|
||||
s.Error = err.Error()
|
||||
}
|
||||
|
||||
func (s *State) IsRestarting() bool {
|
||||
s.Lock()
|
||||
res := s.Restarting
|
||||
|
||||
Reference in New Issue
Block a user