WIP: Geo: Move push to secondary (SSH) logic from Rails into workhorse - push
requested to merge ashmckenzie/geo-push-to-secondary-into-workhorse-pt2 into ashmckenzie/geo-push-to-secondary-into-workhorse
This MR moves the push logic from Rails (https://gitlab.com/gitlab-org/gitlab-ee/blob/master/ee/lib/api/geo.rb#L70-88) into workhorse. In the broad strokes, here's how push to secondary (SSH) works:
-
git push
to secondary from command line -
check_custom_action(cmd)
(https://gitlab.com/gitlab-org/gitlab-ee/blob/master/lib/gitlab/git_access.rb#L68) is examined - For a valid Geo setup, https://gitlab.com/gitlab-org/gitlab-ee/blob/master/ee/lib/ee/gitlab/geo_git_access.rb#L34-47 is executed which returns a JSON payload to gitlab-shell with some endpoints to POST to in sequence -
["/api/v4/geo/proxy_git_push_ssh/info_refs", "/api/v4/geo/proxy_git_push_ssh/push"]
- Each endpoint is POST'd at the secondary node, with any output being send to the following endpoint (e.g. output from
/api/v4/geo/proxy_git_push_ssh/info_refs
is sent POST'd to/api/v4/geo/proxy_git_push_ssh/push
) - For each
/api/v4/geo/proxy_git_push_ssh/*
API endpoint on the secondary node, logic forinfo_refs
(https://gitlab.com/gitlab-org/gitlab-ee/blob/master/ee/lib/gitlab/geo/git_push_ssh_proxy.rb#L57) andpush
(https://gitlab.com/gitlab-org/gitlab-ee/blob/master/ee/lib/gitlab/geo/git_push_ssh_proxy.rb#L71) is executed.
Items 4. and 5. present a challenge here as we need to not only POST data to the various endpoints, but we also need to return and pass along any output.
Am totally open to alternate ways of achieving the same result
Related:
Edited by Ash McKenzie