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

v1.Layer doesn't abstract away tarball #487

Open
jonjohnsonjr opened this issue Jul 24, 2019 · 9 comments
Open

v1.Layer doesn't abstract away tarball #487

jonjohnsonjr opened this issue Jul 24, 2019 · 9 comments

Comments

@jonjohnsonjr
Copy link
Collaborator

There's not a way to access files in a v1.Layer other than through Uncompressed + tar.NewReader. Our current abstraction is fine for moving images around, but not for accessing the actual filesystem. If we exposed a way to directly access files, we could be resilient to changes to the format, but we probably don't have enough information to make good decisions for the actual abstraction. Opening this as a nice place to dump ideas.

@clrprod
Copy link
Contributor

clrprod commented Jul 24, 2019

I like FileMaps as an export, since they're easy to generate. They don't work well for larger containers. The classic way to represent files is a http.FileServer. We could also implement a Read / ReadDir method. which is cheaper. I know there is some work on making this really cheap (from Brad Fitzpatrick), so maybe we should copy the api they are setting up?

@jonjohnsonjr
Copy link
Collaborator Author

jonjohnsonjr commented Jul 24, 2019

For reference: https://github.com/google/crfs (godoc).

There might be a small interface we could pull out of here.

@jonjohnsonjr
Copy link
Collaborator Author

We should implement the same interface as http.FileSystem:

type FileSystem interface {
        Open(name string) (File, error)
}

The File has Readdir:

type File interface {
        io.Closer
        io.Reader
        io.Seeker
        Readdir(count int) ([]os.FileInfo, error)
        Stat() (os.FileInfo, error)
}

So we could call layer.Open("/").Readdir(-1) and traverse the filesystem, but it would be really nice to have a way to efficiently get an index of the entire filesystem (not just one directory), something like Brad's TOC footer for stargz.

@dprotaso
Copy link
Contributor

dprotaso commented Aug 2, 2019 via email

@jonjohnsonjr
Copy link
Collaborator Author

Related: #531

Compressed presumes gzip.

@micahyoung
Copy link
Contributor

micahyoung commented Mar 4, 2020

Just wanted to add that this would be very nice for abstracting some Windows/Linux layer content differences (as required by Docker WCOW, K8s on Windows, ContainerD for Windows, etc):

When Reading:

  • File entries in the tar are prefixed with Files/ instead of /

If the abstraction went so far as to support writing to layers:

  • Each Windows layers require Files/ and Hives/ directory entries
  • Each parent directory for a nested path must have an prior, explicit tar entry

@jonjohnsonjr
Copy link
Collaborator Author

I'd be interested in learning more about that. I haven't looked too much into it, but the windows container stuff seems remarkably bad, and there are a ton of random caveats that aren't really documented anywhere.

@github-actions
Copy link

This issue is stale because it has been open for 90 days with no
activity. It will automatically close after 30 more days of
inactivity. Reopen the issue with /reopen. Mark the issue as
fresh by adding the comment /remove-lifecycle stale.

@jonjohnsonjr
Copy link
Collaborator Author

https://tip.golang.org/doc/go1.16#fs 👀

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

4 participants