Skip to content
This repository has been archived by the owner on Oct 13, 2023. It is now read-only.

Commit

Permalink
Merge pull request #358 from thaJeztah/19.03_backport_exec_failure_event
Browse files Browse the repository at this point in the history
[19.03 backport] Send exec exit event on failures
Upstream-commit: 879fba29d54b4403bb11cc69fa0ba9b6b4aca7c2
Component: engine
  • Loading branch information
thaJeztah committed Sep 20, 2019
2 parents 6a94234 + 36d6bc9 commit c7ae679
Showing 1 changed file with 8 additions and 11 deletions.
19 changes: 8 additions & 11 deletions components/engine/daemon/monitor.go
Original file line number Diff line number Diff line change
Expand Up @@ -117,6 +117,7 @@ func (daemon *Daemon) ProcessEvent(id string, e libcontainerdtypes.EventType, ei
return cpErr
}

exitCode := 127
if execConfig := c.ExecCommands.Get(ei.ProcessID); execConfig != nil {
ec := int(ei.ExitCode)
execConfig.Lock()
Expand All @@ -131,18 +132,14 @@ func (daemon *Daemon) ProcessEvent(id string, e libcontainerdtypes.EventType, ei
// remove the exec command from the container's store only and not the
// daemon's store so that the exec command can be inspected.
c.ExecCommands.Delete(execConfig.ID, execConfig.Pid)
attributes := map[string]string{
"execID": execConfig.ID,
"exitCode": strconv.Itoa(ec),
}
daemon.LogContainerEventWithAttributes(c, "exec_die", attributes)
} else {
logrus.WithFields(logrus.Fields{
"container": c.ID,
"exec-id": ei.ProcessID,
"exec-pid": ei.Pid,
}).Warn("Ignoring Exit Event, no such exec command found")

exitCode = ec
}
attributes := map[string]string{
"execID": ei.ProcessID,
"exitCode": strconv.Itoa(exitCode),
}
daemon.LogContainerEventWithAttributes(c, "exec_die", attributes)
case libcontainerdtypes.EventStart:
c.Lock()
defer c.Unlock()
Expand Down

0 comments on commit c7ae679

Please sign in to comment.