-
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 flake TestRun/Dockerfile_test_copy_symlink #1030
Conversation
@@ -616,7 +616,7 @@ func CopySymlink(src, dest, buildcontext string) (bool, error) { | |||
if err := createParentDirectory(dest); err != nil { | |||
return false, err | |||
} | |||
return false, os.Symlink(link, dest) | |||
return CopyFile(link, dest, buildcontext, uid, 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.
Why the change from link to copy? I'm struggling to connect this change to a flaky test.
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 test was flaky because of 2 reasons
- The
link
value was/tmp/target
.
We were linkingkaniko/0/tmp/link
to/tmp/target
- should have been/kaniko/0/tmp/link
- The target file
/tmp/target
was getting wiped out before call toos.Symlink(link, dest)
. - this caused flakiness.
(I still don't know why this is caused. However, imitating docker by actually creating the destlink as a regular file with contents of target file fixed the flakiness)
In the description, i mentioned i fixed the CopySymlink
to replicate docker behavior. Docker copies the target file to destination link and hence i replaced os.Symlink
to CopyFile
.
if err != nil { | ||
return err | ||
} | ||
return os.Symlink(link, destFile) | ||
linkPath := filepath.Join(destDir, link) |
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.
Could you explain this code a bit? I'm having trouble wraping my head around it.
It looks like linkPath
is the resolved path of src
joined with destDir
. I'm confused how we can be sure this path exists.
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 was error 1 mentioned in here
This ensures, we are copying/creating the required file in kaniko sratch workspace.
Fixes #1019
In this PR
Replicate
docker build
behavior by copying the target file to destination link.Create file with same uid and gid as target.
Added different scenarios for
ln
in integration test.Manually verified by building use kaniko and docker.
Verified by running the test 10 times