Procházet zdrojové kódy

Merge pull request #39434 from crosbymichael/exec-failure-event

Send exec exit event on failures
Akihiro Suda před 6 roky
rodič
revize
c7d1908d90
1 změnil soubory, kde provedl 8 přidání a 11 odebrání
  1. 8 11
      daemon/monitor.go

+ 8 - 11
daemon/monitor.go

@@ -118,6 +118,7 @@ func (daemon *Daemon) ProcessEvent(id string, e libcontainerdtypes.EventType, ei
 			return cpErr
 			return cpErr
 		}
 		}
 
 
+		exitCode := 127
 		if execConfig := c.ExecCommands.Get(ei.ProcessID); execConfig != nil {
 		if execConfig := c.ExecCommands.Get(ei.ProcessID); execConfig != nil {
 			ec := int(ei.ExitCode)
 			ec := int(ei.ExitCode)
 			execConfig.Lock()
 			execConfig.Lock()
@@ -135,18 +136,14 @@ func (daemon *Daemon) ProcessEvent(id string, e libcontainerdtypes.EventType, ei
 			// remove the exec command from the container's store only and not the
 			// remove the exec command from the container's store only and not the
 			// daemon's store so that the exec command can be inspected.
 			// daemon's store so that the exec command can be inspected.
 			c.ExecCommands.Delete(execConfig.ID, execConfig.Pid)
 			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:
 	case libcontainerdtypes.EventStart:
 		c.Lock()
 		c.Lock()
 		defer c.Unlock()
 		defer c.Unlock()