Add secondary lag message on Git push to secondary over SSH

Problem to solve

Output a replication lag message on Git push over SSH to a Geo secondary node.

Intended users

Users who use Git over SSH against a Geo secondary node.

Further details

A user sees a message about replication lag in their console when they:

  • Git pull from a secondary over SSH https://gitlab.com/gitlab-org/gitlab-ee/merge_requests/10471
  • Git push to a secondary over HTTP https://gitlab.com/gitlab-org/gitlab-ee/issues/9195

We are unable to show the message on Git pull over HTTP because &733 (comment 131836153):

As Mike has discovered, using git over HTTP does not currently possess any method for displaying informational messages for successful responses. Again, as Mike points out, it is possible to display informational messages when a response is a non-success: https://github.com/git/git/blob/master/remote-curl.c#L389-L398.

I also looked at client side hooks but am pretty sure we can't do much there either 😞 There's no client side hook for fetch, but there are for pre-rebase and post-merge so we could make an API call or such in there to retrieve current replication lag. It's not ideal though.

But, it looks like we don't show the message on Git push over SSH https://gitlab.com/gitlab-org/gitlab-ee/issues/9195#note_202940090:

@ashmckenzie I hacked my test instance so that ::Gitlab::Geo::HealthCheck.new.db_replication_lag_seconds returns 35 so I could see what the lag notice looks like for Git over SSH.

I see that git pull looks like this:

$ git pull
> GitLab: Current replication lag: 35 seconds
Already up to date.
$ 

But I don't see a lag message on git push. Is there one?

$ echo "Hello" >> README.md && gcam "Edit a file `date`" && git push
[master d9ef440] Edit a file Mon Aug 12 16:04:29 PDT 2019
 1 file changed, 1 insertion(+)
> GitLab: You're pushing to a Geo secondary.
> GitLab: We'll help you by proxying this request to the primary: git@mkozono-20190730h-primary-geo.gogitlab.ml:some-group/some-project.git
Enumerating objects: 5, done.
Counting objects: 100% (5/5), done.
Writing objects: 100% (3/3), 950 bytes | 950.00 KiB/s, done.
Total 3 (delta 0), reused 0 (delta 0)
To mkozono-20190730h-secondary-geo.gogitlab.ml:some-group/some-project.git
   0706649..d9ef440  master -> master

Proposal

Follow on https://gitlab.com/gitlab-org/gitlab-ee/merge_requests/10471

Permissions and Security

Documentation

Testing

What does success look like, and how can we measure that?

A user sees a message about replication lag in their console when they Git push over SSH to a Geo secondary node.

Something like:

$ git push origin my_branch
[master 9f50ae3] Update README.md
 1 file changed, 1 insertion(+)
Enumerating objects: 5, done.
Counting objects: 100% (5/5), done.
Delta compression using up to 8 threads
Compressing objects: 100% (3/3), done.
Writing objects: 100% (3/3), 974 bytes | 974.00 KiB/s, done.
Total 3 (delta 2), reused 0 (delta 0)
remote: 
remote: ========================================================================
remote: 
remote:                    Current replication lag: 7 seconds
remote: 
remote: ========================================================================
remote: 
To ssh://localhost:2223/twitter/typeahead-js.git
   911ab92..9f50ae3  master -> master

What is the type of buyer?

  • Premium
  • Ultimate

Links / references

Edited Sep 11, 2019 by Ash McKenzie
Assignee Loading
Time tracking Loading