Fix bug in extracting hardlinks
When we execute multistage builds, we store the fs of each intermediate stage at /kaniko/<stage number> if it's used later in the build. This created a bug when extracting hardlinks, because we weren't appending the new directory to the link path. So, if `/tmp/file1` and `/tmp/file2` were hardlinked, kaniko was trying to link `/kaniko/0/tmp/file1` to `/tmp/file2` instead of `/kaniko/0/tmp/file2`. This change will append the correct directory to the link, and fixes #437 #362 #352 #342.
This commit is contained in:
parent
0c294138b8
commit
9d67953ed3
|
|
@ -1,3 +1,13 @@
|
|||
FROM composer@sha256:5c4bd89217b50125f28e08d9f16414ecb75f90ce9b773605472b35cd55f3e5c0 AS composer
|
||||
FROM php@sha256:9fe20c8003a12f5907ffdc1d7ec435b4ca4226fa4342b94cec4d66189a439f17
|
||||
COPY --from=composer /usr/bin/composer /usr/bin/composer
|
||||
COPY ./ /app
|
||||
WORKDIR /app
|
||||
RUN ls -l
|
||||
|
||||
# make sure hardlink extracts correctly
|
||||
FROM jboss/base-jdk@sha256:138591422fdab93a5844c13f6cbcc685631b37a16503675e9f340d2503617a41
|
||||
|
||||
FROM gcr.io/kaniko-test/hardlink-base:latest
|
||||
RUN ls -al /usr/libexec/git-core/git /usr/bin/git /usr/libexec/git-core/git-diff
|
||||
RUN stat /usr/bin/git
|
||||
|
|
|
|||
|
|
@ -245,8 +245,8 @@ func extractFile(dest string, hdr *tar.Header, tr io.Reader) error {
|
|||
return errors.Wrapf(err, "error removing %s to make way for new link", hdr.Name)
|
||||
}
|
||||
}
|
||||
|
||||
if err := os.Link(filepath.Clean(filepath.Join("/", hdr.Linkname)), path); err != nil {
|
||||
link := filepath.Join(dest, hdr.Linkname)
|
||||
if err := os.Link(filepath.Clean(filepath.Join("/", link)), path); err != nil {
|
||||
return err
|
||||
}
|
||||
|
||||
|
|
|
|||
Loading…
Reference in New Issue