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

Confused about Diff() and Changes() #479

Closed
adrianreber opened this issue Dec 2, 2019 · 1 comment
Closed

Confused about Diff() and Changes() #479

adrianreber opened this issue Dec 2, 2019 · 1 comment

Comments

@adrianreber
Copy link

I guess I am confused by all the layers but I currently cannot find the right way to use Diff() when compared to Changes(). This is motivated by the podman bug report: containers/podman#4606

Looking at the documentation of Diff() and Changes() I see:

        // Changes returns a slice of Change structures, which contain a pathname
        // (Path) and a description of what sort of change (Kind) was made by the
        // layer (either ChangeModify, ChangeAdd, or ChangeDelete), relative to a
        // specified layer.  By default, the layer's parent is used as a reference.
        Changes(from, to string) ([]archive.Change, error)

        // Diff produces a tarstream which can be applied to a layer with the contents
        // of the first layer to produce a layer with the contents of the second layer.
        // By default, the parent of the second layer is used as the first
        // layer, so it need not be specified.  Options can be used to override
        // default behavior, but are also not required.
        Diff(from, to string, options *DiffOptions) (io.ReadCloser, error)

To checkpoint a container with the changes to the root file-system I am using Diff() to get a tarstream of all the changes since the container has been started.

The code in container_internal_linux.go looks like this:

tarStream, err := c.runtime.GetDiffTarStream("", c.ID())

This is using the same parameters as podman diff. (This is all confusing as the podman command diff uses the call Changes() and Diff() creates the tarstream, I hope I did not mix them up).

Reading the comments above more closely it seems Diff() (to create a tarstream) does

"By default, the parent of the second layer is used as the first layer, so it need not be specified."

This confuses me and maybe someone can give me an explanation how to use Diff() to get the same results as Changes().

Currently the rootfs diff in the checkpoint archive contains the changes to the container as well as the complete layer below. In an one layer images like ubi8, this is all the content. I would like to only have the changes in the tarstream between the current running container and the layer the container was started from.

@adrianreber
Copy link
Author

Closing this, as I worked around it in Podman.

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

No branches or pull requests

1 participant