Skip to content

Commit c68458a

Browse files
committed
Don't delete containers when ExecID is non-empty
Non-empty Exec ID means deleting the task, not its container. Signed-off-by: Kazuyoshi Kato <[email protected]>
1 parent 31baf7a commit c68458a

File tree

2 files changed

+11
-6
lines changed

2 files changed

+11
-6
lines changed

runtime/service.go

Lines changed: 10 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -787,17 +787,23 @@ func (s *service) Delete(requestCtx context.Context, req *taskAPI.DeleteRequest)
787787
return nil, err
788788
}
789789

790+
if req.ExecID != "" {
791+
return resp, nil
792+
}
793+
794+
// Delete the container
790795
dir, err := s.shimDir.BundleLink(req.ID)
791796
if err != nil {
792797
return nil, errors.Wrapf(err, "failed to find the bundle directory of the container: %s", req.ID)
793798
}
794799

795800
_, err = os.Stat(dir.RootPath())
796801
if os.IsNotExist(err) {
797-
// is this really bad?
798-
logger.Warnf("failed to delete %s: %v", dir.RootPath(), err)
799-
} else if err = os.Remove(dir.RootPath()); err != nil {
800-
return nil, errors.Wrapf(err, "failed to remove the bundle directory of the container: %s", req.ID)
802+
return nil, errors.Wrapf(err, "failed to find the bundle directory of the container: %s", dir.RootPath())
803+
}
804+
805+
if err = os.Remove(dir.RootPath()); err != nil {
806+
return nil, errors.Wrapf(err, "failed to remove the bundle directory of the container: %s", dir.RootPath())
801807
}
802808

803809
return resp, nil

runtime/service_integ_test.go

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -572,8 +572,7 @@ func testCreateContainerWithSameName(t *testing.T, vmID string) {
572572
pluginClient, err := ttrpcutil.NewClient(containerdSockPath + ".ttrpc")
573573
require.NoError(t, err, "failed to create ttrpc client")
574574

575-
// Explicitly specify Container Count = 2
576-
// TODO: shouldn't it work without specifying the count?
575+
// Explicitly specify Container Count = 2 to workaround #230
577576
if len(vmID) != 0 {
578577
fcClient := fccontrol.NewFirecrackerClient(pluginClient.Client())
579578
_, err = fcClient.CreateVM(ctx, &proto.CreateVMRequest{

0 commit comments

Comments
 (0)