MCPcopy Index your code
hub / github.com/containerd/containerd / checkLayerFileUpdate

Function checkLayerFileUpdate

core/snapshots/testsuite/issues.go:43–70  ·  view source on GitHub ↗

Checks which cover former issues found in older layering models. NOTE: In older models, applying with tar was used to create read only layers, however with the snapshot model read only layers are created just using mounts and commits. Read write layers are a separate type of snapshot which is not c

(ctx context.Context, t *testing.T, sn snapshots.Snapshotter, work string)

Source from the content-addressed store, hash-verified

41// avoid such issues by not relying on tar to create layers.
42// See https://github.com/docker/docker/issues/21555
43func checkLayerFileUpdate(ctx context.Context, t *testing.T, sn snapshots.Snapshotter, work string) {
44 l1Init := fstest.Apply(
45 fstest.CreateDir("/etc", 0700),
46 fstest.CreateFile("/etc/hosts", []byte("mydomain 10.0.0.1"), 0644),
47 fstest.CreateFile("/etc/profile", []byte("PATH=/usr/bin"), 0644),
48 )
49 l2Init := fstest.Apply(
50 fstest.CreateFile("/etc/hosts", []byte("mydomain 10.0.0.2"), 0644),
51 fstest.CreateFile("/etc/profile", []byte("PATH=/usr/bin"), 0666),
52 fstest.CreateDir("/root", 0700),
53 fstest.CreateFile("/root/.bashrc", []byte("PATH=/usr/sbin:/usr/bin"), 0644),
54 )
55
56 var sleepTime time.Duration
57
58 // run 5 times to account for sporadic failure
59 for range 5 {
60 time.Sleep(sleepTime)
61
62 if err := checkSnapshots(ctx, sn, work, l1Init, l2Init); err != nil {
63 t.Fatalf("Check snapshots failed: %+v", err)
64 }
65
66 // Sleep until next second boundary before running again
67 nextTime := time.Now()
68 sleepTime = time.Unix(nextTime.Unix()+1, 0).Sub(nextTime)
69 }
70}
71
72// checkRemoveDirectoryInLowerLayer
73// See https://github.com/docker/docker/issues/25244

Callers

nothing calls this directly

Calls 2

checkSnapshotsFunction · 0.85
ApplyMethod · 0.65

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…