container-diff icon indicating copy to clipboard operation
container-diff copied to clipboard

layer diff depends on layer ordering

Open aaron-prindle opened this issue 7 years ago • 4 comments

currently when diffing layers of images, container-diff essentially requires layers to in the same order and have the same number of layers for the diff to be meaningful. A single missing layer early will cause the layer introspection to compare "the wrong" layers. it would be awesome if container-diff could try to correlate the layers but it is understandable if this is outside the scope of container-diff

aaron-prindle avatar Jun 04 '18 22:06 aaron-prindle

I agree this would be great, but I'm not totally sure what it would look like. Layer comparison is hard because we don't really have a good way of "correlating" layers. SHAs don't work because adding a single file to a layer gives it an entirely new SHA. We could try and do something clever with sizes (for each layer, find the layer closest in size and compare those two), but there are corner cases where that would break down and give us garbage results. Any suggestions for a better way to go about this are certainly welcome :)

nkubala avatar Jun 11 '18 22:06 nkubala

just an idea, but probably something similar to what was suggested in https://github.com/GoogleContainerTools/container-diff/pull/233#pullrequestreview-120040358 would do the trick. Instead of trying to guess the layers to compare, let user select them by introducing somehow the layer IDs to compare.

davidcassany avatar Jun 27 '18 14:06 davidcassany

I think that's a fine idea actually, as discussed in #248 it's probably the only option for comparing images with a variable number of layers. Are you interested in sending a PR?

nkubala avatar Jul 20 '18 19:07 nkubala

@nkubala I can try to make a PR for that, probably it will take me some days to find the spare cycles to do it, but I'll try to come up with a suggestion.

davidcassany avatar Jul 23 '18 15:07 davidcassany