Skip to content
This repository has been archived by the owner on Dec 7, 2023. It is now read-only.

add wait check for task.Kill(cc.ctx, syscall.SIGQUIT) #931

Open
wants to merge 1 commit into
base: main
Choose a base branch
from
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
12 changes: 9 additions & 3 deletions pkg/runtime/containerd/client.go
Original file line number Diff line number Diff line change
Expand Up @@ -706,17 +706,23 @@ func (cc *ctdClient) StopContainer(container string, timeout *time.Duration) (er
}

// After sending the signal, start the timer to force-kill the task
timeoutC := make(chan error)
timeoutC := make(<-chan containerd.ExitStatus)
timer := time.AfterFunc(*timeout, func() {
timeoutC <- task.Kill(cc.ctx, syscall.SIGQUIT)
timeoutC, err = task.Wait(cc.ctx)
if err != nil {
return
}
if err = task.Kill(cc.ctx, syscall.SIGQUIT); err != nil {
return
}
})

// Wait for the task to stop or the timer to fire
select {
case exitStatus := <-waitC:
timer.Stop() // Cancel the force-kill timer
err = exitStatus.Error() // TODO: Handle exit code
case err = <-timeoutC: // The kill timer has fired
case <-timeoutC: // The kill timer has fired
}

// Delete the task
Expand Down