Skip to content

Implement Archive.apply on Windows#1903

Merged
crosbymichael merged 2 commits intocontainerd:masterfrom
darstahl:ArchiveOpts
Jan 2, 2018
Merged

Implement Archive.apply on Windows#1903
crosbymichael merged 2 commits intocontainerd:masterfrom
darstahl:ArchiveOpts

Conversation

@darstahl
Copy link
Copy Markdown
Contributor

@darstahl darstahl commented Dec 9, 2017

This implements archive.Apply on Windows. It uses opts similar to Snapshots.Opt, etc.

The current options on Windows are BaseLayers (which is required for all layers except the base layer) and isolation, which is not currently used, but will be enabled in another PR, and is necessary for Windows layer extraction.

I have a local updated version of snapshotter and differ PR that I've tested this against. I'll be pushing that one soon.

The second commit is a temp hack as vndr is deleting the file even though it is referenced. I'll work that out on Monday.

@crosbymichael @stevvooe @dmcgowan @jessvalarezo

@dnephin
Copy link
Copy Markdown
Contributor

dnephin commented Dec 11, 2017

vendor failures are because vendor.conf needs to be updated to use the correct version

@dmcgowan
Copy link
Copy Markdown
Member

Thanks @darrenstahlmsft, this is very clean! Is there ever a case where the existing Apply logic which is now in tar_unix.go would be called in Windows, I was thinking maybe if it was used with the naive snapshot driver for something?

Signed-off-by: Darren Stahl <[email protected]>
@darstahl
Copy link
Copy Markdown
Contributor Author

@dnephin Oops. Silly mistake on my part. Fixed. Thanks.

@dmcgowan It would not be used for any container layers on Windows, but I guess the naive snapshotter can be used to manage things other than container layers. I can restructure in a way that the old tar apply can be used as well from the naive snapshotter.

@darstahl
Copy link
Copy Markdown
Contributor Author

Added a new ApplyOpt called AsWindowsContainerLayer to trigger using the Windows Container Layer apply code, otherwise it does the naive apply as it used to. That way naive differ will work the same without changes, but the new Windows Differ can apply Windows layers.

@codecov-io
Copy link
Copy Markdown

Codecov Report

Merging #1903 into master will decrease coverage by 1.48%.
The diff coverage is 7.83%.

Impacted file tree graph

@@            Coverage Diff            @@
##           master   #1903      +/-   ##
=========================================
- Coverage   47.29%   45.8%   -1.49%     
=========================================
  Files          89      91       +2     
  Lines        8830    9127     +297     
=========================================
+ Hits         4176    4181       +5     
- Misses       3968    4258     +290     
- Partials      686     688       +2
Flag Coverage Δ
#linux 50.66% <36.66%> (-0.01%) ⬇️
#windows 40.7% <5.7%> (-1.54%) ⬇️
Impacted Files Coverage Δ
archive/tar_opts_windows.go 0% <0%> (ø)
archive/strconv.go 0% <0%> (ø)
archive/tar_windows.go 8.49% <0.8%> (-32.19%) ⬇️
archive/tar_unix.go 52.38% <100%> (+1.56%) ⬆️
archive/tar.go 43.68% <32.05%> (-0.31%) ⬇️

Continue to review full report at Codecov.

Legend - Click here to learn more
Δ = absolute <relative> (impact), ø = not affected, ? = missing data
Powered by Codecov. Last update 6393165...539192a. Read the comment docs.

@stevvooe stevvooe added this to the 1.1 milestone Dec 14, 2017
@darstahl
Copy link
Copy Markdown
Contributor Author

This closes #1678 when merged.

Comment thread archive/tar.go Outdated
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

Why move above? Is there a reason we would want to do the done check after the blocking call rather than before?

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

Not intentional. I moved this when attempting to combine the tar extract loop with Windows apply, but decided against it. I'll move it back where it was.

Comment thread archive/tar_windows.go Outdated
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

Could these privilege calls be done by the caller?

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

Certainly could be. Moving it to the client would also mean that the archive.Apply would not need to be aware if it is running isolated or not, which is likely better.

Comment thread archive/tar_windows.go Outdated
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

Do we want to remove this for now based on previous discussion? What would happen if 2 unpacks are happening simultaneously. Personally I would rather not have the archive package know about isolation and privileges and leave that to the higher level caller.

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

Yes. I'll remove this for now.

@darstahl darstahl mentioned this pull request Dec 14, 2017
8 tasks
@dmcgowan
Copy link
Copy Markdown
Member

I am not familiar enough with links in Windows, does any of the Window's apply code need to be leveraging fs.RootPath?

@darstahl
Copy link
Copy Markdown
Contributor Author

darstahl commented Dec 15, 2017

This is handled by the layer extraction code in the platform. All paths should be relative to the layer root, rather than full paths, which is why the paths here do not need to be rooted.

Edit: Note that the links in this code are not OS links, but rather adding links via the hcsshim layer writer APIs

@codecov-io
Copy link
Copy Markdown

Codecov Report

Merging #1903 into master will decrease coverage by 1.37%.
The diff coverage is 8.04%.

Impacted file tree graph

@@            Coverage Diff             @@
##           master    #1903      +/-   ##
==========================================
- Coverage   47.14%   45.76%   -1.38%     
==========================================
  Files          89       91       +2     
  Lines        8833     9109     +276     
==========================================
+ Hits         4164     4169       +5     
- Misses       3981     4250     +269     
- Partials      688      690       +2
Flag Coverage Δ
#linux 50.48% <35.59%> (-0.01%) ⬇️
#windows 40.65% <5.78%> (-1.43%) ⬇️
Impacted Files Coverage Δ
archive/tar_opts_windows.go 0% <0%> (ø)
archive/strconv.go 0% <0%> (ø)
archive/tar_windows.go 8.96% <0.86%> (-31.72%) ⬇️
archive/tar_unix.go 52.38% <100%> (+1.56%) ⬆️
archive/tar.go 43.68% <31.16%> (-0.31%) ⬇️

Continue to review full report at Codecov.

Legend - Click here to learn more
Δ = absolute <relative> (impact), ø = not affected, ? = missing data
Powered by Codecov. Last update 5956e15...c195ebb. Read the comment docs.

Comment thread archive/tar_windows.go
if err != nil {
return nil, err
}
if ahdr.Typeflag != tar.TypeReg || !strings.HasPrefix(ahdr.Name, hdr.Name+":") {
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

Is : safe here because Windows doesn't allow : as part of a file name?

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

Yep

Comment thread archive/tar_windows.go
}

// fileInfoFromHeader retrieves basic Win32 file information from a tar header, using the additional metadata written by
// WriteTarFileFromBackupStream.
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

Where is WriteTarFileFromBackupStream?

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

Current implementation used by Docker is at https://github.com/Microsoft/go-winio/blob/master/backuptar/tar.go#L119

A second PR to implement the Diff side of archive will include the containerd implementation.

@dmcgowan
Copy link
Copy Markdown
Member

A couple questions then LGTM

@crosbymichael
Copy link
Copy Markdown
Member

LGTM

@crosbymichael crosbymichael merged commit e479165 into containerd:master Jan 2, 2018
// ApplyOptions provides additional options for an Apply operation
type ApplyOptions struct {
ParentLayerPaths []string // Parent layer paths used for Windows layer apply
IsWindowsContainerLayer bool // True if the tar stream to be applied is a Windows Container Layer
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

Would it help to make this more generic? It seems like this should be set via a mediatype or other mechanism.

@darstahl darstahl deleted the ArchiveOpts branch January 17, 2018 01:01
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.

6 participants