summaryrefslogtreecommitdiff
path: root/lib/gitlab/setup_helper.rb
diff options
context:
space:
mode:
authorGitLab Bot <gitlab-bot@gitlab.com>2022-05-19 07:33:21 +0000
committerGitLab Bot <gitlab-bot@gitlab.com>2022-05-19 07:33:21 +0000
commit36a59d088eca61b834191dacea009677a96c052f (patch)
treee4f33972dab5d8ef79e3944a9f403035fceea43f /lib/gitlab/setup_helper.rb
parenta1761f15ec2cae7c7f7bbda39a75494add0dfd6f (diff)
downloadgitlab-ce-36a59d088eca61b834191dacea009677a96c052f.tar.gz
Add latest changes from gitlab-org/gitlab@15-0-stable-eev15.0.0-rc42
Diffstat (limited to 'lib/gitlab/setup_helper.rb')
-rw-r--r--lib/gitlab/setup_helper.rb35
1 files changed, 27 insertions, 8 deletions
diff --git a/lib/gitlab/setup_helper.rb b/lib/gitlab/setup_helper.rb
index a498e329c3f..1e42003b203 100644
--- a/lib/gitlab/setup_helper.rb
+++ b/lib/gitlab/setup_helper.rb
@@ -149,28 +149,47 @@ module Gitlab
module Praefect
extend Gitlab::SetupHelper
class << self
- def configuration_toml(gitaly_dir, _, _)
+ def configuration_toml(gitaly_dir, _storage_paths, options)
+ raise 'This configuration is only intended for test' unless Rails.env.test?
+
nodes = [{ storage: 'default', address: "unix:#{gitaly_dir}/gitaly.socket", primary: true, token: 'secret' }]
second_storage_nodes = [{ storage: 'test_second_storage', address: "unix:#{gitaly_dir}/gitaly2.socket", primary: true, token: 'secret' }]
storages = [{ name: 'default', node: nodes }, { name: 'test_second_storage', node: second_storage_nodes }]
- failover = { enabled: false, election_strategy: 'local' }
+
config = {
- i_understand_my_election_strategy_is_unsupported_and_will_be_removed_without_warning: true,
socket_path: "#{gitaly_dir}/praefect.socket",
- memory_queue_enabled: true,
virtual_storage: storages,
- failover: failover
+ token: 'secret'
}
- config[:token] = 'secret' if Rails.env.test?
+
+ if options[:per_repository]
+ failover = { enabled: true, election_strategy: 'per_repository' }
+ database = { host: options.fetch(:pghost),
+ port: options.fetch(:pgport).to_i,
+ user: options.fetch(:pguser),
+ dbname: options.fetch(:dbname, 'praefect_test') }
+
+ config.merge!(database: database,
+ failover: failover)
+ else
+ failover = { enabled: false, election_strategy: 'local' }
+
+ config.merge!(
+ i_understand_my_election_strategy_is_unsupported_and_will_be_removed_without_warning: true,
+ memory_queue_enabled: true,
+ failover: failover
+ )
+ end
TomlRB.dump(config)
end
private
- def get_config_path(dir, _)
- File.join(dir, 'praefect.config.toml')
+ def get_config_path(dir, options)
+ config_filename = options[:config_filename] || 'praefect.config.toml'
+ File.join(dir, config_filename)
end
end
end