Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

diff: implement windows layer support for linux #510

Merged
merged 1 commit into from
Jul 17, 2018

Conversation

tonistiigi
Copy link
Member

split from #499 for easier review

The tar blobs containing the layers have a different structure in linux and windows. The current differ ignores that and hopes that the differ is compatible with the blob.

For example, linux blobs directly contain the rootfs for the container while windows container have a structure like Files/, Hives/, UtilityVM with the Files directory containing the actual rootfs. Additionally, the records in the windows layer tarball need to contain specific PAX headers that are required for the files to be accessible from the container.

In order to allow cross-build from one os to another, this PR enables additional features in the differ that enable it to apply and diff windows layers on linux, with existing linux snapshotters. On apply only contents of Files/ is extracted and on diff additional directory structure is added with the required header values.

@dmcgowan @AkihiroSuda Do you think we could eventually add this functionality directly to containerd so that BuildKit does not need to override the differ/applier for this case?

Signed-off-by: Tonis Tiigi tonistiigi@gmail.com

@dmcgowan
Copy link
Member

Do you think we could eventually add this functionality directly to containerd so that BuildKit does not need to override the differ/applier for this case?

Yes, but we would probably need to use labels since the differ and applier operations today are based off media type. Can you file an issue on containerd and we can discuss how it should be implemented in containerd and find someone interesting in implementing.

if platform := p.Puller.Platform; platform != nil {
if platform.OS == "windows" && runtime.GOOS != "windows" {
ctx = winlayers.UseWindowsLayerMode(ctx)
layerTypeWindows = true
Copy link
Collaborator

@tiborvass tiborvass Jul 16, 2018

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

if platform.OS == "windows" && runtime.GOOS == "windows" then layerTypeWindows is false, which is confusing. I'm trying to think of a better name: layerNeedsTypeWindows, layerNeedsMarkTypeWindows or needsMarkTypeWindows ... Otherwise maybe just add a comment at definition.

pulled, err := p.Puller.Pull(ctx)
if err != nil {
return nil, err
}
if pulled.ChainID == "" {
return nil, nil
}
return p.CacheAccessor.GetFromSnapshotter(ctx, string(pulled.ChainID), cache.WithDescription(fmt.Sprintf("pulled from %s", pulled.Ref)))
ref, err := p.CacheAccessor.GetFromSnapshotter(ctx, string(pulled.ChainID), cache.WithDescription(fmt.Sprintf("pulled from %s", pulled.Ref)))
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

nit: no need for Sprintf: "pulled from " + pulled.Ref

Signed-off-by: Tonis Tiigi <tonistiigi@gmail.com>
@tonistiigi tonistiigi force-pushed the win-differ-support branch from 9bb10fd to bc76586 Compare July 16, 2018 23:33
return ocispec.Descriptor{}, errors.Wrapf(errdefs.ErrNotImplemented, "unsupported diff media type: %v", desc.MediaType)
}

var ocidesc ocispec.Descriptor
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

nit: variable of same type already defined in return value d. Rename d to ocidesc ?

func addSecurityDescriptor(h *tar.Header) {
if h.Typeflag == tar.TypeDir {
// O:BAG:SYD:(A;OICI;FA;;;BA)(A;OICI;FA;;;SY)(A;;FA;;;BA)(A;OICIIO;GA;;;CO)(A;OICI;0x1200a9;;;BU)(A;CI;LC;;;BU)(A;CI;DC;;;BU)
h.PAXRecords[keySDRaw] = "AQAEgBQAAAAkAAAAAAAAADAAAAABAgAAAAAABSAAAAAgAgAAAQEAAAAAAAUSAAAAAgCoAAcAAAAAAxgA/wEfAAECAAAAAAAFIAAAACACAAAAAxQA/wEfAAEBAAAAAAAFEgAAAAAAGAD/AR8AAQIAAAAAAAUgAAAAIAIAAAALFAAAAAAQAQEAAAAAAAMAAAAAAAMYAKkAEgABAgAAAAAABSAAAAAhAgAAAAIYAAQAAAABAgAAAAAABSAAAAAhAgAAAAIYAAIAAAABAgAAAAAABSAAAAAhAgAA"
Copy link
Collaborator

@tiborvass tiborvass Jul 17, 2018

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

however obvious it can seem from the encoded string, it would be nice to tell readers that it is using base64. Apparently this is a base64 of raw binary stuff, not the human readable string in the comment.

Copy link
Collaborator

@tiborvass tiborvass left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM

@AkihiroSuda AkihiroSuda merged commit 56e2ea0 into moby:master Jul 17, 2018
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants