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

Create intermediate directories in COPY with correct uid and gid #2795

Merged
merged 4 commits into from
Nov 28, 2023

Conversation

rhaps0dy
Copy link
Contributor

@rhaps0dy rhaps0dy commented Oct 13, 2023

Fixes #1524

Description

#1524 reports that running COPY --chown=... does not create intermediate directories with correct UID and GID. I fixed that.

I'm not sure whether it fixes #2415 as well. Likely so because Add uses Copy under the hood, but I'm not sure how to add tests for that.

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.
    • I don't think any additional integration tests are needed, but I'm unsure

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.

@JeromeJu
Copy link
Collaborator

JeromeJu commented Nov 8, 2023

Thanks for the PR @rhaps0dy . For the release note, would you mind deleting the block since it is not applicable here?

@@ -66,6 +66,11 @@ var copyTests = []struct {
sourcesAndDest: []string{"f[o][osp]", "tempCopyExecuteTest"},
expectedDest: []string{"tempCopyExecuteTest"},
},
{
name: "Copy into several to-be-created directories",
sourcesAndDest: []string{"f[o][osp]", "tempCopyExecuteTest/foo/bar"},
Copy link
Collaborator

Choose a reason for hiding this comment

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

I understand that you included in the PR message about adding the test but it looks like this is not adding coverage for the CreateFile case with UID/GID :/

Copy link
Collaborator

Choose a reason for hiding this comment

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

What might be valuable here is to add an integration test at https://github.com/GoogleContainerTools/kaniko/tree/main/integration/dockerfiles, with COPY --chown= ... and it would be very helpful so that we could verify the fix when comparing in the future release.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Yeah, you're right, it doesn't set UID/GID. I didn't know how to add that test :( I think I added this one to quickly be able to figure out how to create intermediate directories in the first place.

I'll add an integration test.

@rhaps0dy
Copy link
Contributor Author

rhaps0dy commented Nov 11, 2023

you mind deleting the block since it is not applicable here?

I don't understand what you mean. What block are you talking about?

Ah you meant the release notes. Done.

@rhaps0dy
Copy link
Contributor Author

Done @JeromeJu . I tested it using:

for IMAGE in ghcr.io/rhaps0dy/kaniko/executor:latest gcr.io/kaniko-project/executor:latest; do
    docker run -it -v $(pwd):/workspace $IMAGE --context=dir:///workspace/integration/ --dockerfile=dockerfiles/Dockerfile_test_copy_chown_intermediate_dirs --no-push
done

the first should succeed and the latter should fail.

@rhaps0dy
Copy link
Contributor Author

Could you please authorize the workflow so we can be sure the tests pass in CI?

@JeromeJu
Copy link
Collaborator

Could you please authorize the workflow so we can be sure the tests pass in CI?

Hi @rhaps0dy thanks for the update! It seems that all the CI tests have passed. Are there any other test you are referring to or intended to add? Otherwise this PR seems good to go.

@rhaps0dy
Copy link
Contributor Author

Awesome thank you! I'm happy with the PR, I think it's ready for merging too :)

Copy link
Collaborator

@JeromeJu JeromeJu left a comment

Choose a reason for hiding this comment

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

Thanks @rhaps0dy !

@JeromeJu JeromeJu merged commit 143e694 into GoogleContainerTools:main Nov 28, 2023
10 checks passed
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