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
path: root/lib
diff options
context:
space:
mode:
authorGitLab Bot <gitlab-bot@gitlab.com>2024-01-16 15:08:54 +0300
committerGitLab Bot <gitlab-bot@gitlab.com>2024-01-16 15:08:54 +0300
commit218585fc850159e0cf7fa4b609f0837cb5f29599 (patch)
treeb4210dff575984a1a5f7aa6328355dc499c62b93 /lib
parent65d9a877b3487bdcb75985dbcbe8bcf76280591f (diff)
Add latest changes from gitlab-org/gitlab@master
Diffstat (limited to 'lib')
-rw-r--r--lib/gitlab/redis/wrapper.rb38
1 files changed, 34 insertions, 4 deletions
diff --git a/lib/gitlab/redis/wrapper.rb b/lib/gitlab/redis/wrapper.rb
index 1f5d8ab7c9b..80f3e8418ba 100644
--- a/lib/gitlab/redis/wrapper.rb
+++ b/lib/gitlab/redis/wrapper.rb
@@ -17,6 +17,7 @@ module Gitlab
module Redis
class Wrapper
InvalidPathError = Class.new(StandardError)
+ CommandExecutionError = Class.new(StandardError)
class << self
delegate :params, :url, :store, :encrypted_secrets, :redis_client_params, to: :new
@@ -178,17 +179,46 @@ module Gitlab
config[:instrumentation_class] ||= self.class.instrumentation_class
decrypted_config = parse_encrypted_config(config)
+ final_config = parse_extra_config(decrypted_config)
- result = if decrypted_config[:cluster].present?
- decrypted_config[:db] = 0 # Redis Cluster only supports db 0
- decrypted_config
+ result = if final_config[:cluster].present?
+ final_config[:db] = 0 # Redis Cluster only supports db 0
+ final_config
else
- parse_redis_url(decrypted_config)
+ parse_redis_url(final_config)
end
parse_client_tls_options(result)
end
+ def parse_extra_config(decrypted_config)
+ command = decrypted_config.delete(:config_command)
+ return decrypted_config unless command.present?
+
+ config_from_command = extra_config_from_command(command)
+ return decrypted_config unless config_from_command.present?
+
+ decrypted_config.deep_merge(config_from_command)
+ end
+
+ def extra_config_from_command(command)
+ cmd = command.split(" ")
+ output, exit_status = Gitlab::Popen.popen(cmd)
+
+ if exit_status != 0
+ raise CommandExecutionError,
+ "Redis: Execution of `#{command}` failed with exit code #{exit_status}. Output: #{output}"
+ end
+
+ YAML.safe_load(output).deep_symbolize_keys
+ rescue Psych::SyntaxError => e
+ error_message = <<~MSG
+ Redis: Execution of `#{command}` generated invalid yaml.
+ Error: #{e.problem} #{e.context} at line #{e.line} column #{e.column}
+ MSG
+ raise CommandExecutionError, error_message
+ end
+
def parse_encrypted_config(encrypted_config)
encrypted_config.delete(:secret_file)