-
Notifications
You must be signed in to change notification settings - Fork 5.5k
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
Add support for Git LFS enabled repositories (fixes #1853) #1941
Conversation
@@ -361,9 +395,8 @@ func (m *nativeGitClient) runCredentialedCmd(command string, args ...string) (st | |||
func (m *nativeGitClient) runCmdOutput(cmd *exec.Cmd) (string, error) { | |||
cmd.Dir = m.root | |||
cmd.Env = append(cmd.Env, os.Environ()...) | |||
cmd.Env = append(cmd.Env, "HOME=/dev/null") | |||
cmd.Env = append(cmd.Env, "GIT_CONFIG_NOSYSTEM=true") | |||
cmd.Env = append(cmd.Env, "GIT_CONFIG_NOGLOBAL=true") |
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.
I have removed these environment variables, since I was assuming these were set to not fiddle with Git configuration when the argocd
CLI still tested repository access from the client it was executed. This behaviour was removed with PR #1807, and the git
is not called on the client anymore.
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.
I think this is right assumption and we don't need these variables anymore. @jessesuen can you confirm please?
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.
LGTM. @jessesuen can you take a look too? Looking for confirmation about GIT_CONFIG_NOSYSTEM, GIT_CONFIG_NOGLOBAL env variables
I just added tests for the PR that references a LFS enabled mock repository in my GitHub account from https://github.com/jannfis/argocd-testrepo-lfs - if you want, you can clone that repository to argocd GitHub account and I will change the reference in the code. |
Forked test repo to https://github.com/argoproj-labs/argocd-testrepo-lfs |
Hm, I can't seem to get the LFS plugin for Git into the image run during CircleCI workflow. I updated base image in Dockerfile, but that does not seem to work. Does it work differently for CircleCI? Do I have to perform additional steps? |
Ah, right. I need to update builder image and push it. Doing it right now. Can you please change image to |
@@ -41,14 +41,15 @@ type Client interface { | |||
Checkout(revision string) error | |||
LsRemote(revision string) (string, error) | |||
LsFiles(path string) ([]string, error) | |||
LsLargeFiles() ([]string, error) |
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.
There is one more struct which supposed to implement git client interface: https://github.com/argoproj/argo-cd/blob/master/reposerver/metrics/gitwrapper.go#L1-L1
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.
Yes, one little change, so much butterfly effect. Should have compiled all components before pushing that commit :|
I missed some additional changes in Git Client interface which I introduced for the tests with commit |
@@ -139,6 +140,37 @@ func TestLsRemote(t *testing.T) { | |||
} | |||
} | |||
|
|||
// Running this test requires git-lfs to be installed on your machine. | |||
func TestLFSClient(t *testing.T) { | |||
tempDir, err := ioutil.TempDir("", "git-client-lfs-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.
Looks like we will need to install git-lfs in circle ci config:
https://discuss.circleci.com/t/is-git-lfs-supported-by-circleci-2-0/11283/7
name: Install Git LFS
command: |
curl -s https://packagecloud.io/install/repositories/github/git-lfs/script.deb.sh | bash
apt-get update
apt-get install -y git-lfs openssh-client
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.
Thanks a lot @alexmt - I got CircleCI to install & use the Git LFS plugin now. Unfortunately, this led to another error, which I believe is CircleCI specific. The LFS test fails with:
Error Trace: git_test.go:162
Error: Received unexpected error:
`git lfs fetch --all` failed exit status 2: batch request: Invalid deploy key for argoproj-labs/argocd-testrepo-lfs: exit status 1
error: failed to fetch some objects from 'https://github.com/argoproj-labs/argocd-testrepo-lfs.git/info/lfs'
Test: TestLFSClient
I changed test repositories, but to no avail A quick search on Google revealed not much to this specific error, and all I found seems to be CircleCI related. The LFS works from multiple machines I tested on, just not in the CircleCI build. I will look through their support base for possible solutions, or write to their support.
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.
We are going to dockerize tests since it's been pretty painful to configure Circle CI same as real production environment. I would suggest moving your test to test/e2e
directory and skip it during CI run using test.LocalOnly(t)
(example)
After dockerizing the tests we will enable this test in CI
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.
I have found the reason and could fix it. CircleCI injects a SSH key to the user's $HOME/.ssh, which is reason for LFS failing (doesn't like deploy keys). Actually, I guess that was one of the reasons why HOME was set to /dev/null in Git client implementation -- and I removed that with one of the previous commits. It's back in place now, LFS now also works in the CI environment.
I had to switch back to v1.0.0 because the v1.0.1 seems broken - it apperently has no goreman included. Output from
|
…3-add-git-lfs-support
Following E2E test is failing: From my point of view, this PR is ready for merge at your discretion. Thanks a lot for your help and shared experience, @alexmt ! |
This PR enables LFS (Large File Support) for repositories and fixes #1853
For this, a new switch
--enable-lfs
is introduced torepo add
command. LFS must be enabled on a per repository basis, and it should be used carefully (because LFS can reference really large files).For declarative setup, the property name is
enableLfs
and of typebool
.As a bonus, while I was at the code, I fixed upsert mechanism for the
insecure-ignore-host-key
andinsecure-skip-server-validation
setting of repositories as well.