Merge pull request #1607 from crosbymichael/term-err
libcontainer: handler errors from terminate
This commit is contained in:
commit
74a1729647
|
@ -290,7 +290,7 @@ func (c *linuxContainer) start(process *Process, isInit bool) error {
|
||||||
}
|
}
|
||||||
if err := parent.start(); err != nil {
|
if err := parent.start(); err != nil {
|
||||||
// terminate the process to ensure that it properly is reaped.
|
// terminate the process to ensure that it properly is reaped.
|
||||||
if err := parent.terminate(); err != nil {
|
if err := ignoreTerminateErrors(parent.terminate()); err != nil {
|
||||||
logrus.Warn(err)
|
logrus.Warn(err)
|
||||||
}
|
}
|
||||||
return newSystemErrorWithCause(err, "starting container process")
|
return newSystemErrorWithCause(err, "starting container process")
|
||||||
|
@ -316,7 +316,7 @@ func (c *linuxContainer) start(process *Process, isInit bool) error {
|
||||||
}
|
}
|
||||||
for i, hook := range c.config.Hooks.Poststart {
|
for i, hook := range c.config.Hooks.Poststart {
|
||||||
if err := hook.Run(s); err != nil {
|
if err := hook.Run(s); err != nil {
|
||||||
if err := parent.terminate(); err != nil {
|
if err := ignoreTerminateErrors(parent.terminate()); err != nil {
|
||||||
logrus.Warn(err)
|
logrus.Warn(err)
|
||||||
}
|
}
|
||||||
return newSystemErrorWithCausef(err, "running poststart hook %d", i)
|
return newSystemErrorWithCausef(err, "running poststart hook %d", i)
|
||||||
|
@ -1776,3 +1776,18 @@ func (c *linuxContainer) bootstrapData(cloneFlags uintptr, nsMaps map[configs.Na
|
||||||
|
|
||||||
return bytes.NewReader(r.Serialize()), nil
|
return bytes.NewReader(r.Serialize()), nil
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// ignoreTerminateErrors returns nil if the given err matches an error known
|
||||||
|
// to indicate that the terminate occurred successfully or err was nil, otherwise
|
||||||
|
// err is returned unaltered.
|
||||||
|
func ignoreTerminateErrors(err error) error {
|
||||||
|
if err == nil {
|
||||||
|
return nil
|
||||||
|
}
|
||||||
|
s := err.Error()
|
||||||
|
switch {
|
||||||
|
case strings.Contains(s, "process already finished"), strings.Contains(s, "Wait was already called"):
|
||||||
|
return nil
|
||||||
|
}
|
||||||
|
return err
|
||||||
|
}
|
||||||
|
|
Loading…
Reference in New Issue