Merge component 'engine' from git@github.com:docker/engine master

This commit is contained in:
GordonTheTurtle
2018-06-21 17:05:30 +00:00
6 changed files with 25 additions and 61 deletions

View File

@ -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)
}

View File

@ -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)
}

View File

@ -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

View File

@ -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)

View File

@ -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
}

View File

@ -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 {