Skip to content

Commit e563e5b

Browse files
committed
StopVM doesn't work when Firecracker is not responding
This commit doesn't fix the issue, but reproduce that in TestStopVM_Isolated. pidExists is added to check the existence of a process. process.PidExists() uses /proc filesystem which doesn't work apparently. Signed-off-by: Kazuyoshi Kato <[email protected]>
1 parent 3de37ab commit e563e5b

File tree

1 file changed

+29
-6
lines changed

1 file changed

+29
-6
lines changed

runtime/service_integ_test.go

Lines changed: 29 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1599,6 +1599,10 @@ func findProcess(
15991599
return matches, nil
16001600
}
16011601

1602+
func pidExists(pid int) bool {
1603+
return syscall.ESRCH.Is(syscall.Kill(pid, 0))
1604+
}
1605+
16021606
func TestStopVM_Isolated(t *testing.T) {
16031607
prepareIntegTest(t)
16041608
require := require.New(t)
@@ -1725,6 +1729,25 @@ func TestStopVM_Isolated(t *testing.T) {
17251729
require.NoError(err)
17261730
},
17271731
},
1732+
1733+
{
1734+
name: "Suspend",
1735+
withStopVM: true,
1736+
1737+
createVMRequest: proto.CreateVMRequest{},
1738+
stopFunc: func(ctx context.Context, fcClient fccontrol.FirecrackerService, req proto.CreateVMRequest) {
1739+
firecrackerProcesses, err := findProcess(ctx, findFirecracker)
1740+
require.NoError(err, "failed waiting for expected firecracker process %q to come up", firecrackerProcessName)
1741+
require.Len(firecrackerProcesses, 1, "expected only one firecracker process to exist")
1742+
firecrackerProcess := firecrackerProcesses[0]
1743+
1744+
err = firecrackerProcess.Suspend()
1745+
require.NoError(err, "failed to suspend Firecracker")
1746+
1747+
_, err = fcClient.StopVM(ctx, &proto.StopVMRequest{VMID: req.VMID})
1748+
assert.NotNil(err)
1749+
},
1750+
},
17281751
}
17291752

17301753
fcClient, err := newFCControlClient(containerdSockPath)
@@ -1768,13 +1791,13 @@ func TestStopVM_Isolated(t *testing.T) {
17681791
// If the function above uses StopVMRequest, all underlying processes must be dead
17691792
// (either gracefully or forcibly) at the end of the request.
17701793
if test.withStopVM {
1771-
fcExists, err := process.PidExists(fcProcess.Pid)
1772-
require.NoError(err, "failed to find firecracker")
1773-
require.False(fcExists, "firecracker %s is still there", vmID)
1794+
fcExists := pidExists(int(fcProcess.Pid))
1795+
assert.NoError(err, "failed to find firecracker")
1796+
assert.False(fcExists, "firecracker %s (pid=%d) is still there", vmID, fcProcess.Pid)
17741797

1775-
shimExists, err := process.PidExists(shimProcess.Pid)
1776-
require.NoError(err, "failed to find shim")
1777-
require.False(shimExists, "shim %s is still there", vmID)
1798+
shimExists := pidExists(int(shimProcess.Pid))
1799+
assert.NoError(err, "failed to find shim")
1800+
assert.False(shimExists, "shim %s (pid=%d) is still there", vmID, shimProcess.Pid)
17781801
}
17791802

17801803
err = internal.WaitForPidToExit(ctx, time.Second, shimProcess.Pid)

0 commit comments

Comments
 (0)