-
Notifications
You must be signed in to change notification settings - Fork 1.4k
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 copying ownership #1725
Fix copying ownership #1725
Conversation
44802e6
to
dfae5b9
Compare
PR rebased to
source code of fork in |
return errors.Wrap(err, "reading ownership") | ||
} | ||
stat := info.Sys().(*syscall.Stat_t) | ||
err = os.Chown(destPath, int(stat.Uid), int(stat.Gid)) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This failed a lint check for ineffective error assignment that wasn't present when you proposed this PR. In #1858 I tried just having this return the error, but it leads to a unit test failure:
time="2021-12-23T19:27:59Z" level=info msg="Saving file copied/bam.txt for later use"
util.go:73: chown /tmp/592266814/kaniko/0/bam.txt: no such file or directory
copying ownership
github.com/GoogleContainerTools/kaniko/pkg/util.CopyFileOrSymlink
/home/runner/work/kaniko/kaniko/pkg/util/fs_util.go:910
github.com/GoogleContainerTools/kaniko/pkg/executor.DoBuild
/home/runner/work/kaniko/kaniko/pkg/executor/build.go:680
github.com/GoogleContainerTools/kaniko/pkg/executor.TestCopyCommand_Multistage.func1
/home/runner/work/kaniko/kaniko/pkg/executor/copy_multistage_test.go:47
testing.tRunner
/opt/hostedtoolcache/go/1.17.5/x64/src/testing/testing.go:1259
runtime.goexit
/opt/hostedtoolcache/go/1.17.5/x64/src/runtime/asm_amd64.s:1581
could not save file
github.com/GoogleContainerTools/kaniko/pkg/executor.DoBuild
/home/runner/work/kaniko/kaniko/pkg/executor/build.go:681
github.com/GoogleContainerTools/kaniko/pkg/executor.TestCopyCommand_Multistage.func1
/home/runner/work/kaniko/kaniko/pkg/executor/copy_multistage_test.go:47
testing.tRunner
/opt/hostedtoolcache/go/1.17.5/x64/src/testing/testing.go:1259
runtime.goexit
/opt/hostedtoolcache/go/1.17.5/x64/src/runtime/asm_amd64.s:1581
copy_multistage_test.go:52: open /tmp/592266814/output: no such file or directory
If you can figure out the fix that'd be great, otherwise I may have to revert this change to ensure we can keep the project moving forward. Sorry for the difficulty, we're trying to get the gears moving again.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thank you. I'll take a look
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I got the test to pass with the change in fe94bcc but I'd love to have your feedback on whether that's the right way forward.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Well, I have similar errors even without merging this PR (just in v1.7.0
for example)
INFO[0000] Using dockerignore file: ../../integration/.dockerignore
--- FAIL: Test_GetFSFromLayers_with_whiteouts_include_whiteout_enabled (0.00s)
fs_util_test.go:1124: initializing filesystem ignore list: checking filesystem mount paths for ignore list: open /proc/self/mountinfo: no such file or directory
--- FAIL: Test_GetFSFromLayers_with_whiteouts_include_whiteout_disabled (0.00s)
fs_util_test.go:1228: initializing filesystem ignore list: checking filesystem mount paths for ignore list: open /proc/self/mountinfo: no such file or directory
--- FAIL: Test_GetFSFromLayers_ignorelist (0.00s)
fs_util_test.go:1319: initializing filesystem ignore list: checking filesystem mount paths for ignore list: open /proc/self/mountinfo: no such file or directory
--- FAIL: Test_GetFSFromLayers (0.00s)
fs_util_test.go:1445: initializing filesystem ignore list: checking filesystem mount paths for ignore list: open /proc/self/mountinfo: no such file or directory
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Ah sorry, it seems problem was caused by architecture of my new M1 chip.
In x86_64 virtual machine all tests are passed with no problems 🤔
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think this problem is caused by the fact that kaniko directory is overrided just for this unit test:
kaniko/pkg/executor/copy_multistage_test.go
Lines 167 to 168 in 7065921
config.RootDir = testDir | |
config.KanikoDir = fmt.Sprintf("%s/%s", testDir, "kaniko") |
But this path is not actually ignored, thus util.CopyOwnership is trying to chown /tmp/592266814/kaniko/0/bam.txt but this file is actually located in staging directory.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
My guess was wring, the relative path was calculated wrong.
Here is PR which fixes this #1859
* fix uid, gid overriding * fix ownership for staging building * add integration test * add check for ignored files * improve errors
Fixes #1315
Description
This PR solved two problems:
First problem is that
uid, gid
overriding by loop inCopyDir
function:kaniko/pkg/util/fs_util.go
Line 692 in 3ab2e1d
Second problem is that
otiai10Cpy.Copy
is not preserving ownership information. Solved by implementing additional loop for copying ownership information.It might need rebase after merging #1724.
This branch includes both fixes:
kvaps:fix-copying-root-and-ownership
; compiled docker images:Submitter Checklist
These are the criteria that every PR should meet, please check them off as you
review them:
See the contribution guide for more details.
Reviewer Notes
Release Notes
Describe any changes here so maintainer can include it in the release notes, or delete this block.