"5:couldn't query the remote HEAD" when mirroring to CodeCommit
Summary
When mirroring to CodeCommit, GitLab occasionally creates a state in the remote repo that prevents further syncs.
Steps to reproduce
(I have not tested it this way, but it should end up with the same error.)
- Create Repo
- Commit a file
- Create a branch from the master branch (it has to be equal)
- Mirror the Repo to CodeCommit (push-mirror from GitLab & via HTTPS)
- Trigger another push to CodeCommit
Example Project
¯\_(ツ)_/¯
What is the current bug behavior?
GitLab reports a "5:couldn't query the remote HEAD" every time it tries to push to the CodeCommit remote repo after the initial push.
What is the expected correct behavior?
GitLab pushes new changes to the CodeCommit remote.
Relevant logs and/or screenshots
If I clone the repo from GitLab, it looks like this
$ git remote show origin
* remote origin
Fetch URL: git@gitlab.foo.bar:foogroup/bar/foo
Push URL: git@gitlab.foo.bar:foogroup/bar/foo
HEAD branch: master
Remote branches:
master tracked
foo tracked
Local branch configured for 'git pull':
master merges with remote master
Local ref configured for 'git push':
master pushes to master (up to date)
but when cloning the repo from CodeCommmit, git-remote shows the following
$ git remote show origin
* remote origin
Fetch URL: https://git-codecommit.eu-central-1.amazonaws.com/v1/repos/foo
Push URL: https://git-codecommit.eu-central-1.amazonaws.com/v1/repos/foo
HEAD branch (remote HEAD is ambiguous, may be one of the following):
master
foo
Remote branches:
master tracked
foo tracked
Local branch configured for 'git pull':
master merges with remote master
Local ref configured for 'git push':
master pushes to master (up to date)
The HEAD branch (remote HEAD is ambiguous, may be one of the following): is the part that causes the error. (see
https://gitlab.com/gitlab-org/gitaly/blob/master/internal/service/remote/find_remote_root_ref.go)
Output of checks
¯\_(ツ)_/¯
Results of GitLab environment info
I don't have access to this. I'm just a user. Only thing I know: it's 11.3.0-ee
Results of GitLab application Check
Same here. ¯\_(ツ)_/¯
Possible fixes
In https://gitlab.com/gitlab-org/gitaly/blob/master/internal/service/remote/find_remote_root_ref.go
Change
const headPrefix = "HEAD branch: "
to
const headPrefix = "HEAD branch"
or something like this.
