Browse code

integration/system: Extend rootless disk usage drift tolerance

Rootless snapshotter mode can report image TotalSize one filesystem
block above the per-image and reclaimable sizes after loading BusyBox.
The empty disk usage case already accepts this overlayfs accounting
artifact.

Allow the same bounded 4096-byte positive drift in the
after_LoadBusybox assertions while keeping strict equality for other
daemon modes.

Signed-off-by: Paweł Gronowski <pawel.gronowski@docker.com>

Paweł Gronowski authored on 2026/06/12 20:28:34
Showing 1 changed files
... ...
@@ -45,14 +45,7 @@ func TestDiskUsage(t *testing.T) {
45 45
 				})
46 46
 				assert.NilError(t, err)
47 47
 
48
-				expectedLayersSize := int64(0)
49
-				// TODO: Investigate https://github.com/moby/moby/issues/47119
50
-				// Make 4096 (block size) also a valid value for zero usage.
51
-				if testEnv.UsingSnapshotter() && testEnv.IsRootless() {
52
-					if du.Images.TotalSize == 4096 {
53
-						expectedLayersSize = 4096
54
-					}
55
-				}
48
+				expectedLayersSize := adjustedExpectedUsage(du.Images.TotalSize, 0)
56 49
 
57 50
 				assert.DeepEqual(t, du, client.DiskUsageResult{
58 51
 					Containers: client.ContainersDiskUsage{},
... ...
@@ -81,14 +74,17 @@ func TestDiskUsage(t *testing.T) {
81 81
 
82 82
 				assert.Equal(t, du.Images.ActiveCount, int64(0))
83 83
 				assert.Equal(t, du.Images.TotalCount, int64(1))
84
-				assert.Equal(t, du.Images.Reclaimable, du.Images.TotalSize)
84
+
85
+				expectedTotalSize := adjustedExpectedUsage(du.Images.TotalSize, du.Images.Reclaimable)
86
+				assert.Equal(t, du.Images.TotalSize, expectedTotalSize)
85 87
 				assert.Assert(t, du.Images.TotalSize > 0)
86 88
 				assert.Equal(t, len(du.Images.Items), 1)
87 89
 				assert.Equal(t, len(du.Images.Items[0].RepoTags), 1)
88 90
 				assert.Check(t, is.Equal(du.Images.Items[0].RepoTags[0], "busybox:latest"))
89 91
 
90 92
 				// Image size is layer size + content size. Content size is included in layers size.
91
-				assert.Equal(t, du.Images.Items[0].Size, du.Images.TotalSize)
93
+				expectedTotalSize = adjustedExpectedUsage(du.Images.TotalSize, du.Images.Items[0].Size)
94
+				assert.Equal(t, du.Images.TotalSize, expectedTotalSize)
92 95
 
93 96
 				return du
94 97
 			},
... ...
@@ -300,3 +296,14 @@ func TestDiskUsage(t *testing.T) {
300 300
 		})
301 301
 	}
302 302
 }
303
+
304
+// Rootless snapshotter disk usage can drift by one filesystem block.
305
+// TODO: Investigate why https://github.com/moby/moby/issues/52845
306
+func adjustedExpectedUsage(actual, expected int64) int64 {
307
+	if testEnv.UsingSnapshotter() && testEnv.IsRootless() {
308
+		if actual == expected+4096 {
309
+			return actual
310
+		}
311
+	}
312
+	return expected
313
+}