From 719b08313f246b6bcb0000a391500c720fcee6c8 Mon Sep 17 00:00:00 2001 From: Cory Snider Date: Mon, 30 Jan 2023 13:26:26 -0500 Subject: [PATCH] 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 --- libcontainerd/local/local_windows.go | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/libcontainerd/local/local_windows.go b/libcontainerd/local/local_windows.go index da71805dbd..41c50e6e73 100644 --- a/libcontainerd/local/local_windows.go +++ b/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,