During container creation, unikontainer.InitialSetup() persists the container state with:
Pid = -1
Status = creating
If container creation fails before unikontainer.Create() updates the PID, the container remains in this intermediate state.
Later, when attempting to clean up the failed container using:
urunc delete <container-id>
Delete() invokes isRunning(), which currently performs:
syscall.Kill(u.State.Pid, syscall.Signal(0))
without validating the PID value.
When Pid == -1, the call becomes:
On Unix systems, kill(-1, sig) targets all processes that the caller has permission to signal. When running as a privileged user, this call succeeds, causing isRunning() to incorrectly return true.
As a result, Delete() refuses to remove the container and reports:
cannot delete running container: <container-id>
This leaves failed containers stuck in the creating state and prevents cleanup of the associated runtime state.
Steps to Reproduce
- Trigger a failure after
unikontainer.InitialSetup() has completed but before unikontainer.Create() updates the PID.
- Observe that the persisted state contains:
{
"status": "creating",
"pid": -1
}
- Attempt to remove the failed container:
urunc delete <container-id>
Actual Behavior
Delete() reports that the container is still running:
cannot delete running container: <container-id>
and the runtime state cannot be cleaned up.
Expected Behavior
Containers with non-positive PIDs (Pid <= 0) should be considered not running, allowing cleanup to proceed.
Suggested Fix
Guard against invalid PID values in isRunning():
func (u *Unikontainer) isRunning() bool {
if u.State.Pid <= 0 {
return false
}
err := syscall.Kill(u.State.Pid, syscall.Signal(0))
return err == nil
}
Additional Notes
InitialSetup() intentionally persists state before container creation completes, so failures during subsequent setup phases can legitimately leave containers with Pid = -1. Handling this case explicitly would allow these partially-created containers to be cleaned up correctly.
During container creation,
unikontainer.InitialSetup()persists the container state with:If container creation fails before
unikontainer.Create()updates the PID, the container remains in this intermediate state.Later, when attempting to clean up the failed container using:
Delete()invokesisRunning(), which currently performs:without validating the PID value.
When
Pid == -1, the call becomes:On Unix systems,
kill(-1, sig)targets all processes that the caller has permission to signal. When running as a privileged user, this call succeeds, causingisRunning()to incorrectly returntrue.As a result,
Delete()refuses to remove the container and reports:This leaves failed containers stuck in the
creatingstate and prevents cleanup of the associated runtime state.Steps to Reproduce
unikontainer.InitialSetup()has completed but beforeunikontainer.Create()updates the PID.{ "status": "creating", "pid": -1 }Actual Behavior
Delete()reports that the container is still running:and the runtime state cannot be cleaned up.
Expected Behavior
Containers with non-positive PIDs (
Pid <= 0) should be considered not running, allowing cleanup to proceed.Suggested Fix
Guard against invalid PID values in
isRunning():Additional Notes
InitialSetup()intentionally persists state before container creation completes, so failures during subsequent setup phases can legitimately leave containers withPid = -1. Handling this case explicitly would allow these partially-created containers to be cleaned up correctly.