diff --git a/components/engine/daemon/graphdriver/overlay2/overlay.go b/components/engine/daemon/graphdriver/overlay2/overlay.go index 5108a2c055..49b055cc03 100644 --- a/components/engine/daemon/graphdriver/overlay2/overlay.go +++ b/components/engine/daemon/graphdriver/overlay2/overlay.go @@ -754,16 +754,5 @@ func (d *Driver) Diff(id, parent string) (io.ReadCloser, error) { // Changes produces a list of changes between the specified layer and its // parent layer. If parent is "", then all changes will be ADD changes. func (d *Driver) Changes(id, parent string) ([]archive.Change, error) { - if useNaiveDiff(d.home) || !d.isParent(id, parent) { - return d.naiveDiff.Changes(id, parent) - } - // Overlay doesn't have snapshots, so we need to get changes from all parent - // layers. - diffPath := d.getDiffPath(id) - layers, err := d.getLowerDirs(id) - if err != nil { - return nil, err - } - - return archive.OverlayChanges(layers, diffPath) + return d.naiveDiff.Changes(id, parent) } diff --git a/components/engine/daemon/graphdriver/overlay2/overlay_test.go b/components/engine/daemon/graphdriver/overlay2/overlay_test.go index 4a07137ed8..6befa7db57 100644 --- a/components/engine/daemon/graphdriver/overlay2/overlay_test.go +++ b/components/engine/daemon/graphdriver/overlay2/overlay_test.go @@ -62,7 +62,7 @@ func TestOverlayDiffApply10Files(t *testing.T) { } func TestOverlayChanges(t *testing.T) { - skipIfNaive(t) + t.Skipf("Cannot run test with naive change algorithm") graphtest.DriverTestChanges(t, driverName) } diff --git a/components/engine/integration/internal/network/ops.go b/components/engine/integration/internal/network/ops.go index 190918abed..8bec62d79e 100644 --- a/components/engine/integration/internal/network/ops.go +++ b/components/engine/integration/internal/network/ops.go @@ -26,7 +26,7 @@ func WithCheckDuplicate() func(*types.NetworkCreate) { } } -// WithInternal sets the Internal flag on the network +// WithInternal enables Internal flag on the create network request func WithInternal() func(*types.NetworkCreate) { return func(n *types.NetworkCreate) { n.Internal = true diff --git a/components/engine/integration/network/macvlan/macvlan_test.go b/components/engine/integration/network/macvlan/macvlan_test.go index 14dfce92cb..9c0fd407a1 100644 --- a/components/engine/integration/network/macvlan/macvlan_test.go +++ b/components/engine/integration/network/macvlan/macvlan_test.go @@ -6,7 +6,6 @@ import ( "testing" "time" - "github.com/docker/docker/api/types" "github.com/docker/docker/client" "github.com/docker/docker/integration/internal/container" net "github.com/docker/docker/integration/internal/network" @@ -138,17 +137,17 @@ func testMacvlanSubinterface(client client.APIClient) func(*testing.T) { func testMacvlanNilParent(client client.APIClient) func(*testing.T) { return func(t *testing.T) { // macvlan bridge mode - dummy parent interface is provisioned dynamically - _, err := client.NetworkCreate(context.Background(), "dm-nil-parent", types.NetworkCreate{ - Driver: "macvlan", - }) - assert.NilError(t, err) - assert.Check(t, n.IsNetworkAvailable(client, "dm-nil-parent")) + netName := "dm-nil-parent" + net.CreateNoError(t, context.Background(), client, netName, + net.WithMacvlan(""), + ) + assert.Check(t, n.IsNetworkAvailable(client, netName)) ctx := context.Background() - id1 := container.Run(t, ctx, client, container.WithNetworkMode("dm-nil-parent")) - id2 := container.Run(t, ctx, client, container.WithNetworkMode("dm-nil-parent")) + id1 := container.Run(t, ctx, client, container.WithNetworkMode(netName)) + id2 := container.Run(t, ctx, client, container.WithNetworkMode(netName)) - _, err = container.Exec(ctx, client, id2, []string{"ping", "-c", "1", id1}) + _, err := container.Exec(ctx, client, id2, []string{"ping", "-c", "1", id1}) assert.Check(t, err == nil) } } @@ -156,20 +155,20 @@ func testMacvlanNilParent(client client.APIClient) func(*testing.T) { func testMacvlanInternalMode(client client.APIClient) func(*testing.T) { return func(t *testing.T) { // macvlan bridge mode - dummy parent interface is provisioned dynamically - _, err := client.NetworkCreate(context.Background(), "dm-internal", types.NetworkCreate{ - Driver: "macvlan", - Internal: true, - }) - assert.NilError(t, err) - assert.Check(t, n.IsNetworkAvailable(client, "dm-internal")) + netName := "dm-internal" + net.CreateNoError(t, context.Background(), client, netName, + net.WithMacvlan(""), + net.WithInternal(), + ) + assert.Check(t, n.IsNetworkAvailable(client, netName)) ctx := context.Background() - id1 := container.Run(t, ctx, client, container.WithNetworkMode("dm-internal")) - id2 := container.Run(t, ctx, client, container.WithNetworkMode("dm-internal")) + id1 := container.Run(t, ctx, client, container.WithNetworkMode(netName)) + id2 := container.Run(t, ctx, client, container.WithNetworkMode(netName)) timeoutCtx, cancel := context.WithTimeout(context.Background(), 1*time.Second) defer cancel() - _, err = container.Exec(timeoutCtx, client, id1, []string{"ping", "-c", "1", "-w", "1", "8.8.8.8"}) + _, err := container.Exec(timeoutCtx, client, id1, []string{"ping", "-c", "1", "-w", "1", "8.8.8.8"}) // FIXME(vdemeester) check the time of error ? assert.Check(t, err != nil) assert.Check(t, timeoutCtx.Err() == context.DeadlineExceeded) diff --git a/components/engine/pkg/archive/changes_linux.go b/components/engine/pkg/archive/changes_linux.go index 78a5393c8e..f8792b3d4e 100644 --- a/components/engine/pkg/archive/changes_linux.go +++ b/components/engine/pkg/archive/changes_linux.go @@ -284,30 +284,3 @@ func clen(n []byte) int { } return len(n) } - -// OverlayChanges walks the path rw and determines changes for the files in the path, -// with respect to the parent layers -func OverlayChanges(layers []string, rw string) ([]Change, error) { - return changes(layers, rw, overlayDeletedFile, nil) -} - -func overlayDeletedFile(root, path string, fi os.FileInfo) (string, error) { - if fi.Mode()&os.ModeCharDevice != 0 { - s := fi.Sys().(*syscall.Stat_t) - if unix.Major(uint64(s.Rdev)) == 0 && unix.Minor(uint64(s.Rdev)) == 0 { // nolint: unconvert - return path, nil - } - } - if fi.Mode()&os.ModeDir != 0 { - opaque, err := system.Lgetxattr(filepath.Join(root, path), "trusted.overlay.opaque") - if err != nil { - return "", err - } - if len(opaque) == 1 && opaque[0] == 'y' { - return path, nil - } - } - - return "", nil - -} diff --git a/components/engine/volume/testutils/testutils.go b/components/engine/volume/testutils/testutils.go index 5bb38e3f33..0a20a35516 100644 --- a/components/engine/volume/testutils/testutils.go +++ b/components/engine/volume/testutils/testutils.go @@ -41,11 +41,12 @@ func (NoopVolume) CreatedAt() (time.Time, error) { return time.Now(), nil } type FakeVolume struct { name string driverName string + createdAt time.Time } // NewFakeVolume creates a new fake volume for testing func NewFakeVolume(name string, driverName string) volume.Volume { - return FakeVolume{name: name, driverName: driverName} + return FakeVolume{name: name, driverName: driverName, createdAt: time.Now()} } // Name is the name of the volume @@ -69,7 +70,9 @@ func (FakeVolume) Status() map[string]interface{} { } // CreatedAt provides the time the volume (directory) was created at -func (FakeVolume) CreatedAt() (time.Time, error) { return time.Now(), nil } +func (f FakeVolume) CreatedAt() (time.Time, error) { + return f.createdAt, nil +} // FakeDriver is a driver that generates fake volumes type FakeDriver struct {