Skip to content

Geo: Forward project repo pulls to the primary when repo is out of date

Michael Kozono requested to merge mk/proxy-pulls-if-repo-out-of-date into master

What does this MR do and why?

Describe in detail what your merge request does and why.

A secondary site will now forward project repo pulls to the primary site if the latest repo change is not yet replicated. With limitations as shown below.

Part of #345267 (closed). Does not resolve it fully, yet.

Current limitations

We assume last_repository_updated_at is a timestamp of the latest change. So we compare the timestamp of the latest sync to last_repository_updated_at.

  • Unfortunately, project wiki updates also touch last_repository_updated_at. So wiki updates will also bump the repo to out-of-date.
  • Unfortunately, successive last_repository_updated_at touches are throttled within Event::REPOSITORY_UPDATED_AT_INTERVAL minutes. This is currently set to 5 minutes. So for example, secondary sites will think highly active repos are up-to-date after the first sync of each 5 minute interval.

This is a rough improvement over the current code.

Next, we can iteratively improve the accuracy of .repository_out_of_date? to fully address the problem. It may be rather involved, so this MR helps by reducing the scope of that future change.

Screenshots or screen recordings

These are strongly recommended to assist reviewers and reduce the time to merge your change.

How to set up and validate locally

Numbered steps to set up and validate the change are strongly suggested.

  1. Have Geo set up locally, with both sites running this MR's branch, with Unified URL
  2. Have a project with a repo, and make sure the secondary site has synced it
  3. git clone a project repo from the Unified URL
  4. Notice that git clone (or a subsequent git pull) does not output warning: redirecting to a path with push_from_secondary in it (yes, the path segment name should be different)
  5. In Terminal, in the directory of the secondary site, run gdk stop rails-background-jobs to block repo replication
  6. In the GitLab UI, edit a file in the repo and commit it
  7. git pull
  8. Notice that git pull outputs warning: redirecting to because the secondary's repo is out of date and the new code is exercised
  9. In Terminal, in the directory of the secondary site, run gdk start rails-background-jobs to let repo replication happen
  10. git pull
  11. Notice that git pull does not output warning: redirecting to

MR acceptance checklist

This checklist encourages us to confirm any changes have been analyzed to reduce risks in quality, performance, reliability, security, and maintainability.

Edited by Michael Kozono

Merge request reports