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

Skip duplicate image layers when copying #129

Merged
merged 2 commits into from
Sep 6, 2022

Conversation

carolynvs
Copy link
Collaborator

Some images have duplicate layers, for example docker/whalesay. This can be caused by DOCKERFILE commands that are executed but do not modify the filesystem. While it's not optimal for an image to do this, it shouldn't cause errors either.

When we copy the images used by a manifest into the bundle repository, we are creating a copy task for each layer resulting in multiple copy tasks attempting to copy the same layer. Only the first copy task works, and the others fail with "unexpected size" errors because the layer was already copied (fully or in part) in the previous task.

I've updated descriptorContentHandler to keep track of the layers, so that we can skip over duplicate layers.

Fixes #128

Some images have duplicate layers, for example docker/whalesay. This can be caused by DOCKERFILE commands that are executed but do not modify the filesystem. While it's not optimal for an image to do this, it shouldn't cause errors either.

When we copy the images used by a manifest into the bundle repository, we are creating a copy task for each layer resulting in multiple copy tasks attempting to copy the same layer. Only the first copy task works, and the others fail with "unexpected size" errors because the layer was already copied (fully or in part) in the previous task.

I've updated descriptorContentHandler to keep track of the layers, so that we can skip over duplicate layers.

Signed-off-by: Carolyn Van Slyck <me@carolynvanslyck.com>
Signed-off-by: Carolyn Van Slyck <me@carolynvanslyck.com>
@carolynvs carolynvs marked this pull request as ready for review September 5, 2022 03:37
Copy link
Member

@radu-matei radu-matei left a comment

Choose a reason for hiding this comment

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

Thanks for the fix!

LGTM

@carolynvs carolynvs merged commit fadbd17 into cnabio:main Sep 6, 2022
@carolynvs carolynvs deleted the skip-duplicate-layers branch September 6, 2022 00:55
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.

Image copy fails when image contains duplicate layers
2 participants