Skip to content

Commit bf48ef2

Browse files
balasankarcRobert Marshall
authored andcommitted
Enable unique password configuration for redis and sentinels
Allow workhorse to be configured with different passwords for the redis and sentinels services. Related https://gitlab.com/gitlab-org/gitlab/-/issues/422820 Changelog: fixed Signed-off-by: Balasankar "Balu" C <[email protected]>
1 parent 7327497 commit bf48ef2

File tree

5 files changed

+8
-6
lines changed

5 files changed

+8
-6
lines changed

files/gitlab-cookbooks/gitlab/libraries/redis_helper.rb

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -70,7 +70,7 @@ def workhorse_params
7070
password: redis_params.last,
7171
sentinels: redis_sentinel_urls('redis_sentinels'),
7272
sentinelMaster: redis['master_name'],
73-
sentinelPassword: redis['master_password']
73+
sentinelPassword: gitlab_rails['redis_sentinels_password']
7474
}
7575
end
7676
end

files/gitlab-cookbooks/gitlab/recipes/gitlab-workhorse.rb

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -108,7 +108,7 @@
108108
password: redis_params[:password],
109109
sentinels: redis_params[:sentinels],
110110
sentinel_master: redis_params[:sentinelMaster],
111-
master_password: redis_params[:sentinelPassword],
111+
sentinel_password: redis_params[:sentinelPassword],
112112
shutdown_timeout: shutdown_timeout,
113113
image_scaler_max_procs: image_scaler_max_procs,
114114
image_scaler_max_filesize: image_scaler_max_filesize,

files/gitlab-cookbooks/gitlab/templates/default/workhorse-config.toml.erb

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -13,13 +13,13 @@ trusted_cidrs_for_x_forwarded_for = <%= @trusted_cidrs_for_x_forwarded_for.to_js
1313

1414
<% if @workhorse_keywatcher %>
1515
[redis]
16+
Password = "<%= @password %>"
1617
<% if @sentinels.empty? %>
1718
URL = "<%= @redis_url %>"
18-
Password = "<%= @password %>"
1919
<% else %>
2020
Sentinel = <%= @sentinels.to_json %>
2121
SentinelMaster = "<%= @sentinel_master %>"
22-
Password = "<%= @master_password %>"
22+
SentinelPassword = "<%= @sentinel_password %>"
2323
<% end %>
2424
<% end %>
2525

spec/chef/cookbooks/gitlab/libraries/redis_helper_spec.rb

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -186,7 +186,7 @@
186186
expect(params[:password]).to eq('password_from.redis.master_password')
187187
expect(params[:sentinels].map(&:to_s)).to eq(%w[redis://sentinel1.example.com:12345 redis://sentinel2.example.com:12345])
188188
expect(params[:sentinelMaster]).to eq('master_from.redis.master_name')
189-
expect(params[:sentinelPassword]).to eq('password_from.redis.master_password')
189+
expect(params[:sentinelPassword]).to be_nil
190190
expect(params[:url].to_s).to eq("redis://:password_from.redis.master_password@master_from.redis.master_name/")
191191
end
192192
end

spec/chef/cookbooks/gitlab/recipes/gitlab-workhorse_spec.rb

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -610,9 +610,11 @@
610610
it 'should generate config file with the specified values' do
611611
content = 'Sentinel = ["redis://:[email protected]:26379","redis://:[email protected]:12345"]'
612612
content_sentinel_master = 'SentinelMaster = "examplemaster"'
613-
content_sentinel_password = 'Password = "examplepassword"'
613+
content_password = 'Password = "examplepassword"'
614+
content_sentinel_password = 'SentinelPassword = "some pass"'
614615
content_url = 'URL ='
615616
expect(chef_run).to render_file("/var/opt/gitlab/gitlab-workhorse/config.toml").with_content(content)
617+
expect(chef_run).to render_file("/var/opt/gitlab/gitlab-workhorse/config.toml").with_content(content_password)
616618
expect(chef_run).to render_file("/var/opt/gitlab/gitlab-workhorse/config.toml").with_content(content_sentinel_master)
617619
expect(chef_run).to render_file("/var/opt/gitlab/gitlab-workhorse/config.toml").with_content(content_sentinel_password)
618620
expect(chef_run).not_to render_file("/var/opt/gitlab/gitlab-workhorse/config.toml").with_content(content_url)

0 commit comments

Comments
 (0)