Skip to content

Commit d51f55f

Browse files
balasankarcRobert Marshall
authored andcommitted
Switch GitLab Exporter to use NewRedisHelper
Refactor the GitLab Exporter recipe to calculate its redis configuration with the new helper library. Signed-off-by: Balasankar 'Balu' C <[email protected]>
1 parent 6ac66c1 commit d51f55f

File tree

2 files changed

+29
-5
lines changed

2 files changed

+29
-5
lines changed

files/gitlab-cookbooks/monitoring/recipes/gitlab-exporter.rb

Lines changed: 4 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,7 @@
1616
# limitations under the License.
1717
#
1818
account_helper = AccountHelper.new(node)
19-
redis_helper = RedisHelper.new(node)
19+
redis_helper = NewRedisHelper::GitlabExporter.new(node)
2020
logfiles_helper = LogfilesHelper.new(node)
2121
logging_settings = logfiles_helper.logging_settings('gitlab-exporter')
2222
gitlab_user = account_helper.gitlab_user
@@ -51,8 +51,7 @@
5151
else
5252
" host=#{node['gitlab']['gitlab_rails']['db_host']} port=#{node['gitlab']['gitlab_rails']['db_port']} password=#{node['gitlab']['gitlab_rails']['db_password']}"
5353
end
54-
55-
redis_url = redis_helper.redis_url(support_sentinel_groupname: false)
54+
redis_params = redis_helper.redis_params
5655

5756
template "#{gitlab_exporter_dir}/gitlab-exporter.yml" do
5857
source "gitlab-exporter.yml.erb"
@@ -64,9 +63,9 @@
6463
probe_elasticsearch: node['monitoring']['gitlab_exporter']['probe_elasticsearch'],
6564
elasticsearch_url: node['monitoring']['gitlab_exporter']['elasticsearch_url'],
6665
elasticsearch_authorization: node['monitoring']['gitlab_exporter']['elasticsearch_authorization'],
67-
redis_url: redis_url,
66+
redis_url: redis_params[:url],
6867
connection_string: connection_string,
69-
redis_enable_client: node['gitlab']['gitlab_rails']['redis_enable_client']
68+
redis_enable_client: redis_params[:enable_client]
7069
)
7170
sensitive true
7271
end
Lines changed: 25 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,25 @@
1+
module NewRedisHelper
2+
class GitlabExporter < NewRedisHelper::Base
3+
def redis_params
4+
{
5+
url: redis_url,
6+
enable_client: enable_client
7+
}
8+
end
9+
10+
private
11+
12+
def enable_client
13+
node_attr['redis_enable_client']
14+
end
15+
16+
# GitLab Exporter uses the same Redis information as GitLab Rails
17+
def node_access_keys
18+
%w[gitlab gitlab_rails]
19+
end
20+
21+
def support_sentinel_groupname?
22+
false
23+
end
24+
end
25+
end

0 commit comments

Comments
 (0)