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

Don't write whiteout files to directories that were replaced with files or links #2590

Merged

Conversation

andreasf
Copy link
Contributor

Fixes #2308

Description

If a non-empty directory gets replaced with something other than a directory (e.g. file or symlink), the files in that directory also get deleted. However, there should not be any whiteout files for them in the layer. If there were, the resulting tar file would not be extractable.

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.

Copy link
Contributor

@gabyx gabyx left a comment

Choose a reason for hiding this comment

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

Looks good to me.
Some questions, and small typos I guess.

pkg/snapshot/snapshot.go Outdated Show resolved Hide resolved
if err != nil {
return err
}
if skipWhiteout {
Copy link
Contributor

Choose a reason for hiding this comment

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

nice!


for _, file := range kanikoFiles {
if strings.HasPrefix(file, "a/.wh.") {
t.Errorf("Last layer should not add whiteout files to deleted directory but found %s", file)
Copy link
Contributor

Choose a reason for hiding this comment

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

Nice

pkg/snapshot/snapshot_test.go Show resolved Hide resolved
@aaron-prindle aaron-prindle modified the milestone: v1.12.0 Jun 20, 2023
@aaron-prindle
Copy link
Collaborator

aaron-prindle commented Jun 20, 2023

Agree w/ @gabyx, LGTM just address the single nit - s/err/nil and we should be able to merge! 🎊

@@ -896,10 +955,10 @@ func initIntegrationTestConfig() *integrationTestConfig {
var gcsEndpoint string
var disableGcsAuth bool
flag.StringVar(&c.gcsBucket, "bucket", "gs://kaniko-test-bucket", "The gcs bucket argument to uploaded the tar-ed contents of the `integration` dir to.")
flag.StringVar(&c.imageRepo, "repo", "gcr.io/kaniko-test", "The (docker) image repo to build and push images to during the test. `gcloud` must be authenticated with this repo or serviceAccount must be set.")
flag.StringVar(&c.imageRepo, "repo", "localhost:5000", "The (docker) image repo to build and push images to during the test. `gcloud` must be authenticated with this repo or serviceAccount must be set.")
Copy link
Collaborator

Choose a reason for hiding this comment

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

I missed this initially but can you also change this back to its original value

flag.StringVar(&c.serviceAccount, "serviceAccount", "", "The path to the service account push images to GCR and upload/download files to GCS.")
flag.StringVar(&gcsEndpoint, "gcs-endpoint", "", "Custom endpoint for GCS. Used for local integration tests")
flag.BoolVar(&disableGcsAuth, "disable-gcs-auth", false, "Disable GCS Authentication. Used for local integration tests")
flag.BoolVar(&disableGcsAuth, "disable-gcs-auth", true, "Disable GCS Authentication. Used for local integration tests")
Copy link
Collaborator

Choose a reason for hiding this comment

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

I missed this initially but can you also change this back to its original value

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Oops. Fixed

…es or links

If a non-empty directory gets replaced with something other than a
directory (e.g. file or symlink), the files in that directory also get
deleted. However, there should not be any whiteout files for them in the
layer. If there were, the resulting tar file would not be extractable.

Fixes GoogleContainerTools#2308
Copy link
Collaborator

@aaron-prindle aaron-prindle 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 PR here @andreasf! LGTM

@aaron-prindle aaron-prindle merged commit 0d925dd into GoogleContainerTools:main Jun 22, 2023
kylecarbs pushed a commit to coder/kaniko that referenced this pull request Jul 12, 2023
…es or links (GoogleContainerTools#2590)

If a non-empty directory gets replaced with something other than a
directory (e.g. file or symlink), the files in that directory also get
deleted. However, there should not be any whiteout files for them in the
layer. If there were, the resulting tar file would not be extractable.

Fixes GoogleContainerTools#2308
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
3 participants