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

checkout: honor opaque checkouts #1486

Closed
wants to merge 1 commit into from

Conversation

giuseppe
Copy link
Member

@giuseppe giuseppe commented Mar 5, 2018

Signed-off-by: Giuseppe Scrivano [email protected]

@giuseppe
Copy link
Member Author

@nalind does this implementation look good to you?

@giuseppe giuseppe force-pushed the opaque-whiteout-support branch from e39b942 to d1fc1d9 Compare May 31, 2018 13:26
@giuseppe giuseppe force-pushed the opaque-whiteout-support branch from d1fc1d9 to 7984b3a Compare July 30, 2018 12:05
@giuseppe
Copy link
Member Author

giuseppe commented Jul 30, 2018

Dropping the WIP label as I think it is ready for review

@giuseppe giuseppe changed the title [WIP] checkout: honor opaque checkouts checkout: honor opaque checkouts Jul 30, 2018
@giuseppe giuseppe removed the WIP label Jul 30, 2018
@giuseppe giuseppe force-pushed the opaque-whiteout-support branch from 7984b3a to 5bedcad Compare August 7, 2018 08:23
@giuseppe giuseppe force-pushed the opaque-whiteout-support branch from 5bedcad to 1b9ce05 Compare September 3, 2018 07:02
@giuseppe giuseppe force-pushed the opaque-whiteout-support branch 2 times, most recently from b413b02 to a6fc88d Compare October 3, 2018 09:20
@giuseppe giuseppe force-pushed the opaque-whiteout-support branch 4 times, most recently from 05fc070 to 72b6720 Compare October 15, 2018 11:39
@giuseppe
Copy link
Member Author

tests are passing

@giuseppe giuseppe force-pushed the opaque-whiteout-support branch from 72b6720 to 7334ffd Compare October 17, 2018 20:01
@giuseppe
Copy link
Member Author

/cc @cgwalters

@cgwalters
Copy link
Member

A little bit more information - a link to some other code that handles this format e.g. - would be useful in the commit message or as a code comment.

This is a serialization of the

A directory is made opaque by setting the xattr "trusted.overlay.opaque"

from the kernel Documentation/filesystems/overlayfs.txt?

{
is_opaque_whiteout = (g_str_equal (fname, OPAQUE_WHITEOUT_NAME));
if (is_opaque_whiteout)
break;
Copy link
Member

Choose a reason for hiding this comment

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

One thing I don't quite understand is why we're looping over all of the children here. Doesn't there need to be name matching against the target somehow? Or hmm...is the serialization that there's exactly one child with that name?

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 am looking for a child ".wh..wh..opq" and it needs to have exactly that name. I didn't find a better way for having this search in O(1). Is there a better way to look for it?

Copy link
Member

Choose a reason for hiding this comment

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

I am looking for a child ".wh..wh..opq" and it needs to have exactly that name.

My question is - should that be the only child?

Copy link
Member Author

Choose a reason for hiding this comment

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

no, there can be other children and they will appear normally in the directory. The ".wh..wh..opq" file is only to hide anything that is in the lower layers, but the same layer can add more content

@giuseppe
Copy link
Member Author

A little bit more information - a link to some other code that handles this format e.g. - would be useful in the commit message or as a code comment.

This PR came after the comment here: containers/storage#137 (comment)

What I've done is:

skopeo copy docker://docker.io/redis@sha256:26c93c5b06eaa323bb1089500f42b0dd158138772348b865e364127f1d554982  ostree:foo@/ostree/repo
ostree ls ociimage/67b22db27e5144c14efdf55d9cef9c3dadffb43593790ec99663fb1b783dbb6b /var/lib/apt/lists/partial
d00755 0 0      0 /var/lib/apt/lists/partial
-00755 0 0      0 /var/lib/apt/lists/partial/.wh..wh..opq

what this file does is to rm -rf every entry in the directory where it is present so that /var/lib/apt/lists/partial exists but it is empty

I'll amend more information in the commit message

if a file ".wh..wh..opq" is present in a directory, delete anything
from lower layers that is already in that directory.

Signed-off-by: Giuseppe Scrivano <[email protected]>
@giuseppe giuseppe force-pushed the opaque-whiteout-support branch from 7334ffd to 035e693 Compare October 26, 2018 16:17
@cgwalters
Copy link
Member

@rh-atomic-bot r+ 035e693

@rh-atomic-bot
Copy link

⚡ Test exempted: merge already tested.

@cgwalters
Copy link
Member

OK, thanks! I think I understand now. Just in general though I really prefer if even nearly trivial changes have some sort of rationale. For example in c9a9e6c

I could have just said "Add bindings section" since it's really obvious what I'm doing but even there I added a why I'm doing it. Another example is:
5183c8f
Where the why is "Making this change since I saw an unprefixed error in an issue.".

This is a far from trivial change and I think deserved a commit message; thanks for fleshing it out a bit! We should probably still add comments to the code but not blocking on that since the previous code didn't have a lot either (and in some places in libostree we're relatively decent with comments, others not so much).

@cgwalters
Copy link
Member

And sorry again about the delay here...I think I must have missed notifications, and I sort of use the default github PR viewer as a "review stack" but this one got too buried. Wish there was a way to change that view to default to "recently changed" and not "initial creation time".

@giuseppe
Copy link
Member Author

And sorry again about the delay here...I think I must have missed notifications, and I sort of use the default github PR viewer as a "review stack" but this one got too buried. Wish there was a way to change that view to default to "recently changed" and not "initial creation time".

no problem :-) I've left it marked as WIP for a long time.

Also, for reference, I've used this Dockerfile to get an opaque checkout:

FROM alpine
RUN rm -rf /srv && mkdir -p /srv && touch /srv/a

Once it is imported into ostree I see:

# ostree ls -R ociimage/aa1c5b4533c0d2c7d18d06c7618a7e4318a71764b9a394202840cc85e39d7630 /
d00755 0 0      0 /
d00755 0 0      0 /etc
-00755 0 0      0 /etc/resolv.conf
d00755 0 0      0 /run
d00755 0 0      0 /run/secrets
d00755 0 0      0 /srv
-00755 0 0      0 /srv/.wh..wh..opq
-00644 0 0      0 /srv/a

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