Skip to content

Commit 583cff8

Browse files
jacobvosmaerDouwe Maan
authored and
Douwe Maan
committed
Default to Gitaly for 'git push' HTTP/SSH, and make Gitaly mandatory for SSH pull
1 parent 32e41b5 commit 583cff8

File tree

4 files changed

+31
-36
lines changed

4 files changed

+31
-36
lines changed
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
---
2+
title: Default to Gitaly for 'git push' HTTP/SSH, and make Gitaly mandatory for SSH
3+
pull
4+
merge_request: 16586
5+
author:
6+
type: other

lib/api/helpers/internal_helpers.rb

+8-7
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,6 @@
11
module API
22
module Helpers
33
module InternalHelpers
4-
SSH_GITALY_FEATURES = {
5-
'git-receive-pack' => [:ssh_receive_pack, Gitlab::GitalyClient::MigrationStatus::OPT_IN],
6-
'git-upload-pack' => [:ssh_upload_pack, Gitlab::GitalyClient::MigrationStatus::OPT_OUT]
7-
}.freeze
8-
94
attr_reader :redirected_path
105

116
def wiki?
@@ -102,8 +97,14 @@ def repository_path
10297

10398
# Return the Gitaly Address if it is enabled
10499
def gitaly_payload(action)
105-
feature, status = SSH_GITALY_FEATURES[action]
106-
return unless feature && Gitlab::GitalyClient.feature_enabled?(feature, status: status)
100+
return unless %w[git-receive-pack git-upload-pack].include?(action)
101+
102+
if action == 'git-receive-pack'
103+
return unless Gitlab::GitalyClient.feature_enabled?(
104+
:ssh_receive_pack,
105+
status: Gitlab::GitalyClient::MigrationStatus::OPT_OUT
106+
)
107+
end
107108

108109
{
109110
repository: repository.gitaly_repository,

lib/gitlab/workhorse.rb

+4-1
Original file line numberDiff line numberDiff line change
@@ -34,7 +34,10 @@ def git_http_ok(repository, is_wiki, user, action, show_all_refs: false)
3434

3535
feature_enabled = case action.to_s
3636
when 'git_receive_pack'
37-
Gitlab::GitalyClient.feature_enabled?(:post_receive_pack)
37+
Gitlab::GitalyClient.feature_enabled?(
38+
:post_receive_pack,
39+
status: Gitlab::GitalyClient::MigrationStatus::OPT_OUT
40+
)
3841
when 'git_upload_pack'
3942
true
4043
when 'info_refs'

spec/requests/api/internal_spec.rb

+13-28
Original file line numberDiff line numberDiff line change
@@ -317,35 +317,20 @@
317317
end
318318

319319
context "git pull" do
320-
context "gitaly disabled", :disable_gitaly do
321-
it "has the correct payload" do
322-
pull(key, project)
323-
324-
expect(response).to have_gitlab_http_status(200)
325-
expect(json_response["status"]).to be_truthy
326-
expect(json_response["repository_path"]).to eq(project.repository.path_to_repo)
327-
expect(json_response["gl_repository"]).to eq("project-#{project.id}")
328-
expect(json_response["gitaly"]).to be_nil
329-
expect(user).to have_an_activity_record
330-
end
331-
end
332-
333-
context "gitaly enabled" do
334-
it "has the correct payload" do
335-
pull(key, project)
320+
it "has the correct payload" do
321+
pull(key, project)
336322

337-
expect(response).to have_gitlab_http_status(200)
338-
expect(json_response["status"]).to be_truthy
339-
expect(json_response["repository_path"]).to eq(project.repository.path_to_repo)
340-
expect(json_response["gl_repository"]).to eq("project-#{project.id}")
341-
expect(json_response["gitaly"]).not_to be_nil
342-
expect(json_response["gitaly"]["repository"]).not_to be_nil
343-
expect(json_response["gitaly"]["repository"]["storage_name"]).to eq(project.repository.gitaly_repository.storage_name)
344-
expect(json_response["gitaly"]["repository"]["relative_path"]).to eq(project.repository.gitaly_repository.relative_path)
345-
expect(json_response["gitaly"]["address"]).to eq(Gitlab::GitalyClient.address(project.repository_storage))
346-
expect(json_response["gitaly"]["token"]).to eq(Gitlab::GitalyClient.token(project.repository_storage))
347-
expect(user).to have_an_activity_record
348-
end
323+
expect(response).to have_gitlab_http_status(200)
324+
expect(json_response["status"]).to be_truthy
325+
expect(json_response["repository_path"]).to eq(project.repository.path_to_repo)
326+
expect(json_response["gl_repository"]).to eq("project-#{project.id}")
327+
expect(json_response["gitaly"]).not_to be_nil
328+
expect(json_response["gitaly"]["repository"]).not_to be_nil
329+
expect(json_response["gitaly"]["repository"]["storage_name"]).to eq(project.repository.gitaly_repository.storage_name)
330+
expect(json_response["gitaly"]["repository"]["relative_path"]).to eq(project.repository.gitaly_repository.relative_path)
331+
expect(json_response["gitaly"]["address"]).to eq(Gitlab::GitalyClient.address(project.repository_storage))
332+
expect(json_response["gitaly"]["token"]).to eq(Gitlab::GitalyClient.token(project.repository_storage))
333+
expect(user).to have_an_activity_record
349334
end
350335
end
351336

0 commit comments

Comments
 (0)