Welcome to mirror list, hosted at ThFree Co, Russian Federation.

gitlab.com/gitlab-org/gitlab-foss.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorZeger-Jan van de Weg <git@zjvandeweg.nl>2018-05-16 11:20:14 +0300
committerJacob Vosmaer <jacob@gitlab.com>2018-06-06 12:20:41 +0300
commitf131757fc81e6f04f5adfcf09f37e13b008bf4b8 (patch)
treed76c0678f73b7f553e5cdcf42d3ddb26c164410d /lib/gitlab/gitaly_client.rb
parentbb6b73cf3c64a6f963e6afc657cab937db46564b (diff)
Set Gitaly Server feature flags from Rails
Gitaly itself hold very little state, other than the data on disk. This limits the interfaces to set feature flags. Gitaly now has the ability to interpret the request metadata to check for feature flags. https://gitlab.com/gitlab-org/gitaly/merge_requests/704 This allows clients control on the Gitaly server, and given that Rails has an internal chatops interface to set these values this was chosen as solution. Known limitation right now, is that this package doesn't support the opt out that other Gitaly features do.
Diffstat (limited to 'lib/gitlab/gitaly_client.rb')
-rw-r--r--lib/gitlab/gitaly_client.rb16
1 files changed, 16 insertions, 0 deletions
diff --git a/lib/gitlab/gitaly_client.rb b/lib/gitlab/gitaly_client.rb
index 550294916a4..52e940ee407 100644
--- a/lib/gitlab/gitaly_client.rb
+++ b/lib/gitlab/gitaly_client.rb
@@ -191,6 +191,8 @@ module Gitlab
metadata['call_site'] = feature.to_s if feature
metadata['gitaly-servers'] = address_metadata(remote_storage) if remote_storage
+ metadata.merge!(server_feature_flags(feature))
+
result = { metadata: metadata }
# nil timeout indicates that we should use the default
@@ -209,6 +211,20 @@ module Gitlab
result
end
+ SERVER_FEATURE_FLAGS = {
+ find_commit: ["gogit-findcommit"]
+ }.freeze
+
+ # Other than data on the disk, Gitaly is stateless. Rails will thus set
+ # feature flags in the request metadata.
+ def self.server_feature_flags(feature)
+ return {} unless SERVER_FEATURE_FLAGS.key?(feature)
+
+ SERVER_FEATURE_FLAGS[feature]
+ .map { |f| ["gitaly-feature-#{f}", feature_enabled?(f).to_s] }
+ .to_h
+ end
+
def self.token(storage)
params = Gitlab.config.repositories.storages[storage]
raise "storage not found: #{storage.inspect}" if params.nil?