Skip to content

Support gitserver/repo address pinning

Administrator requested to merge mv/gitserver/pinning into main

Created by: vrto

Issue

gitserver: Add support for repository pinning

Description

This adds a new site config option to configure pinned repositories. An admin can manually specify which git repositories will be pinned to gitserver instances.

Example config:

  "experimentalFeatures": {
    "gitServerPinnedRepos": {
      "github.com/hashicorp/go-multierror": "127.0.0.1:3502",
    }

Please note that for now, this feature is experimental. The pinning works, but we'll need to follow up for janitor code that will smoothly migrate the cloned repo to another gitserver instance (so we avoid an additional re-clone). This is currently in progress. After a conversation with @asdine, we agreed that it's easier to reuse this code once ready (instead of developing the same thing twice).

📺 Demo

https://user-images.githubusercontent.com/3193149/159436694-c383c147-e94e-42e1-8a81-04f5572561a5.mp4

Implementation highlights

  • introduces a new GitServerAddresses struct to group the hostnames with pinned repos (so they're always accessed and processed together)
  • AddrForRepo avoids calling the hashing function (for computing gitserver address) when the repo in question is pinned
  • any time pinned repos are observed, the ClientImplementor fetches a fresh copy from conf (so we don't have to watch for changes and sync state)
  • watchForPinned hook available and will use the repo migration logic once ready (see the Description section above)

Test plan

  • the feature is unit tested in this PR
  • feature manually QA'd (see the linked Demo video)
  • the repo-updater hook is getting invoked, see the following:
Screenshot 2022-03-22 at 8 53 59

Related to #32319 (closed)

Merge request reports

Loading