fix flake TestRun/Dockerfile_test_copy_symlink#1030
Conversation
| return false, err | ||
| } | ||
| return false, os.Symlink(link, dest) | ||
| return CopyFile(link, dest, buildcontext, uid, gid) |
There was a problem hiding this comment.
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.
This test was flaky because of 2 reasons
- The
linkvalue was/tmp/target.
We were linkingkaniko/0/tmp/linkto/tmp/target- should have been/kaniko/0/tmp/link - The target file
/tmp/targetwas 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.
| return err | ||
| } | ||
| return os.Symlink(link, destFile) | ||
| linkPath := filepath.Join(destDir, link) |
There was a problem hiding this comment.
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.
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 buildbehavior by copying the target file to destination link.Create file with same uid and gid as target.
Added different scenarios for
lnin integration test.Manually verified by building use kaniko and docker.
Verified by running the test 10 times