Fixes #39427
This always sends the exec exit events even when the exec fails to find
the binary. A standard 127 exit status is sent in this situation.
Signed-off-by: Michael Crosby <crosbymichael@gmail.com>
(cherry picked from commit c08d4da6e58799465317599804d46a530cc0f704)
Signed-off-by: Sebastiaan van Stijn <github@gone.nl>
| ... | ... |
@@ -117,6 +117,7 @@ func (daemon *Daemon) ProcessEvent(id string, e libcontainerdtypes.EventType, ei |
| 117 | 117 |
return cpErr |
| 118 | 118 |
} |
| 119 | 119 |
|
| 120 |
+ exitCode := 127 |
|
| 120 | 121 |
if execConfig := c.ExecCommands.Get(ei.ProcessID); execConfig != nil {
|
| 121 | 122 |
ec := int(ei.ExitCode) |
| 122 | 123 |
execConfig.Lock() |
| ... | ... |
@@ -131,18 +132,14 @@ func (daemon *Daemon) ProcessEvent(id string, e libcontainerdtypes.EventType, ei |
| 131 | 131 |
// remove the exec command from the container's store only and not the |
| 132 | 132 |
// daemon's store so that the exec command can be inspected. |
| 133 | 133 |
c.ExecCommands.Delete(execConfig.ID, execConfig.Pid) |
| 134 |
- attributes := map[string]string{
|
|
| 135 |
- "execID": execConfig.ID, |
|
| 136 |
- "exitCode": strconv.Itoa(ec), |
|
| 137 |
- } |
|
| 138 |
- daemon.LogContainerEventWithAttributes(c, "exec_die", attributes) |
|
| 139 |
- } else {
|
|
| 140 |
- logrus.WithFields(logrus.Fields{
|
|
| 141 |
- "container": c.ID, |
|
| 142 |
- "exec-id": ei.ProcessID, |
|
| 143 |
- "exec-pid": ei.Pid, |
|
| 144 |
- }).Warn("Ignoring Exit Event, no such exec command found")
|
|
| 134 |
+ |
|
| 135 |
+ exitCode = ec |
|
| 136 |
+ } |
|
| 137 |
+ attributes := map[string]string{
|
|
| 138 |
+ "execID": ei.ProcessID, |
|
| 139 |
+ "exitCode": strconv.Itoa(exitCode), |
|
| 145 | 140 |
} |
| 141 |
+ daemon.LogContainerEventWithAttributes(c, "exec_die", attributes) |
|
| 146 | 142 |
case libcontainerdtypes.EventStart: |
| 147 | 143 |
c.Lock() |
| 148 | 144 |
defer c.Unlock() |