提交 87987632 编写于 作者: G GitLab Bot

Add latest changes from gitlab-org/gitlab@master

上级 b63f3afa
......@@ -3,4 +3,6 @@
require ::File.expand_path('../../config/environment', __FILE__)
Rails.application.eager_load!
ACTION_CABLE_SERVER = true
run ActionCable.server
---
title: Decouple partial clone config from max input size
merge_request: 30354
author: Son Luong Ngoc
type: changed
......@@ -1065,6 +1065,11 @@ production: &base
# host: localhost
# port: 3808
## ActionCable settings
action_cable:
# Number of threads used to process ActionCable connection callbacks and channel actions
# worker_pool_size: 4
## Monitoring
# Built in monitoring settings
monitoring:
......
......@@ -717,6 +717,12 @@ Settings.webpack.dev_server['enabled'] ||= false
Settings.webpack.dev_server['host'] ||= 'localhost'
Settings.webpack.dev_server['port'] ||= 3808
#
# ActionCable settings
#
Settings['action_cable'] ||= Settingslogic.new({})
Settings.action_cable['worker_pool_size'] ||= 4
#
# Monitoring settings
#
......
......@@ -5,4 +5,5 @@ Rails.application.configure do
# we're running ActionCable as a standalone server
config.action_cable.mount_path = nil
config.action_cable.url = Gitlab::Utils.append_path(Gitlab.config.gitlab.relative_url_root, '/-/cable')
config.action_cable.worker_pool_size = Gitlab.config.action_cable.worker_pool_size
end
......@@ -69,13 +69,14 @@ module API
}
# Custom option for git-receive-pack command
if Feature.enabled?(:gitaly_upload_pack_filter, project, default_enabled: true)
payload[:git_config_options] << "uploadpack.allowFilter=true" << "uploadpack.allowAnySHA1InWant=true"
end
receive_max_input_size = Gitlab::CurrentSettings.receive_max_input_size.to_i
if receive_max_input_size > 0
payload[:git_config_options] << "receive.maxInputSize=#{receive_max_input_size.megabytes}"
if Feature.enabled?(:gitaly_upload_pack_filter, project, default_enabled: true)
payload[:git_config_options] << "uploadpack.allowFilter=true" << "uploadpack.allowAnySHA1InWant=true"
end
end
response_with_status(**payload)
......
......@@ -37,7 +37,7 @@ module Gitlab
end
def puma?
!!defined?(::Puma)
!!defined?(::Puma) && !defined?(ACTION_CABLE_SERVER)
end
# For unicorn, we need to check for actual server instances to avoid false positives.
......@@ -70,25 +70,31 @@ module Gitlab
end
def web_server?
puma? || unicorn?
puma? || unicorn? || action_cable?
end
def action_cable?
!!defined?(ACTION_CABLE_SERVER)
end
def multi_threaded?
puma? || sidekiq?
puma? || sidekiq? || action_cable?
end
def max_threads
main_thread = 1
if puma?
Puma.cli_config.options[:max_threads] + main_thread
if action_cable?
Gitlab::Application.config.action_cable.worker_pool_size
elsif puma?
Puma.cli_config.options[:max_threads]
elsif sidekiq?
# An extra thread for the poller in Sidekiq Cron:
# https://github.com/ondrejbartas/sidekiq-cron#under-the-hood
Sidekiq.options[:concurrency] + main_thread + 1
Sidekiq.options[:concurrency] + 1
else
main_thread
end
0
end + main_thread
end
end
end
......
......@@ -14,6 +14,7 @@ module QA
ResourceQueryError = Class.new(RuntimeError)
ResourceUpdateFailedError = Class.new(RuntimeError)
ResourceURLMissingError = Class.new(RuntimeError)
InternalServerError = Class.new(RuntimeError)
attr_reader :api_resource, :api_response
attr_writer :api_client
......@@ -85,7 +86,9 @@ module QA
url = Runtime::API::Request.new(api_client, get_path).url
response = get(url)
unless response.code == HTTP_STATUS_OK
if response.code == HTTP_STATUS_SERVER_ERROR
raise InternalServerError, "Failed to GET #{url} - (#{response.code}): `#{response}`."
elsif response.code != HTTP_STATUS_OK
raise ResourceNotFoundError, "Resource at #{url} could not be found (#{response.code}): `#{response}`."
end
......
......@@ -7,6 +7,7 @@ module QA
HTTP_STATUS_CREATED = 201
HTTP_STATUS_NO_CONTENT = 204
HTTP_STATUS_ACCEPTED = 202
HTTP_STATUS_SERVER_ERROR = 500
def post(url, payload)
RestClient::Request.execute(
......
......@@ -105,4 +105,17 @@ describe Gitlab::Runtime do
it_behaves_like "valid runtime", :rails_runner, 1
end
context "action_cable" do
before do
stub_const('ACTION_CABLE_SERVER', true)
stub_const('::Puma', Module.new)
allow(Gitlab::Application).to receive_message_chain(:config, :action_cable, :worker_pool_size).and_return(8)
end
it "reports its maximum concurrency based on ActionCable's worker pool size" do
expect(subject.max_threads).to eq(9)
end
end
end
......@@ -441,10 +441,11 @@ describe API::Internal::Base do
allow(Gitlab::CurrentSettings).to receive(:receive_max_input_size) { 1 }
end
it 'returns custom git config' do
it 'returns maxInputSize and partial clone git config' do
push(key, project)
expect(json_response["git_config_options"]).to be_present
expect(json_response["git_config_options"]).to include("receive.maxInputSize=1048576")
expect(json_response["git_config_options"]).to include("uploadpack.allowFilter=true")
expect(json_response["git_config_options"]).to include("uploadpack.allowAnySHA1InWant=true")
end
......@@ -454,10 +455,11 @@ describe API::Internal::Base do
stub_feature_flags(gitaly_upload_pack_filter: { enabled: false, thing: project })
end
it 'does not include allowFilter and allowAnySha1InWant in the git config options' do
it 'returns only maxInputSize and not partial clone git config' do
push(key, project)
expect(json_response["git_config_options"]).to be_present
expect(json_response["git_config_options"]).to include("receive.maxInputSize=1048576")
expect(json_response["git_config_options"]).not_to include("uploadpack.allowFilter=true")
expect(json_response["git_config_options"]).not_to include("uploadpack.allowAnySHA1InWant=true")
end
......@@ -465,12 +467,28 @@ describe API::Internal::Base do
end
context 'when receive_max_input_size is empty' do
it 'returns an empty git config' do
before do
allow(Gitlab::CurrentSettings).to receive(:receive_max_input_size) { nil }
end
it 'returns partial clone git config' do
push(key, project)
expect(json_response["git_config_options"]).to be_empty
expect(json_response["git_config_options"]).to be_present
expect(json_response["git_config_options"]).to include("uploadpack.allowFilter=true")
expect(json_response["git_config_options"]).to include("uploadpack.allowAnySHA1InWant=true")
end
context 'when gitaly_upload_pack_filter feature flag is disabled' do
before do
stub_feature_flags(gitaly_upload_pack_filter: { enabled: false, thing: project })
end
it 'returns an empty git config' do
push(key, project)
expect(json_response["git_config_options"]).to be_empty
end
end
end
end
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册