Sfoglia il codice sorgente

libc8d/local: set task id to container id

ContainerD unconditionally sets the ID of a task to its container's ID.
Emulate this behaviour in the libcontainerd local_windows implementation
so that the daemon can use ProcessID == ContainerID (in libcontainerd
terminology) to identify that an exit event is for the container's task
and not for another process (i.e. an exec) in the same container.

Signed-off-by: Cory Snider <csnider@mirantis.com>
Cory Snider 2 anni fa
parent
commit
719b08313f
1 ha cambiato i file con 4 aggiunte e 4 eliminazioni
  1. 4 4
      libcontainerd/local/local_windows.go

+ 4 - 4
libcontainerd/local/local_windows.go

@@ -461,7 +461,7 @@ func (ctr *container) Start(_ context.Context, _ string, withStdin bool, attachS
 		}
 	}()
 	t := &task{process: process{
-		id:         libcontainerdtypes.InitProcessName,
+		id:         ctr.id,
 		ctr:        ctr,
 		hcsProcess: newProcess,
 		waitCh:     make(chan struct{}),
@@ -495,7 +495,7 @@ func (ctr *container) Start(_ context.Context, _ string, withStdin bool, attachS
 	ctr.client.eventQ.Append(ctr.id, func() {
 		ei := libcontainerdtypes.EventInfo{
 			ContainerID: ctr.id,
-			ProcessID:   libcontainerdtypes.InitProcessName,
+			ProcessID:   t.id,
 			Pid:         pid,
 		}
 		ctr.client.logger.WithFields(logrus.Fields{
@@ -793,7 +793,7 @@ func (t *task) Pause(_ context.Context) error {
 	t.ctr.client.eventQ.Append(t.ctr.id, func() {
 		err := t.ctr.client.backend.ProcessEvent(t.ctr.id, libcontainerdtypes.EventPaused, libcontainerdtypes.EventInfo{
 			ContainerID: t.ctr.id,
-			ProcessID:   libcontainerdtypes.InitProcessName,
+			ProcessID:   t.id,
 		})
 		t.ctr.client.logger.WithFields(logrus.Fields{
 			"container": t.ctr.id,
@@ -834,7 +834,7 @@ func (t *task) Resume(ctx context.Context) error {
 	t.ctr.client.eventQ.Append(t.ctr.id, func() {
 		err := t.ctr.client.backend.ProcessEvent(t.ctr.id, libcontainerdtypes.EventResumed, libcontainerdtypes.EventInfo{
 			ContainerID: t.ctr.id,
-			ProcessID:   libcontainerdtypes.InitProcessName,
+			ProcessID:   t.id,
 		})
 		t.ctr.client.logger.WithFields(logrus.Fields{
 			"container": t.ctr.id,