@@ -65,7 +65,6 @@ const (
65
65
firecrackerRuntime = "aws.firecracker"
66
66
shimProcessName = "containerd-shim-aws-firecracker"
67
67
firecrackerProcessName = "firecracker"
68
- jailerProcessName = "runc"
69
68
70
69
defaultVMRootfsPath = "/var/lib/firecracker-containerd/runtime/default-rootfs.img"
71
70
defaultVMNetDevName = "eth0"
@@ -1365,16 +1364,16 @@ func TestStopVM_Isolated(t *testing.T) {
1365
1364
tests := []struct {
1366
1365
name string
1367
1366
createVMRequest proto.CreateVMRequest
1368
- stopFunc func (ctx context.Context , fcClient fccontrol.FirecrackerService , vmID string )
1367
+ stopFunc func (ctx context.Context , fcClient fccontrol.FirecrackerService , req proto. CreateVMRequest )
1369
1368
withStopVM bool
1370
1369
}{
1371
1370
{
1372
1371
name : "Successful" ,
1373
1372
withStopVM : true ,
1374
1373
1375
1374
createVMRequest : proto.CreateVMRequest {},
1376
- stopFunc : func (ctx context.Context , fcClient fccontrol.FirecrackerService , vmID string ) {
1377
- _ , err = fcClient .StopVM (ctx , & proto.StopVMRequest {VMID : vmID })
1375
+ stopFunc : func (ctx context.Context , fcClient fccontrol.FirecrackerService , req proto. CreateVMRequest ) {
1376
+ _ , err = fcClient .StopVM (ctx , & proto.StopVMRequest {VMID : req . VMID })
1378
1377
require .Equal (status .Code (err ), codes .OK )
1379
1378
},
1380
1379
},
@@ -1390,11 +1389,17 @@ func TestStopVM_Isolated(t *testing.T) {
1390
1389
HostPath : "/var/lib/firecracker-containerd/runtime/rootfs-slow-reboot.img" ,
1391
1390
},
1392
1391
},
1393
- stopFunc : func (ctx context.Context , fcClient fccontrol.FirecrackerService , vmID string ) {
1394
- _ , err = fcClient .StopVM (ctx , & proto.StopVMRequest {VMID : vmID })
1392
+ stopFunc : func (ctx context.Context , fcClient fccontrol.FirecrackerService , req proto. CreateVMRequest ) {
1393
+ _ , err = fcClient .StopVM (ctx , & proto.StopVMRequest {VMID : req . VMID })
1395
1394
errCode := status .Code (err )
1396
- assert .NotEqual (codes .Unknown , errCode , "the error code must not be Unknown" )
1397
1395
assert .Equal (codes .DeadlineExceeded , errCode , "the error code must be DeadlineExceeded" )
1396
+
1397
+ if req .JailerConfig != nil {
1398
+ // No "signal: ..." error with runc since it traps the signal
1399
+ assert .Contains (err .Error (), "exit status 1" )
1400
+ } else {
1401
+ assert .Contains (err .Error (), "signal: terminated" , "must be 'terminated', not 'killed'" )
1402
+ }
1398
1403
},
1399
1404
},
1400
1405
@@ -1404,7 +1409,7 @@ func TestStopVM_Isolated(t *testing.T) {
1404
1409
withStopVM : false ,
1405
1410
1406
1411
createVMRequest : proto.CreateVMRequest {},
1407
- stopFunc : func (ctx context.Context , _ fccontrol.FirecrackerService , _ string ) {
1412
+ stopFunc : func (ctx context.Context , _ fccontrol.FirecrackerService , _ proto. CreateVMRequest ) {
1408
1413
firecrackerProcesses , err := findProcess (ctx , findFirecracker )
1409
1414
require .NoError (err , "failed waiting for expected firecracker process %q to come up" , firecrackerProcessName )
1410
1415
require .Len (firecrackerProcesses , 1 , "expected only one firecracker process to exist" )
@@ -1426,7 +1431,7 @@ func TestStopVM_Isolated(t *testing.T) {
1426
1431
HostPath : "/var/lib/firecracker-containerd/runtime/rootfs-slow-reboot.img" ,
1427
1432
},
1428
1433
},
1429
- stopFunc : func (ctx context.Context , fcClient fccontrol.FirecrackerService , vmID string ) {
1434
+ stopFunc : func (ctx context.Context , fcClient fccontrol.FirecrackerService , req proto. CreateVMRequest ) {
1430
1435
firecrackerProcesses , err := findProcess (ctx , findFirecracker )
1431
1436
require .NoError (err , "failed waiting for expected firecracker process %q to come up" , firecrackerProcessName )
1432
1437
require .Len (firecrackerProcesses , 1 , "expected only one firecracker process to exist" )
@@ -1439,10 +1444,16 @@ func TestStopVM_Isolated(t *testing.T) {
1439
1444
}()
1440
1445
1441
1446
_ , err = fcClient .StopVM (ctx , & proto.StopVMRequest {
1442
- VMID : vmID ,
1447
+ VMID : req . VMID ,
1443
1448
TimeoutSeconds : 10 ,
1444
1449
})
1445
- require .Contains (err .Error (), "signal: killed" , "unexpected error from StopVM" )
1450
+
1451
+ if req .JailerConfig != nil {
1452
+ // No "signal: ..." error with runc since it traps the signal
1453
+ assert .Contains (err .Error (), "exit status 137" )
1454
+ } else {
1455
+ assert .Contains (err .Error (), "signal: killed" )
1456
+ }
1446
1457
},
1447
1458
},
1448
1459
}
@@ -1481,10 +1492,10 @@ func TestStopVM_Isolated(t *testing.T) {
1481
1492
require .Len (fcProcesses , 1 , "expected only one firecracker process to exist" )
1482
1493
fcProcess := fcProcesses [0 ]
1483
1494
1484
- test .stopFunc (ctx , fcClient , vmID )
1495
+ test .stopFunc (ctx , fcClient , createVMRequest )
1485
1496
1486
1497
// If the function above uses StopVMRequest,
1487
- // shim gurantees that the underlying Firecracker process is dead
1498
+ // shim guarantees that the underlying Firecracker process is dead
1488
1499
// (either gracefully or forcibly) at the end of the request.
1489
1500
if test .withStopVM {
1490
1501
fcExists , err := process .PidExists (fcProcess .Pid )
@@ -1493,7 +1504,7 @@ func TestStopVM_Isolated(t *testing.T) {
1493
1504
}
1494
1505
1495
1506
// Since the shim is the one which is writing the response,
1496
- // it cannot gurantee that the itself is dead at the end of the request.
1507
+ // it cannot guarantee that the shim itself is dead at the end of the request.
1497
1508
// But it should be dead eventually.
1498
1509
err = internal .WaitForPidToExit (ctx , time .Second , shimProcess .Pid )
1499
1510
require .NoError (err , "shim hasn't been terminated" )
0 commit comments