简体   繁体   English

Git在使用Jenkins从共享文件夹中的存储库中提取时挂起

[英]Git hangs while pulling from repository on shared folder using Jenkins

I am using Jenkins slave in my jobs, the slaves are amazon spot instances so I am using shared folder (EFS) in order to mount shared folders such .m2/.npm and the workspace. 我在我的工作中使用Jenkins slave,奴隶是amazon spot实例,因此我使用共享文件夹(EFS)来安装共享文件夹,如.m2 / .npm和工作区。

when the job starts and tries to pull from remote git repository the build hangs while cloning. 当作业开始并尝试从远程git存储库中提取时,构建会在克隆时挂起。

When I am not using the efs and clone on the spot instance itself everything works as expected, creating other files manually or through Jenkins on the efs also works fine. 当我没有在现场实例上使用efs并克隆时,一切都按预期工作,手动创建其他文件或通过efs上的Jenkins也可以正常工作。 permissions for the shared folder is the same as the user Jenkins uses. 共享文件夹的权限与Jenkins使用的用户相同。

Any suggestion what can cause this behavior? 有什么可能导致这种行为的建议吗?

This is the build log: 这是构建日志:

11:41:20 Fetching upstream changes from git@git.assembla.com:alpha.saas.git
11:41:20  > git --version # timeout=10
11:41:20 using GIT_SSH to set credentials jenkins@Dev_Builder(ssh)
11:41:20  > git fetch --no-tags --progress git@git.assembla.com:alpha.saas.git +refs/heads/*:refs/remotes/origin/* # timeout=5
11:41:29  > git rev-parse refs/remotes/origin/master^{commit} # timeout=10
11:41:29  > git rev-parse refs/remotes/origin/origin/master^{commit} # timeout=10
11:41:29 Checking out Revision e0dd60499d693a40fa0d3669201437b49cc2b0c4 (refs/remotes/origin/master)
11:41:29  > git config core.sparsecheckout # timeout=10
11:41:29  > git checkout -f e0dd60499d693a40fa0d3669201437b49cc2b0c4
11:48:59 Build was aborted

So it seems that the problem is with large Packfile size in git, looks like the EFS is pretty slow handling such large files what made it hang for so long. 所以似乎问题是git中的大包文件大小,看起来像EFS处理这么大的文件很慢,这使得它挂起这么久。 I've noticed it by using the lsof command: 我已经通过使用lsof命令注意到了它:

lsof +D ./

Which point it out the index file and the packfile are open for a long time and they both large files: 哪个指出它的索引文件和packfile很长时间都是打开的,它们都是大文件:

./.git/objects/pack/pack-601f9b58380bc69d49bcc429d046c8940c5ed9d2.idx ./.git/objects/pack/pack-601f9b58380bc69d49bcc429d046c8940c5ed9d2.idx

./.git/objects/pack/pack-601f9b58380bc69d49bcc429d046c8940c5ed9d2.pack ./.git/objects/pack/pack-601f9b58380bc69d49bcc429d046c8940c5ed9d2.pack

What I did in order to resolve it was using a shallow clone in Jenkins: 我为解决它而做的是在Jenkins中使用浅层克隆:

checkout([
        $class: 'GitSCM',
        branches: [[name: "$git_branch" ]],
        doGenerateSubmoduleConfigurations: false,
        extensions: [[$class: 'CloneOption', depth: 0, noTags: true, reference: '', shallow: true]],
        submoduleCfg: [],
        userRemoteConfigs: [[url: "$git_repo" , credentialsId: env.gitCredentialsJenkins]]])

That solved the issue though it still takes to long to clone a 1.8GB repository. 这解决了这个问题,虽然克隆一个1.8GB的存储库仍需要很长时间。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM