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: Refactor LayersMap to correct old strange code behavior #2066

Merged
merged 10 commits into from
May 18, 2022

Conversation

gabyx
Copy link
Contributor

@gabyx gabyx commented Apr 28, 2022

  • Added a test.

Fixes #1420
Fixes #1944

Description

Flatten function is still wrong.

Submitter Checklist

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

  • Includes unit tests
  • Adds integration tests if needed.

See the contribution guide for more details.

Reviewer Notes

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

@gabyx
Copy link
Contributor Author

gabyx commented May 10, 2022

My observation is the following:

I have made the following (maybe trivial) observations: LayeredMap.layers never contains any .wh.* whiteout files. This is strange because I assumed that, and the function getFlattenedPaths was probably containing old code which did nothing.

Instead I hardly guess

  • LayeredMap.layers contains the added files
  • LayeredMap.whiteouts contains the deleted files.

However LayeredMap.getFlattenedPaths needs to take these two maps into account, otherwise
we (main) we are passing only the accumulated added files to the util.WalkFS function which is totaly wrong.

@gabyx gabyx force-pushed the bugfix/correct-flatten-paths branch 2 times, most recently from 111279b to 9da0603 Compare May 10, 2022 09:38
@gabyx
Copy link
Contributor Author

gabyx commented May 10, 2022

The other thing is, that this improvements do not yet resolve the symlink bug I see over multiple stages:

FROM base as A
...
RUN echo "DEBUGGINGCHECK:" && ls -al /usr/lib/x86_64-linux-gnu/libbsd.so.0

FROM A as End
RUN echo "DEBUGGINGCHECK:" && ls -al /usr/lib/x86_64-linux-gnu/libbsd.so.0 /// FAILING HERE

Seems that extracting the stage 0 is somehow flawed and does not produce the symlink.

- Added a test.
- Cache current image, track deletes in `whiteouts` as well as normal adds in `layers`.
- Fix ugly delete behavior of `layerHashCache`.
  Delete it when crerating a new snapshot.
- Slight cleanup in `snapshot.go`.
- Format ugly `WalkFS` function.
@gabyx gabyx force-pushed the bugfix/correct-flatten-paths branch from 78eee0c to e0b84c5 Compare May 12, 2022 21:21
@gabyx gabyx force-pushed the bugfix/correct-flatten-paths branch from acc64db to b769a7e Compare May 12, 2022 21:35
@gabyx
Copy link
Contributor Author

gabyx commented May 16, 2022

@tejal29 Could you have a look at this changes that would be great! Especially the firsts commit.

@imjasonh and me are investigating these changes which fixes some ugly bugs with missing files in images when multiple stages are involved.
The current changes vastly reduce some strange old code in favor of some more clean behavior in LayeredMap

@gabyx gabyx force-pushed the bugfix/correct-flatten-paths branch 4 times, most recently from 1dbdede to e0d27aa Compare May 17, 2022 20:39
@gabyx gabyx changed the title fix: Correct getFlattenedPaths function in LayersMap fix: Refactor LayersMap to correct old strange code behavior May 17, 2022
@gabyx
Copy link
Contributor Author

gabyx commented May 17, 2022

@imjasonh: Hurai, finally CI runs through, with minor modifications. IMO only improvements to status quo. Some local test fixes have been applied too to make local testing run through smoothly.

@gabyx gabyx force-pushed the bugfix/correct-flatten-paths branch from 65d4b92 to 7083da8 Compare May 17, 2022 22:29
@gabyx gabyx force-pushed the bugfix/correct-flatten-paths branch from 7083da8 to 62747f6 Compare May 17, 2022 22:30
gabyx added 2 commits May 18, 2022 01:02
- Merge only last layer onto `currentImage`.
@gabyx gabyx force-pushed the bugfix/correct-flatten-paths branch from 11bab2f to d37d622 Compare May 17, 2022 23:21
Copy link
Collaborator

@imjasonh imjasonh left a comment

Choose a reason for hiding this comment

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

There's kind of a lot of changes in this PR, but I think I'm following them all, and at this point it's probably easier just to power through than to split it up. In the future though, smaller single-purpose PRs would be great so we can iteratively make small improvements.

pkg/snapshot/layered_map.go Show resolved Hide resolved
@imjasonh imjasonh merged commit 323e616 into GoogleContainerTools:main May 18, 2022
@gabyx gabyx deleted the bugfix/correct-flatten-paths branch May 18, 2022 06:09
@gabyx
Copy link
Contributor Author

gabyx commented May 18, 2022

@imjasonh Totally agree. I still try to find the bug dockerfile to add as regression test

gabyx added a commit to gabyx/kaniko that referenced this pull request May 18, 2022
- Test `Dockerfile_test_issue_2066` fails on main@28432d3c
imjasonh pushed a commit that referenced this pull request May 18, 2022
* fix: Regression test for #2066

- Test `Dockerfile_test_issue_2066` fails on main@28432d3c

* np: Comment
gabyx added a commit to gabyx/kaniko that referenced this pull request May 31, 2022
- This missing files problem should be fixed by PR GoogleContainerTools#2066.
@gabyx gabyx mentioned this pull request May 31, 2022
4 tasks
imjasonh pushed a commit that referenced this pull request Jun 1, 2022
- This missing files problem should be fixed by PR #2066.
@imjasonh imjasonh mentioned this pull request Jun 1, 2022
chuangw6 added a commit that referenced this pull request Jun 1, 2022
Highlights
- Installed binaries are missing from image [#2049](#2049)
- proc: detect kubernetes runtime by mounts [#2054](#2054)
- Fixes #2046: make target stage lookup case insensitive [#2047](#2047)
- fix: Refactor LayersMap to correct old strange code behavior [#2066](#2066)
- Fix missing setuid flags on COPY --from=build operation [#2089](#2089)
- Fixes #2046: make target stage lookup case insensitive [#2047](#2047)
- Add GitLab CI credentials helper [#2040]((#2040))
- and a number of dependency bumps
chuangw6 added a commit that referenced this pull request Jun 1, 2022
Highlights
- Installed binaries are missing from image #2049
- proc: detect kubernetes runtime by mounts #2054
- Fixes #2046: make target stage lookup case insensitive #2047
- Fix: Refactor LayersMap to correct old strange code behavior #2066
- Fix missing setuid flags on COPY --from=build operation #2089
- Fixes #2046: make target stage lookup case insensitive #2047
- Add GitLab CI credentials helper #2040
- And a number of dependency bumps
@chuangw6 chuangw6 mentioned this pull request Jun 1, 2022
4 tasks
chuangw6 added a commit that referenced this pull request Aug 9, 2022
Highlights
- Installed binaries are missing from image #2049
- proc: detect kubernetes runtime by mounts #2054
- Fixes #2046: make target stage lookup case insensitive #2047
- Fix: Refactor LayersMap to correct old strange code behavior #2066
- Fix missing setuid flags on COPY --from=build operation #2089
- Fixes #2046: make target stage lookup case insensitive #2047
- Add GitLab CI credentials helper #2040
- And a number of dependency bumps
chuangw6 added a commit that referenced this pull request Aug 10, 2022
Highlights
- Installed binaries are missing from image #2049
- proc: detect kubernetes runtime by mounts #2054
- Fixes #2046: make target stage lookup case insensitive #2047
- Fix: Refactor LayersMap to correct old strange code behavior #2066
- Fix missing setuid flags on COPY --from=build operation #2089
- Fixes #2046: make target stage lookup case insensitive #2047
- Add GitLab CI credentials helper #2040
- And a number of dependency bumps
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