Merge pull request #44888 from corhere/fix-kata-exec-exit

Fix exit-event handling for Kata runtime
This commit is contained in:
Bjorn Neergaard 2023-02-02 18:42:22 -07:00 committed by GitHub
commit 0de32693d0
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
4 changed files with 9 additions and 12 deletions

View file

@ -156,7 +156,7 @@ func (daemon *Daemon) ProcessEvent(id string, e libcontainerdtypes.EventType, ei
daemon.LogContainerEvent(c, "oom")
case libcontainerdtypes.EventExit:
if int(ei.Pid) == c.Pid {
if ei.ProcessID == ei.ContainerID {
return daemon.handleContainerExit(c, &ei)
}

View file

@ -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,

View file

@ -213,9 +213,9 @@ func (c *container) Start(ctx context.Context, checkpointDir string, withStdin b
t, err = c.c8dCtr.NewTask(ctx,
func(id string) (cio.IO, error) {
fifos := newFIFOSet(bundle, libcontainerdtypes.InitProcessName, withStdin, spec.Process.Terminal)
fifos := newFIFOSet(bundle, id, withStdin, spec.Process.Terminal)
rio, err = c.createIO(fifos, libcontainerdtypes.InitProcessName, stdinCloseSync, attachStdio)
rio, err = c.createIO(fifos, stdinCloseSync, attachStdio)
return rio, err
},
taskOpts...,
@ -278,7 +278,7 @@ func (t *task) Exec(ctx context.Context, processID string, spec *specs.Process,
}()
p, err = t.Task.Exec(ctx, processID, spec, func(id string) (cio.IO, error) {
rio, err = t.ctr.createIO(fifos, processID, stdinCloseSync, attachStdio)
rio, err = t.ctr.createIO(fifos, stdinCloseSync, attachStdio)
return rio, err
})
if err != nil {
@ -489,7 +489,7 @@ func (c *container) Task(ctx context.Context) (libcontainerdtypes.Task, error) {
// createIO creates the io to be used by a process
// This needs to get a pointer to interface as upon closure the process may not have yet been registered
func (c *container) createIO(fifos *cio.FIFOSet, processID string, stdinCloseSync chan containerd.Process, attachStdio libcontainerdtypes.StdioCallback) (cio.IO, error) {
func (c *container) createIO(fifos *cio.FIFOSet, stdinCloseSync chan containerd.Process, attachStdio libcontainerdtypes.StdioCallback) (cio.IO, error) {
var (
io *cio.DirectIO
err error

View file

@ -99,6 +99,3 @@ type Task interface {
// StdioCallback is called to connect a container or process stdio.
type StdioCallback func(io *cio.DirectIO) (cio.IO, error)
// InitProcessName is the name given to the first process of a container
const InitProcessName = "init"