From 75bfc7e53c6b25657bca38dfc378b8d5f8df3fbb Mon Sep 17 00:00:00 2001 From: Stan Hu Date: Tue, 5 Mar 2019 14:08:02 -0800 Subject: [PATCH] Add support for Google Cloud Memorystore This adds an optional `redis_enable_client` config option that will turn off the CLIENT command when talking to the Sidekiq API. Relates to https://gitlab.com/gitlab-org/omnibus-gitlab/issues/4164 --- config/gitlab-monitor.yml.example | 1 + lib/gitlab_monitor/sidekiq.rb | 25 +++++++++++++++++++------ 2 files changed, 20 insertions(+), 6 deletions(-) diff --git a/config/gitlab-monitor.yml.example b/config/gitlab-monitor.yml.example index 8f82e66..ed4b906 100644 --- a/config/gitlab-monitor.yml.example +++ b/config/gitlab-monitor.yml.example @@ -78,6 +78,7 @@ probes: - probe_dead opts: redis_url: "redis://localhost:6379" + redis_enable_client: true metrics: multiple: true diff --git a/lib/gitlab_monitor/sidekiq.rb b/lib/gitlab_monitor/sidekiq.rb index ed703d5..9fe3811 100644 --- a/lib/gitlab_monitor/sidekiq.rb +++ b/lib/gitlab_monitor/sidekiq.rb @@ -15,12 +15,7 @@ module GitLab @metrics = metrics Sidekiq.configure_client do |config| - config.redis = { - url: opts[:redis_url], - namespace: "resque:gitlab", - connect_timeout: 1, - reconnect_attempts: 0 - } + config.redis = redis_options end ensure_queue_job_stats_script_loaded @@ -110,6 +105,24 @@ module GitLab private + def redis_options + options = { + url: @opts[:redis_url], + namespace: "resque:gitlab", + connect_timeout: 1, + reconnect_attempts: 0 + } + + options[:id] = nil unless redis_enable_client? + options + end + + def redis_enable_client? + return true if @opts[:redis_enable_client].nil? + + @opts[:redis_enable_client] + end + def connected? @connected ||= begin Sidekiq.redis do |conn| -- GitLab