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

Fix: Flatten layer function needs to return existing files in the layer correctly #2057

Merged

Conversation

gabyx
Copy link
Contributor

@gabyx gabyx commented Apr 20, 2022

Fixes #1420 and also probably fixes: #1944

Description

The getFlattenedPathsForWhiteout function was kind os suspicous and definitely not correct. It reports .wh. prefixed files as existing, which IMO should not be included. Since: This function should IMO return the list of existing paths in the layer, since its only used in this context in utils.WalkFS. This probably causes also the existence of .wh.wh.... in layers...

Submitter Checklist

These are the criteria that every PR should meet, please check them off as you
review them:

  • Includes unit tests
    Triggering these bugs above is really hard. If I have time I will try to test it.

See the contribution guide for more details.

Reviewer Notes

  • The code flow looks good.
  • Unit tests and or integration tests added.

Release Notes

Describe any changes here so maintainer can include it in the release notes, or delete this block.

Missing

@gabyx gabyx changed the title Bugfix/fix flatten layer function Fix: Flatten layer function needs to return existing files in the layer correctly Apr 20, 2022
basename := filepath.Base(p)
if strings.HasPrefix(basename, archive.WhiteoutPrefix) {
deletedFile := filepath.Join(filepath.Dir(p), strings.TrimPrefix(basename, archive.WhiteoutPrefix))
delete(paths, deletedFile)
Copy link
Contributor Author

Choose a reason for hiding this comment

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

Here I delete the corresponding file, also .wh. prefixed files never enter the paths map.

@imjasonh imjasonh merged commit 76a54a0 into GoogleContainerTools:main Apr 26, 2022
@gabyx gabyx deleted the bugfix/fix-flatten-layer-function branch April 28, 2022 06:10
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
2 participants