Skip to content
Open
Show file tree
Hide file tree
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
4 changes: 4 additions & 0 deletions pkg/unikontainers/hypervisors/utils.go
Original file line number Diff line number Diff line change
Expand Up @@ -71,6 +71,10 @@ func killProcess(pid int) error {
const timeout = 2 * time.Second
err := syscall.Kill(pid, unix.SIGKILL)
if err != nil {
if errors.Is(err, syscall.ESRCH) {
// Process already dead, nothing to do
return nil
}
return err
}
deadline := time.Now().Add(timeout)
Expand Down
19 changes: 12 additions & 7 deletions pkg/unikontainers/unikontainers.go
Original file line number Diff line number Diff line change
Expand Up @@ -555,18 +555,23 @@ func (u *Unikontainer) Kill() error {
if err != nil {
return err
}
err = vmm.Stop(u.State.Pid)
if err != nil {
return err
// Attempt to stop VMM process. If it's already dead, vmm.Stop() returns nil.
// We save any error but continue with network cleanup regardless.
stopErr := vmm.Stop(u.State.Pid)
if stopErr != nil {
uniklog.Warnf("vmm.Stop returned error (will continue with cleanup): %v", stopErr)
}

// Always clean up network resources, regardless of VMM state.
// The TAP device and TC rules exist independently of the VMM process.
// TODO: tap0_urunc should not be hardcoded
err = network.Cleanup("tap0_urunc")
if err != nil {
uniklog.Errorf("failed to delete tap0_urunc: %v", err)
cleanupErr := network.Cleanup("tap0_urunc")
if cleanupErr != nil {
uniklog.Errorf("failed to delete tap0_urunc: %v", cleanupErr)
}

return nil
// Return vmm.Stop error if any (network cleanup errors are logged but not fatal)
return stopErr
}

// Delete removes the containers base directory and its contents
Expand Down