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

Snapshot overlay view #532

Merged
merged 4 commits into from
Feb 27, 2017
Merged

Conversation

dmcgowan
Copy link
Member

Implements view function for overlay. This creates an active directory in overlay with no upper or work directory. Mounts without these directories will be treated as readonly in overlay.

For reference

Multiple lower layers can now be given using the the colon (":") as a
separator character between the directory names.  For example:

  mount -t overlay overlay -olowerdir=/lower1:/lower2:/lower3 /merged

As the example shows, "upperdir=" and "workdir=" may be omitted.  In
that case the overlay will be read-only.

https://www.kernel.org/doc/Documentation/filesystems/overlayfs.txt

@codecov-io
Copy link

codecov-io commented Feb 18, 2017

Codecov Report

Merging #532 into master will decrease coverage by -0.54%.
The diff coverage is 61.22%.

@@            Coverage Diff             @@
##           master     #532      +/-   ##
==========================================
- Coverage   62.12%   61.59%   -0.54%     
==========================================
  Files           3        3              
  Lines         404      440      +36     
==========================================
+ Hits          251      271      +20     
- Misses         93      102       +9     
- Partials       60       67       +7
Impacted Files Coverage Δ
snapshot/overlay/overlay.go 65.9% <61.22%> (-2.03%)

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 5bdfeea...c48e9a7. Read the comment docs.

Copy link
Member

@estesp estesp left a comment

Choose a reason for hiding this comment

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

minor typo in the test, but would be confusing if not fixed for a potential future error case.

t.Errorf("expected source %q but received %q", expected, m.Source)
}
if m.Options[0] != "ro" {
t.Errorf("expected mount option rw but received %q", m.Options[0])
Copy link
Member

Choose a reason for hiding this comment

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

nit: typo - "expected mount option ro but received.."

Copy link
Member Author

Choose a reason for hiding this comment

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

nice catch, thanks! updated

@@ -174,7 +185,7 @@ func (o *Snapshotter) Walk(fn func(snapshot.Info) error) error {
})
}

func (o *Snapshotter) newActiveDir(key string) (*activeDir, error) {
func (o *Snapshotter) newActiveDir(key string, readonly bool) (*activeDir, error) {
Copy link
Member

Choose a reason for hiding this comment

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

This extra argument is only used in two places and is hard-coded in each. Can this logic be handled in the caller instead of adding a bool arg?

Copy link
Member

Choose a reason for hiding this comment

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

This okay here, since we've split the callers into Prepare and View.

@@ -236,6 +254,13 @@ func (a *activeDir) setParent(name string) error {
}

func (a *activeDir) commit(name string, c *cache) error {
if _, err := os.Stat(filepath.Join(a.path, "fs")); err != nil {
if os.IsNotExist(err) {
return errors.New("cannot commit view")
Copy link
Member

Choose a reason for hiding this comment

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

errors.Wrap?

Copy link
Member Author

Choose a reason for hiding this comment

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

My anticipation is that this could be replaced with an error defined in the snapshot package as I think this would be an error any snapshot implementation would return (trying to commit a view, an error described in the function interface definition)

@dmcgowan dmcgowan force-pushed the snapshot-overlay-view branch from 41a6c1b to 4edd969 Compare February 21, 2017 21:10
@@ -114,7 +114,18 @@ func (o *Snapshotter) Prepare(key, parent string) ([]containerd.Mount, error) {
}

func (o *Snapshotter) View(key, parent string) ([]containerd.Mount, error) {
panic("not implemented")
if parent == "" {
Copy link
Member

Choose a reason for hiding this comment

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

Do we not allow viewing an empty directory?

We should define that boundary condition.

Copy link
Member Author

Choose a reason for hiding this comment

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

I don't think it makes much sense to view an empty directory. The callers will need to check but I think it makes more sense for the caller to handle it than have the snapshot drivers create an empty directory just to create a ro bind mount to it.

Copy link
Member

Choose a reason for hiding this comment

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

The definition of the empty string is the empty directory. I see no reason to create this special case and arbitrary restriction.

@stevvooe
Copy link
Member

LGTM

Allow creating actives without an upper directory for
capturing changes. Actives without the upper directory
will always be mounted read only. Read only actives
must have a parent.

Signed-off-by: Derek McGowan <derek@mcgstyle.net> (github: dmcgowan)
Signed-off-by: Derek McGowan <derek@mcgstyle.net> (github: dmcgowan)
Signed-off-by: Derek McGowan <derek@mcgstyle.net> (github: dmcgowan)
@dmcgowan dmcgowan force-pushed the snapshot-overlay-view branch from 4edd969 to eeb8855 Compare February 27, 2017 21:32
@dmcgowan
Copy link
Member Author

dmcgowan commented Feb 27, 2017

Rebased, removed unnecessary restriction on View having a parent

Signed-off-by: Derek McGowan <derek@mcgstyle.net> (github: dmcgowan)
@stevvooe stevvooe merged commit 4edcaa3 into containerd:master Feb 27, 2017
@dmcgowan dmcgowan deleted the snapshot-overlay-view branch April 5, 2017 23:30
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.

5 participants