Skip to content

Geo: Add `done` pktline when git clone --depth option is given

Javiera Tapia requested to merge jtapiab-add-done-pkt-git-clone-depth-option into main

Resolves gitlab#391980

A detailed explanation can be found at: gitlab#391980 (comment 1670644254)

This MR fixes the hanging behavior when performing a git clone --depth=1 SSH request redirected to a Geo primary site when a secondary site is not up-to-date.

The current request of this Git operation looks like this:

12:05:05.464057 pkt-line.c:85           packet:        clone< 07ee4b20060afd273ed354cc74537a035befb482 HEAD\0multi_ack thin-pack side-band side-band-64k ofs-delta shallow deepen-since deepen-not deepen-relative no-progress include-tag multi_ack_detailed allow-tip-sha1-in-want allow-reachable-sha1-in-want no-done symref=HEAD:refs/heads/main filter object-format=sha1 agent=git/2.42.0
12:05:05.464328 pkt-line.c:85           packet:        clone< 07ee4b20060afd273ed354cc74537a035befb482 refs/heads/main
12:05:05.464352 pkt-line.c:85           packet:        clone< 0000
12:05:05.470390 pkt-line.c:85           packet:        clone> want 07ee4b20060afd273ed354cc74537a035befb482 multi_ack_detailed side-band-64k thin-pack include-tag ofs-delta deepen-since deepen-not agent=git/2.42.0
12:05:05.470424 pkt-line.c:85           packet:        clone> want 07ee4b20060afd273ed354cc74537a035befb482
12:05:05.470429 pkt-line.c:85           packet:        clone> deepen 1
12:05:05.470435 pkt-line.c:85           packet:        clone> 0000

After the last packet sent by the client, the operation hangs whenever the request is proxied to a Geo primary site.

How to validate this locally?

  1. Configure GDK using Geo https://gitlab.com/gitlab-org/gitlab-development-kit/blob/main/doc/howto/geo.md
  2. When the Geo primary and secondary are up and running, enable Geo selective synchronization:
    1. Go to <GDK_PRIMARY_HOST>/admin/geo/sites and edit the secondary site.
    2. Select Projects in certain groups under selective synchronization and a Group to synchronize their projects: Screenshot_2023-11-28_at_20.00.43
  3. Create a project under a different group so the git clone operation will be forced to proxy the request to the primary site
  4. In your terminal, perform a git clone operation as follows: GIT_TRACE_PACKET=1 GIT_TRACE=2 GIT_CURL_VERBOSE=1 git clone --depth=1 ssh://<GDK_SECONDARY_HOST>:<SECONDARY_SSH_PORT>/<GROUP>/<REPOSITORY>.git
  5. The operation should succeed, and performing git log in the local repository should show only the last commit.

Merge request reports