fixup! conmon: Don't leave zombies and fix cgroup race

Signed-off-by: Alexander Larsson <alexl@redhat.com>
This commit is contained in:
Alexander Larsson 2017-06-20 12:18:07 +02:00
parent af4fbcd942
commit 72686c78b4
2 changed files with 31 additions and 62 deletions

View file

@ -200,21 +200,10 @@ func (r *Runtime) CreateContainer(c *Container, cgroupParent string) error {
return fmt.Errorf("error reading container (probably exited) json message: %v", ss.err)
}
logrus.Debugf("Received container pid: %d", ss.si.Pid)
errorMessage := ""
if c.terminal {
errorMessage = stderrBuf.String()
fmt.Fprintf(os.Stderr, errorMessage)
errorMessage = sanitizeConmonErrorMessage(errorMessage)
} else {
if ss.si.Message != "" {
errorMessage = ss.si.Message
}
}
if ss.si.Pid == -1 {
if errorMessage != "" {
logrus.Debugf("Container creation error: %s", errorMessage)
return fmt.Errorf("container create failed: %s", errorMessage)
if ss.si.Message != "" {
logrus.Debugf("Container creation error: %s", ss.si.Message)
return fmt.Errorf("container create failed: %s", ss.si.Message)
}
logrus.Debugf("Container creation failed")
return fmt.Errorf("container create failed")
@ -225,18 +214,6 @@ func (r *Runtime) CreateContainer(c *Container, cgroupParent string) error {
return nil
}
// sanitizeConmonErrorMessage removes conmon debug messages from error string
func sanitizeConmonErrorMessage(errString string) string {
var sanitizedLines []string
lines := strings.Split(errString, "\n")
for _, line := range lines {
if !strings.HasPrefix(line, "[conmon") {
sanitizedLines = append(sanitizedLines, line)
}
}
return strings.Join(sanitizedLines, "\n")
}
func createUnitName(prefix string, name string) string {
return fmt.Sprintf("%s-%s.scope", prefix, name)
}