terraform-backend-git
terraform-backend-git copied to clipboard
Cannot connect to Azure DevOps git repo
my git repo is on Azure DevOps. I tried both ssh and http, and both cli config and terraform backend config, always with the same result:
[terraform-backend-git]: empty git-upload-pack given
[terraform-backend-git]: empty git-upload-pack given
[terraform-backend-git]: empty git-upload-pack given
Error: Error loading state:
Failed to get state: GET http://localhost:6061/?type=git&[email protected]:v3/REDACTED/infra-analytics/tooling-tf&ref=state&state=tfstate.json giving up after 3 attempts
Just to make sure, I already created the branch, and the tfstate.json file, but got the same result.
Here's my config:
terraform {
backend "http" {
address = "http://localhost:6061/?type=git&[email protected]:v3/REDACTED/infra-analytics/tooling-tf&ref=state&state=tfstate.json"
lock_address = "http://localhost:6061/?type=git&[email protected]:v3/REDACTED/infra-analytics/tooling-tf&ref=state&state=tfstate.json"
unlock_address = "http://localhost:6061/?type=git&[email protected]:v3/REDACTED/infra-analytics/tooling-tf&ref=state&state=tfstate.json"
}
}
I also have the TF_BACKEND_HTTP_ENCRYPTION_PASSPHRASE
env var set.
When enabling the access logs, I get
[terraform-backend-git]: ssh: handshake failed: EOF
127.0.0.1 - - [19/Oct/2020:11:24:48 +0200] "GET /?type=git&[email protected]:v3/REDACTED/infra-analytics/tooling-tf&ref=state&state=tfstate.json HTTP/1.1" 500 27
[terraform-backend-git]: empty git-upload-pack given
127.0.0.1 - - [19/Oct/2020:11:25:10 +0200] "GET /?type=git&[email protected]:v3/REDACTED/infra-analytics/tooling-tf&ref=state&state=tfstate.json HTTP/1.1" 500 27
[terraform-backend-git]: empty git-upload-pack given
127.0.0.1 - - [19/Oct/2020:11:25:13 +0200] "GET /?type=git&[email protected]:v3/REDACTED/infra-analytics/tooling-tf&ref=state&state=tfstate.json HTTP/1.1" 500 27
Thanks for your interest in this project @mikemowgli.
Briefly looking into this issue, it looks like the error comes from go-git
. After a little bit of research it looks like this is due to the fact go-git
does not support multi-ack (so as many other git client implementations). Azure DevOps (as well as VSTS) in turn does not support older non-multi-ack protocols. All the major competitors like GitHub/GitLab/Bitbucket does support it.
There's a number of issues being reported both in go-git
as well as it's consumers, just to list the few:
- https://github.com/src-d/go-git/issues/335
- https://github.com/src-d/go-git/issues/1058
- https://github.com/go-git/go-git/issues/64
- https://github.com/pivotal/kpack/issues/213
- https://github.com/fluxcd/source-controller/issues/104
- https://github.com/fluxcd/flux/issues/1224
It goes on and on to as early as 2017. Together with the fact that Azure DevOps/VSTS seems to be the only one who requires multi-ack, I wouldn't hope for a prompt resolution in go-git
. It seems like even Go itself struggle with that: https://github.com/golang/go/issues/28236
That said, Microsoft seems to be firmly refusing to relax protocol requirements: https://github.com/fluxcd/source-controller/issues/104#issuecomment-703681147
Theoretically it should be possible to swap out go-git
by delegating to git
command, but that would significantly increase complexity, introduce external dependencies as well as cause potential portability issues - so I am not sure I want to go down that route. This backend design allows for external storage implementations though, so maybe someone else will want to go for it. I'm gonna leave this issue open to not to forget to update go-git
once they solve this issue. Other than that there's not much I can help with at this time. Sorry.
Fun fact: looking into the GitHub repo stats you seems to be the first one who's trying to use this backend. And you happen to use Azure DevOps which this backend turns out to have compatibility issues with. What a shame.