From 273f50c741e82a0be3e9f9d4c975cc18801dfe38 Mon Sep 17 00:00:00 2001 From: Vincent Batts Date: Mon, 27 Jul 2015 13:23:52 -0400 Subject: [PATCH] graphdriver/*: expect uncompressed tar for ApplyDiff The `ApplyDiff` function takes a tar archive stream that is automagically decompressed later. This was causing a double decompression, and when the layer was empty, that causes an early EOF. Signed-off-by: Vincent Batts --- daemon/graphdriver/aufs/aufs.go | 2 +- daemon/graphdriver/driver.go | 1 + daemon/graphdriver/fsdiff.go | 2 +- daemon/graphdriver/overlay/overlay.go | 2 +- 4 files changed, 4 insertions(+), 3 deletions(-) diff --git a/daemon/graphdriver/aufs/aufs.go b/daemon/graphdriver/aufs/aufs.go index 893801a364..eec4deee66 100644 --- a/daemon/graphdriver/aufs/aufs.go +++ b/daemon/graphdriver/aufs/aufs.go @@ -323,7 +323,7 @@ func (a *Driver) Diff(id, parent string) (archive.Archive, error) { } func (a *Driver) applyDiff(id string, diff archive.ArchiveReader) error { - return chrootarchive.Untar(diff, path.Join(a.rootPath(), "diff", id), nil) + return chrootarchive.UntarUncompressed(diff, path.Join(a.rootPath(), "diff", id), nil) } // DiffSize calculates the changes between the specified id diff --git a/daemon/graphdriver/driver.go b/daemon/graphdriver/driver.go index b7e35e4c0d..2f44fddcbf 100644 --- a/daemon/graphdriver/driver.go +++ b/daemon/graphdriver/driver.go @@ -77,6 +77,7 @@ type Driver interface { // ApplyDiff extracts the changeset from the given diff into the // layer with the specified id and parent, returning the size of the // new layer in bytes. + // The archive.ArchiveReader must be an uncompressed stream. ApplyDiff(id, parent string, diff archive.ArchiveReader) (size int64, err error) // DiffSize calculates the changes between the specified id // and its parent and returns the size in bytes of the changes diff --git a/daemon/graphdriver/fsdiff.go b/daemon/graphdriver/fsdiff.go index e091e619b8..bee9682e70 100644 --- a/daemon/graphdriver/fsdiff.go +++ b/daemon/graphdriver/fsdiff.go @@ -121,7 +121,7 @@ func (gdw *naiveDiffDriver) ApplyDiff(id, parent string, diff archive.ArchiveRea start := time.Now().UTC() logrus.Debugf("Start untar layer") - if size, err = chrootarchive.ApplyLayer(layerFs, diff); err != nil { + if size, err = chrootarchive.ApplyUncompressedLayer(layerFs, diff); err != nil { return } logrus.Debugf("Untar time: %vs", time.Now().UTC().Sub(start).Seconds()) diff --git a/daemon/graphdriver/overlay/overlay.go b/daemon/graphdriver/overlay/overlay.go index 9cde62ae96..fc04057c35 100644 --- a/daemon/graphdriver/overlay/overlay.go +++ b/daemon/graphdriver/overlay/overlay.go @@ -411,7 +411,7 @@ func (d *Driver) ApplyDiff(id string, parent string, diff archive.ArchiveReader) return 0, err } - if size, err = chrootarchive.ApplyLayer(tmpRootDir, diff); err != nil { + if size, err = chrootarchive.ApplyUncompressedLayer(tmpRootDir, diff); err != nil { return 0, err }