Skip to content

Commit 414716c

Browse files
ayushr2gvisor-bot
authored andcommitted
Skip Docker restore tests on Docker v28+.
Docker's `restore` functionality is broken starting from v28 due to moby/moby#50750. This change adds a version check to `dockerutil` and skips tests that rely on `docker restore` if the Docker version is v28 or greater. TCP checkpoint/restore tests are also refactored to centralize common setup and version checks. PiperOrigin-RevId: 818827864
1 parent b8da8ca commit 414716c

File tree

4 files changed

+49
-46
lines changed

4 files changed

+49
-46
lines changed

pkg/test/dockerutil/dockerutil.go

Lines changed: 17 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -89,10 +89,7 @@ func PrintDockerConfig() {
8989
log.Printf("Docker config (from %v):\n--------\n%v\n--------\n", *config, string(configBytes))
9090
}
9191

92-
// EnsureSupportedDockerVersion checks if correct docker is installed.
93-
//
94-
// This logs directly to stderr, as it is typically called from a Main wrapper.
95-
func EnsureSupportedDockerVersion() {
92+
func getDockerVersion() (int, int) {
9693
cmd := exec.Command(dockerCLIPath(), "version")
9794
out, err := cmd.CombinedOutput()
9895
if err != nil {
@@ -105,6 +102,14 @@ func EnsureSupportedDockerVersion() {
105102
}
106103
major, _ := strconv.Atoi(matches[1])
107104
minor, _ := strconv.Atoi(matches[2])
105+
return major, minor
106+
}
107+
108+
// EnsureSupportedDockerVersion checks if correct docker is installed.
109+
//
110+
// This logs directly to stderr, as it is typically called from a Main wrapper.
111+
func EnsureSupportedDockerVersion() {
112+
major, minor := getDockerVersion()
108113
if major < 17 || (major == 17 && minor < 9) {
109114
log.Fatalf("Docker version 17.09.0 or greater is required, found: %02d.%02d", major, minor)
110115
}
@@ -123,6 +128,14 @@ func EnsureDockerExperimentalEnabled() {
123128
}
124129
}
125130

131+
// IsRestoreSupported returns true if the docker version supports restore.
132+
// Docker restore broke starting v28 due to
133+
// https://github.com/moby/moby/issues/50750.
134+
func IsRestoreSupported() bool {
135+
major, _ := getDockerVersion()
136+
return major <= 27
137+
}
138+
126139
// RuntimePath returns the binary path for the current runtime.
127140
func RuntimePath() (string, error) {
128141
rs, err := runtimeMap()

test/e2e/integration_runtime_test.go

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -249,6 +249,9 @@ func TestOverlayCheckpointRestore(t *testing.T) {
249249
t.Skip("Checkpoint is not supported.")
250250
}
251251
dockerutil.EnsureDockerExperimentalEnabled()
252+
if !dockerutil.IsRestoreSupported() {
253+
t.Skip("Restore is not supported.")
254+
}
252255

253256
dir, err := os.MkdirTemp(testutil.TmpDir(), "submount")
254257
if err != nil {

test/e2e/integration_test.go

Lines changed: 26 additions & 42 deletions
Original file line numberDiff line numberDiff line change
@@ -179,6 +179,9 @@ func TestCheckpointRestore(t *testing.T) {
179179
t.Skip("Checkpoint is not supported.")
180180
}
181181
dockerutil.EnsureDockerExperimentalEnabled()
182+
if !dockerutil.IsRestoreSupported() {
183+
t.Skip("Restore is not supported.")
184+
}
182185

183186
ctx := context.Background()
184187
d := dockerutil.MakeContainer(ctx, t)
@@ -1268,7 +1271,25 @@ func connectAndReadWrite(t *testing.T, serverIP string, port int) {
12681271
}
12691272
}
12701273

1271-
func testCheckpointRestoreTCPConnection(ctx context.Context, t *testing.T, d *dockerutil.Container, fName string, numConn int, restoreLoopback bool) {
1274+
func testCheckpointRestoreTCPConnection(t *testing.T, netstackSR bool, fName string, numConn int, restoreLoopback bool) {
1275+
if !testutil.IsCheckpointSupported() {
1276+
t.Skip("Checkpoint is not supported.")
1277+
}
1278+
dockerutil.EnsureDockerExperimentalEnabled()
1279+
if !dockerutil.IsRestoreSupported() {
1280+
t.Skip("Restore is not supported.")
1281+
}
1282+
1283+
var d *dockerutil.Container
1284+
ctx := context.Background()
1285+
if netstackSR {
1286+
if !testutil.IsRunningWithSaveRestoreNetstack() {
1287+
t.Skip("Netstack save restore is not supported.")
1288+
}
1289+
d = dockerutil.MakeContainerWithRuntime(ctx, t, "-save-restore-netstack")
1290+
} else {
1291+
d = dockerutil.MakeContainer(ctx, t)
1292+
}
12721293
defer d.CleanUp(ctx)
12731294

12741295
opts := dockerutil.RunOpts{
@@ -1322,59 +1343,22 @@ func testCheckpointRestoreTCPConnection(ctx context.Context, t *testing.T, d *do
13221343

13231344
// Test to check restore of a TCP listening connection without netstack S/R.
13241345
func TestRestoreListenConn(t *testing.T) {
1325-
if !testutil.IsCheckpointSupported() {
1326-
t.Skip("Checkpoint is not supported.")
1327-
}
1328-
dockerutil.EnsureDockerExperimentalEnabled()
1329-
1330-
ctx := context.Background()
1331-
d := dockerutil.MakeContainer(ctx, t)
1332-
testCheckpointRestoreTCPConnection(ctx, t, d, "./tcp_server" /* fName */, 1 /* numConn */, false /* restoreLoopback */)
1346+
testCheckpointRestoreTCPConnection(t, false /* netstackSR */, "./tcp_server" /* fName */, 1 /* numConn */, false /* restoreLoopback */)
13331347
}
13341348

13351349
// Test to check restore of a TCP listening connection with netstack S/R.
13361350
func TestRestoreListenConnWithNetstackSR(t *testing.T) {
1337-
if !testutil.IsCheckpointSupported() {
1338-
t.Skip("Checkpoint is not supported.")
1339-
}
1340-
if !testutil.IsRunningWithSaveRestoreNetstack() {
1341-
t.Skip("Netstack save restore is not supported.")
1342-
}
1343-
dockerutil.EnsureDockerExperimentalEnabled()
1344-
1345-
ctx := context.Background()
1346-
d := dockerutil.MakeContainerWithRuntime(ctx, t, "-save-restore-netstack")
1347-
testCheckpointRestoreTCPConnection(ctx, t, d, "./tcp_server" /* fName */, 1 /* numConn */, false /* restoreLoopback */)
1351+
testCheckpointRestoreTCPConnection(t, true /* netstackSR */, "./tcp_server" /* fName */, 1 /* numConn */, false /* restoreLoopback */)
13481352
}
13491353

13501354
// Test to check restore of multiple TCP listening connections with netstack S/R.
13511355
func TestRestoreMultipleListenConnWithNetstackSR(t *testing.T) {
1352-
if !testutil.IsCheckpointSupported() {
1353-
t.Skip("Checkpoint is not supported.")
1354-
}
1355-
if !testutil.IsRunningWithSaveRestoreNetstack() {
1356-
t.Skip("Netstack save restore is not supported.")
1357-
}
1358-
dockerutil.EnsureDockerExperimentalEnabled()
1359-
1360-
ctx := context.Background()
1361-
d := dockerutil.MakeContainerWithRuntime(ctx, t, "-save-restore-netstack")
1362-
testCheckpointRestoreTCPConnection(ctx, t, d, "./tcp_stress_server" /* fName */, 100 /* numConn */, false /* restoreLoopback */)
1356+
testCheckpointRestoreTCPConnection(t, true /* netstackSR */, "./tcp_stress_server" /* fName */, 100 /* numConn */, false /* restoreLoopback */)
13631357
}
13641358

13651359
// Test to check restore of TCP established loopback connection with netstack S/R.
13661360
func TestRestoreLoopbackConnWithNetstackSR(t *testing.T) {
1367-
if !testutil.IsCheckpointSupported() {
1368-
t.Skip("Checkpoint is not supported.")
1369-
}
1370-
if !testutil.IsRunningWithSaveRestoreNetstack() {
1371-
t.Skip("Netstack save restore is not supported.")
1372-
}
1373-
dockerutil.EnsureDockerExperimentalEnabled()
1374-
1375-
ctx := context.Background()
1376-
d := dockerutil.MakeContainerWithRuntime(ctx, t, "-save-restore-netstack")
1377-
testCheckpointRestoreTCPConnection(ctx, t, d, "./tcp_loopback" /* fName */, 1 /* numConn */, true /* restoreLoopback */)
1361+
testCheckpointRestoreTCPConnection(t, true /* netstackSR */, "./tcp_loopback" /* fName */, 1 /* numConn */, true /* restoreLoopback */)
13781362
}
13791363

13801364
// Test to check if sudo works

test/gpu/sr_test.go

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -30,6 +30,9 @@ func TestGPUCheckpointRestore(t *testing.T) {
3030
t.Skip("Checkpoint is not supported.")
3131
}
3232
dockerutil.EnsureDockerExperimentalEnabled()
33+
if !dockerutil.IsRestoreSupported() {
34+
t.Skip("Restore is not supported.")
35+
}
3336

3437
ctx := context.Background()
3538
c := dockerutil.MakeContainer(ctx, t)

0 commit comments

Comments
 (0)