Skip to content

Commit

Permalink
Remove dependency on tar2vhd for LCOW differ
Browse files Browse the repository at this point in the history
This change no longer requires the use of a UtlityVM on Windows to convert the
layer tar to an ext4 vhd for LCOW. This has a significant performance boost
that makes linux/amd64 layer extraction comparable to native Linux performance.

Signed-off-by: Justin Terry (VM) <juterry@microsoft.com>
  • Loading branch information
jterry75 committed Oct 10, 2018
1 parent 15f19d7 commit cce78d4
Show file tree
Hide file tree
Showing 13 changed files with 2,085 additions and 48 deletions.
31 changes: 22 additions & 9 deletions diff/lcow/lcow.go
Original file line number Diff line number Diff line change
Expand Up @@ -21,10 +21,11 @@ package lcow
import (
"context"
"io"
"os/exec"
"os"
"path"
"time"

"github.com/Microsoft/hcsshim/ext4/tar2ext4"
"github.com/containerd/containerd/archive/compression"
"github.com/containerd/containerd/content"
"github.com/containerd/containerd/diff"
Expand All @@ -40,6 +41,11 @@ import (
"github.com/sirupsen/logrus"
)

const (
// maxLcowVhdSizeGB is the max size in GB of any layer
maxLcowVhdSizeGB = 128 * 1024 * 1024 * 1024
)

func init() {
plugin.Register(&plugin.Registration{
Type: plugin.DiffPlugin,
Expand Down Expand Up @@ -131,15 +137,22 @@ func (s windowsLcowDiff) Apply(ctx context.Context, desc ocispec.Descriptor, mou
r: io.TeeReader(rdr, digester.Hash()),
}

cmd := exec.Command(
"runhcs.exe",
"tar2vhd",
"--scratchpath", path.Join(layer, "sandbox.vhdx"), // TODO: JTERRY75 when the snapshotter changes this to be scratch.vhdx update it here too.
"--destpath", path.Join(layer, "layer.vhd"))
layerPath := path.Join(layer, "layer.vhd")
outFile, err := os.Create(layerPath)
if err != nil {
return emptyDesc, err
}
defer outFile.Close()
defer func() {
if err != nil {
outFile.Close()
os.Remove(layerPath)
}
}()

cmd.Stdin = rc
if bytes, err := cmd.CombinedOutput(); err != nil {
return emptyDesc, errors.Wrapf(err, "failed to exec runhcs.exe tar2vhd: %s", string(bytes))
err = tar2ext4.Convert(rc, outFile, tar2ext4.ConvertWhiteout, tar2ext4.AppendVhdFooter, tar2ext4.MaximumDiskSize(maxLcowVhdSizeGB))
if err != nil {
return emptyDesc, errors.Wrapf(err, "failed to convert tar to ext4 vhd")
}

return ocispec.Descriptor{
Expand Down
2 changes: 1 addition & 1 deletion vendor.conf
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@ golang.org/x/sync 450f422ab23cf9881c94e2db30cac0eb1b7cf80c
github.com/BurntSushi/toml a368813c5e648fee92e5f6c30e3944ff9d5e8895
github.com/grpc-ecosystem/go-grpc-prometheus 6b7015e65d366bf3f19b2b2a000a831940f0f7e0
github.com/Microsoft/go-winio v0.4.10
github.com/Microsoft/hcsshim v0.7.6
github.com/Microsoft/hcsshim v0.7.9
google.golang.org/genproto d80a6e20e776b0b17a324d0ba1ab50a39c8e8944
golang.org/x/text 19e51611da83d6be54ddafce4a4af510cb3e9ea4
github.com/containerd/ttrpc 2a805f71863501300ae1976d29f0454ae003e85a
Expand Down
6 changes: 3 additions & 3 deletions vendor/github.com/Microsoft/hcsshim/cmd/go-runhcs/runhcs.go

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Loading

0 comments on commit cce78d4

Please sign in to comment.