Skip to content

Commit e0c94bb

Browse files
Merge pull request #4708 from kzys/enable-criu
Re-enable CRIU tests by not using overlayfs snapshotter
2 parents 0d569f8 + 8731888 commit e0c94bb

5 files changed

Lines changed: 47 additions & 7 deletions

File tree

.github/workflows/ci.yml

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -322,6 +322,22 @@ jobs:
322322
sudo GOPATH=$GOPATH GOPROXY=$GOPROXY TEST_RUNTIME=$TEST_RUNTIME RUNC_FLAVOR=$RUNC_FLAVOR TESTFLAGS_PARALLEL=1 make integration EXTRA_TESTFLAGS=-no-criu
323323
working-directory: src/github.com/containerd/containerd
324324

325+
# CRIU wouldn't work with overlay snapshotter yet.
326+
# See https://github.com/containerd/containerd/pull/4708#issuecomment-724322294.
327+
- name: CRIU Integration
328+
env:
329+
GOPROXY: direct
330+
TEST_RUNTIME: ${{ matrix.runtime }}
331+
RUNC_FLAVOR: ${{ matrix.runc }}
332+
# crun doesn't have "checkpoint" command.
333+
if: ${{ matrix.runc == 'runc' }}
334+
run: |
335+
sudo GOPATH=$GOPATH GOPROXY=$GOPROXY \
336+
TEST_RUNTIME=$TEST_RUNTIME RUNC_FLAVOR=$RUNC_FLAVOR TESTFLAGS_PARALLEL=1 \
337+
TEST_SNAPSHOTTER=native \
338+
make integration EXTRA_TESTFLAGS='-run TestCheckpoint'
339+
working-directory: src/github.com/containerd/containerd
340+
325341
- name: CRI Integration Test
326342
env:
327343
TEST_RUNTIME: ${{ matrix.runtime }}

integration/client/client_test.go

Lines changed: 24 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -50,6 +50,7 @@ var (
5050
noCriu bool
5151
supportsCriu bool
5252
testNamespace = "testing"
53+
testSnapshotter = DefaultSnapshotter
5354
ctrdStdioFilePath string
5455

5556
ctrd = &daemon{}
@@ -132,11 +133,30 @@ func TestMain(m *testing.M) {
132133

133134
// allow comparison with containerd under test
134135
log.G(ctx).WithFields(logrus.Fields{
135-
"version": version.Version,
136-
"revision": version.Revision,
137-
"runtime": os.Getenv("TEST_RUNTIME"),
136+
"version": version.Version,
137+
"revision": version.Revision,
138+
"runtime": os.Getenv("TEST_RUNTIME"),
139+
"snapshotter": os.Getenv("TEST_SNAPSHOTTER"),
138140
}).Info("running tests against containerd")
139141

142+
snapshotter := DefaultSnapshotter
143+
if ss := os.Getenv("TEST_SNAPSHOTTER"); ss != "" {
144+
snapshotter = ss
145+
}
146+
147+
ns, ok := namespaces.Namespace(ctx)
148+
if !ok {
149+
fmt.Fprintln(os.Stderr, "error getting namespace")
150+
os.Exit(1)
151+
}
152+
err = client.NamespaceService().SetLabel(ctx, ns, defaults.DefaultSnapshotterNSLabel, snapshotter)
153+
if err != nil {
154+
fmt.Fprintf(os.Stderr, "error setting %s's default snapshotter as %s: %s\n", ns, snapshotter, err)
155+
os.Exit(1)
156+
}
157+
158+
testSnapshotter = snapshotter
159+
140160
// pull a seed image
141161
log.G(ctx).WithField("image", testImage).Info("start to pull seed image")
142162
if _, err = client.Pull(ctx, testImage, WithPullUnpack); err != nil {
@@ -285,7 +305,7 @@ func TestImagePullWithDiscardContent(t *testing.T) {
285305
t.Fatalf("there is no layers in the target image(parent: %v)", img.Target())
286306
}
287307
var (
288-
sn = client.SnapshotService("")
308+
sn = client.SnapshotService(testSnapshotter)
289309
chain []digest.Digest
290310
)
291311
for i, dgst := range layers {

integration/client/container_checkpoint_test.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -414,7 +414,7 @@ func TestCheckpointLeaveRunning(t *testing.T) {
414414
<-statusC
415415
}
416416

417-
func TestCRWithImagePath(t *testing.T) {
417+
func TestCheckpointRestoreWithImagePath(t *testing.T) {
418418
if !supportsCriu {
419419
t.Skip("system does not have criu installed")
420420
}

pkg/process/init.go

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -193,11 +193,15 @@ func (p *Init) createCheckpointedState(r *CreateConfig, pidFile *pidFile) error
193193
ParentPath: r.ParentCheckpoint,
194194
},
195195
PidFile: pidFile.Path(),
196-
IO: p.io.IO(),
197196
NoPivot: p.NoPivotRoot,
198197
Detach: true,
199198
NoSubreaper: true,
200199
}
200+
201+
if p.io != nil {
202+
opts.IO = p.io.IO()
203+
}
204+
201205
p.initState = &createdCheckpointState{
202206
p: p,
203207
opts: opts,

runtime/v2/runc/container.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -49,7 +49,7 @@ func NewContainer(ctx context.Context, platform stdio.Platform, r *task.CreateTa
4949
}
5050

5151
var opts options.Options
52-
if r.Options != nil {
52+
if r.Options != nil && r.Options.GetTypeUrl() != "" {
5353
v, err := typeurl.UnmarshalAny(r.Options)
5454
if err != nil {
5555
return nil, err

0 commit comments

Comments
 (0)