Skip to content
Snippets Groups Projects
Commit 6c142799 authored by Stan Hu's avatar Stan Hu
Browse files

Make ActionCable Redis settings use default Redis Sentinel password

Suppose you have this config:

```
gitlab_rails['redis_sentinels'] = [
  {"host"=>"gitlabtest-cluster-redis-01", "port"=>26379},
  {"host"=>"gitlabtest-cluster-redis-02", "port"=>26379},
  {"host"=>"gitlabtest-cluster-redis-03", "port"=>26379}
]
gitlab_rails['redis_sentinels_password'] = "some password"
redis['enable'] = false
redis['master_name'] = "gitlab-redis"
redis['master_password'] = "some password"
```

Previously ActionCable Redis settings would only look for
`gitlab_rails['redis_actioncable_sentinels_password']` and did
not fall back to `gitlab_rails['redis_sentinels_password']`.

Relates to https://gitlab.com/gitlab-org/omnibus-gitlab/-/issues/8728

Changelog: fixed
parent 6fd2edae
1 merge request!167Merge upstream Omnibus GitLab into Omnibus Heptapod
...@@ -265,6 +265,7 @@ ...@@ -265,6 +265,7 @@
url = node['gitlab']['gitlab_rails']['redis_actioncable_instance'] url = node['gitlab']['gitlab_rails']['redis_actioncable_instance']
sentinels = node['gitlab']['gitlab_rails']['redis_actioncable_sentinels'] sentinels = node['gitlab']['gitlab_rails']['redis_actioncable_sentinels']
sentinels_password = node['gitlab']['gitlab_rails']['redis_actioncable_sentinels_password'] sentinels_password = node['gitlab']['gitlab_rails']['redis_actioncable_sentinels_password']
sentinels_password ||= redis_sentinels_password if sentinels.nil? || sentinels.empty?
if url.nil? if url.nil?
url = redis_url url = redis_url
......
...@@ -378,6 +378,120 @@ ...@@ -378,6 +378,120 @@
expect(resque_yml).to eq(expected_output) expect(resque_yml).to eq(expected_output)
end end
end end
context 'with Redis Sentinels password configured' do
let(:cable_yml_template) { chef_run.template('/var/opt/gitlab/gitlab-rails/etc/cable.yml') }
let(:cable_yml_file_content) { ChefSpec::Renderer.new(chef_run, cable_yml_template).content }
let(:cable_yml) { YAML.safe_load(cable_yml_file_content, aliases: true, symbolize_names: true) }
let(:sentinel_password) { "global sentinel pass" }
let(:expected_output) do
{
production: {
url: 'redis://:toomanysecrets@gitlab-redis/',
sentinels: [
{ host: '10.0.0.2', port: 26379, password: sentinel_password },
{ host: '10.0.0.3', port: 26379, password: sentinel_password },
{ host: '10.0.0.4', port: 26379, password: sentinel_password },
],
secret_file: '/var/opt/gitlab/gitlab-rails/shared/encrypted_settings/redis.yml.enc',
}
}
end
let(:expected_cable_output) do
{
production: {
adapter: 'redis',
url: 'redis://:toomanysecrets@gitlab-redis/',
sentinels: [
{ host: '10.0.0.2', port: 26379, password: sentinel_password },
{ host: '10.0.0.3', port: 26379, password: sentinel_password },
{ host: '10.0.0.4', port: 26379, password: sentinel_password },
]
}
}
end
before do
stub_gitlab_rb(
redis: {
enable: true,
master_name: 'gitlab-redis',
master_password: 'toomanysecrets'
},
gitlab_rails: {
redis_sentinels_password: 'global sentinel pass',
redis_sentinels: [
{ host: '10.0.0.2', port: 26379 },
{ host: '10.0.0.3', port: 26379 },
{ host: '10.0.0.4', port: 26379 },
]
}
)
end
it 'populates resque.yml with expected values' do
expect(resque_yml).to eq(expected_output)
expect(cable_yml).to eq(expected_cable_output)
end
context 'with ActionCable Redis Sentinels defined' do
let(:expected_output) do
{
production: {
url: 'redis://:toomanysecrets@gitlab-redis/',
sentinels: [
{ host: '10.0.0.2', port: 26379, password: sentinel_password },
{ host: '10.0.0.3', port: 26379, password: sentinel_password },
{ host: '10.0.0.4', port: 26379, password: sentinel_password },
],
secret_file: '/var/opt/gitlab/gitlab-rails/shared/encrypted_settings/redis.yml.enc',
}
}
end
let(:expected_cable_output) do
{
production: {
adapter: 'redis',
url: 'redis://:fakepass@fake.redis.actioncable.com:8888/2',
sentinels: [
{ host: '10.0.0.5', port: 26379 },
{ host: '10.0.0.6', port: 26379 },
{ host: '10.0.0.7', port: 26379 },
]
}
}
end
before do
stub_gitlab_rb(
redis: {
enable: true,
master_name: 'gitlab-redis',
master_password: 'toomanysecrets'
},
gitlab_rails: {
redis_sentinels_password: 'global sentinel pass',
redis_sentinels: [
{ host: '10.0.0.2', port: 26379 },
{ host: '10.0.0.3', port: 26379 },
{ host: '10.0.0.4', port: 26379 },
],
redis_actioncable_instance: "redis://:fakepass@fake.redis.actioncable.com:8888/2",
redis_actioncable_sentinels: [
{ host: '10.0.0.5', port: 26379 },
{ host: '10.0.0.6', port: 26379 },
{ host: '10.0.0.7', port: 26379 },
]
}
)
end
it 'populates resque.yml with expected values' do
expect(resque_yml).to eq(expected_output)
expect(cable_yml).to eq(expected_cable_output)
end
end
end
end end
end end
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment