Commit cd58101f authored by Tomasz Maczukin's avatar Tomasz Maczukin

Disable smudging when cloning git-lfs repositories

This resolves the problem when git, during checking out the repository,
is filling all available memory if the LFS object is bigger.

After the repository is cloned and checked out (or fetched and checked
out), explicit `git lfs pull` is called to download and checkout the
content of the LFS object.

For more details please read:

- gitlab-org/gitlab-runner#3366
- https://github.com/git-lfs/git-lfs/issues/3524
parent 4011f186
......@@ -3,7 +3,7 @@ FROM multiarch/alpine:armhf-v3.9
RUN apk add --no-cache bash ca-certificates git git-lfs miniperl \
&& ln -s miniperl /usr/bin/perl
RUN git lfs install
RUN git lfs install --skip-repo
COPY ./scripts/ /usr/bin
COPY ./binaries/gitlab-runner-helper.arm /usr/bin/gitlab-runner-helper
......
......@@ -3,7 +3,7 @@ FROM alpine:3.9
RUN apk add --no-cache bash ca-certificates git git-lfs miniperl \
&& ln -s miniperl /usr/bin/perl
RUN git lfs install
RUN git lfs install --skip-repo
COPY ./scripts/ /usr/bin
COPY ./binaries/gitlab-runner-helper.x86_64 /usr/bin/gitlab-runner-helper
......
......@@ -360,6 +360,12 @@ func (b *AbstractShell) writeCloneFetchCmds(w ShellWriter, info common.ShellScri
w.Warning("DEPRECATION: this GitLab server doesn't support refspecs, gitlab-runner 12.0 will no longer work with this version of GitLab")
}
// We're disabling smudging to prevent us from memory allocation failures.
//
// Please read https://gitlab.com/gitlab-org/gitlab-runner/issues/3366 and
// https://github.com/git-lfs/git-lfs/issues/3524 for context.
w.Variable(common.JobVariable{Key: "GIT_LFS_SKIP_SMUDGE", Value: "1"})
switch info.Build.GetGitStrategy() {
case common.GitFetch:
if hasRefspecs {
......@@ -383,6 +389,16 @@ func (b *AbstractShell) writeCloneFetchCmds(w ShellWriter, info common.ShellScri
if info.Build.GetGitCheckout() {
b.writeCheckoutCmd(w, build)
// Because we've disabled LFS smudging above, we need now manually call `git lfs pull`
// to fetch and checkout all LFS objects that may be present in the repository.
//
// Repositories without LFS objects (and without any LFS metadata) will be not
// affected by this command.
w.IfCmd("git-lfs", "version")
w.Command("git", "lfs", "pull")
w.EmptyLine()
w.EndIf()
} else {
w.Notice("Skipping Git checkout")
}
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment