From c8b53a74ef47dc4c35740e25131ea66f6d78c1eb Mon Sep 17 00:00:00 2001 From: Joachim Winkler Date: Wed, 12 Jun 2024 13:39:43 +0200 Subject: [PATCH 01/14] add check of scheme for workhorse config --- charts/gitlab/templates/_redis.tpl | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/charts/gitlab/templates/_redis.tpl b/charts/gitlab/templates/_redis.tpl index 124f160f2e..42dd9fef04 100644 --- a/charts/gitlab/templates/_redis.tpl +++ b/charts/gitlab/templates/_redis.tpl @@ -113,13 +113,19 @@ Return Sentinel list in format for Workhorse {{- define "gitlab.redis.workhorse.sentinel-list" }} {{- include "gitlab.redis.selectedMergedConfig" . -}} {{- $sentinelList := list }} +{{- $scheme := "tcp" }} +{{- if eq .global.redis.scheme "rediss" }} + {{- $scheme = "rediss" }} +{{- end }} {{- range $i, $entry := .redisMergedConfig.sentinels }} - {{- $sentinelList = append $sentinelList (quote (print "tcp://" (trim $entry.host) ":" ( default 26379 $entry.port | int ) ) ) }} + {{- $sentinelList = append $sentinelList (quote (print $scheme "://" (trim $entry.host) ":" ( default 26379 $entry.port +| int ) ) ) }} {{- end }} {{- $sentinelList | join "," }} {{- end -}} + {{/* Takes a dict with `globalContext` and `instances` as keys. The former specifies the root context `$`, and the latter a list of instances to mount secrets for. -- GitLab From 55ee116ab8b60936be829b46cf608771c902d698 Mon Sep 17 00:00:00 2001 From: Joachim Winkler Date: Wed, 12 Jun 2024 15:34:00 +0200 Subject: [PATCH 02/14] add scheme to values --- charts/gitlab/charts/webservice/values.yaml | 1 + 1 file changed, 1 insertion(+) diff --git a/charts/gitlab/charts/webservice/values.yaml b/charts/gitlab/charts/webservice/values.yaml index 951a44d0d7..565dec734b 100644 --- a/charts/gitlab/charts/webservice/values.yaml +++ b/charts/gitlab/charts/webservice/values.yaml @@ -289,6 +289,7 @@ global: redis: # host: '0.0.0.0' auth: {} + scheme: redis gitaly: internal: names: ["default"] -- GitLab From a4ea04d1ed598c75e559398f6d15640b94c9a43b Mon Sep 17 00:00:00 2001 From: joawin Date: Fri, 14 Jun 2024 06:01:18 +0000 Subject: [PATCH 03/14] remove withspace --- charts/gitlab/templates/_redis.tpl | 1 - 1 file changed, 1 deletion(-) diff --git a/charts/gitlab/templates/_redis.tpl b/charts/gitlab/templates/_redis.tpl index 42dd9fef04..c2509fa128 100644 --- a/charts/gitlab/templates/_redis.tpl +++ b/charts/gitlab/templates/_redis.tpl @@ -125,7 +125,6 @@ Return Sentinel list in format for Workhorse {{- end -}} - {{/* Takes a dict with `globalContext` and `instances` as keys. The former specifies the root context `$`, and the latter a list of instances to mount secrets for. -- GitLab From b68867ecf1cb0dff1f6e89b5d2b8ad2d37858578 Mon Sep 17 00:00:00 2001 From: joawin Date: Fri, 14 Jun 2024 11:24:36 +0000 Subject: [PATCH 04/14] Apply 1 suggestion(s) to 1 file(s) Co-authored-by: Jason Plum --- charts/gitlab/templates/_redis.tpl | 5 +---- 1 file changed, 1 insertion(+), 4 deletions(-) diff --git a/charts/gitlab/templates/_redis.tpl b/charts/gitlab/templates/_redis.tpl index c2509fa128..53d1a50746 100644 --- a/charts/gitlab/templates/_redis.tpl +++ b/charts/gitlab/templates/_redis.tpl @@ -113,10 +113,7 @@ Return Sentinel list in format for Workhorse {{- define "gitlab.redis.workhorse.sentinel-list" }} {{- include "gitlab.redis.selectedMergedConfig" . -}} {{- $sentinelList := list }} -{{- $scheme := "tcp" }} -{{- if eq .global.redis.scheme "rediss" }} - {{- $scheme = "rediss" }} -{{- end }} +{{- $scheme := default "redis" .redisMergedConfig.scheme }} {{- range $i, $entry := .redisMergedConfig.sentinels }} {{- $sentinelList = append $sentinelList (quote (print $scheme "://" (trim $entry.host) ":" ( default 26379 $entry.port | int ) ) ) }} -- GitLab From 8765640ed0f97085eab322f9334584175e87a1d1 Mon Sep 17 00:00:00 2001 From: joawin Date: Tue, 5 Nov 2024 10:31:08 +0000 Subject: [PATCH 05/14] Update file workhorse_spec.rb --- spec/configuration/workhorse_spec.rb | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/spec/configuration/workhorse_spec.rb b/spec/configuration/workhorse_spec.rb index d8c27b5837..eafde3778d 100644 --- a/spec/configuration/workhorse_spec.rb +++ b/spec/configuration/workhorse_spec.rb @@ -336,7 +336,7 @@ describe 'Workhorse configuration' do redis_config = toml['redis'] expect(redis_config.keys).to match_array(%w[Password SentinelMaster Sentinel]) expect(redis_config['SentinelMaster']).to eq('workhorse.redis') - expect(redis_config['Sentinel']).to match_array(%w[tcp://s1.workhorse.redis:26379 tcp://s2.workhorse.redis:26379]) + expect(redis_config['Sentinel']).to match_array(%w[scheme://s1.workhorse.redis:26379 scheme://s2.workhorse.redis:26379]) expect(redis_config['Password']).to eq(workhorse_redis_password) expect(template.dig("ConfigMap/test-workhorse-default", "data", 'workhorse-config.toml.tpl')).to include('redis/workhorse-password') expect(template.dig('ConfigMap/test-workhorse-default', 'data', 'configure')).to include('init-config/redis/workhorse-password') @@ -355,7 +355,8 @@ describe 'Workhorse configuration' do redis_config = toml['redis'] expect(redis_config.keys).to match_array(%w[SentinelMaster Sentinel]) expect(redis_config['SentinelMaster']).to eq('workhorse.redis') - expect(redis_config['Sentinel']).to match_array(%w[tcp://s1.workhorse.redis:26379 tcp://s2.workhorse.redis:26379]) + expect(redis_config['Sentinel']).to match_array(%w[scheme://s1.workhorse.redis:26379 scheme://s2.workhorse.redis:26379]) + end end @@ -399,7 +400,7 @@ describe 'Workhorse configuration' do redis_config = toml['redis'] expect(redis_config.keys).to match_array(%w[Password SentinelMaster Sentinel SentinelPassword]) expect(redis_config['SentinelMaster']).to eq('workhorse.redis') - expect(redis_config['Sentinel']).to match_array(%w[tcp://s1.workhorse.redis:26379 tcp://s2.workhorse.redis:26379]) + expect(redis_config['Sentinel']).to match_array(%w[scheme://s1.workhorse.redis:26379 scheme://s2.workhorse.redis:26379]) expect(redis_config['Password']).to eq(workhorse_redis_password) expect(redis_config['SentinelPassword']).to eq(global_redis_sentinel_password) -- GitLab From 9d4f7fd78834fbac34b221802a124f0ac50ac396 Mon Sep 17 00:00:00 2001 From: joawin Date: Tue, 5 Nov 2024 12:10:37 +0000 Subject: [PATCH 06/14] Update file workhorse_spec.rb --- spec/configuration/workhorse_spec.rb | 7 +++---- 1 file changed, 3 insertions(+), 4 deletions(-) diff --git a/spec/configuration/workhorse_spec.rb b/spec/configuration/workhorse_spec.rb index eafde3778d..e033cb3b51 100644 --- a/spec/configuration/workhorse_spec.rb +++ b/spec/configuration/workhorse_spec.rb @@ -336,7 +336,7 @@ describe 'Workhorse configuration' do redis_config = toml['redis'] expect(redis_config.keys).to match_array(%w[Password SentinelMaster Sentinel]) expect(redis_config['SentinelMaster']).to eq('workhorse.redis') - expect(redis_config['Sentinel']).to match_array(%w[scheme://s1.workhorse.redis:26379 scheme://s2.workhorse.redis:26379]) + expect(redis_config['Sentinel']).to match_array(["{{ $scheme }}://s1.workhorse.redis:26379", "{{ $scheme }}://s2.workhorse.redis:26379"]) expect(redis_config['Password']).to eq(workhorse_redis_password) expect(template.dig("ConfigMap/test-workhorse-default", "data", 'workhorse-config.toml.tpl')).to include('redis/workhorse-password') expect(template.dig('ConfigMap/test-workhorse-default', 'data', 'configure')).to include('init-config/redis/workhorse-password') @@ -355,8 +355,7 @@ describe 'Workhorse configuration' do redis_config = toml['redis'] expect(redis_config.keys).to match_array(%w[SentinelMaster Sentinel]) expect(redis_config['SentinelMaster']).to eq('workhorse.redis') - expect(redis_config['Sentinel']).to match_array(%w[scheme://s1.workhorse.redis:26379 scheme://s2.workhorse.redis:26379]) - + expect(redis_config['Sentinel']).to match_array(["{{ $scheme }}://s1.workhorse.redis:26379", "{{ $scheme }}://s2.workhorse.redis:26379"]) end end @@ -400,7 +399,7 @@ describe 'Workhorse configuration' do redis_config = toml['redis'] expect(redis_config.keys).to match_array(%w[Password SentinelMaster Sentinel SentinelPassword]) expect(redis_config['SentinelMaster']).to eq('workhorse.redis') - expect(redis_config['Sentinel']).to match_array(%w[scheme://s1.workhorse.redis:26379 scheme://s2.workhorse.redis:26379]) + expect(redis_config['Sentinel']).to match_array(["{{ $scheme }}://s1.workhorse.redis:26379", "{{ $scheme }}://s2.workhorse.redis:26379"]) expect(redis_config['Password']).to eq(workhorse_redis_password) expect(redis_config['SentinelPassword']).to eq(global_redis_sentinel_password) -- GitLab From 7096f2ddc9e8a96e11fbc965c354d9db967e61bb Mon Sep 17 00:00:00 2001 From: joawin Date: Tue, 5 Nov 2024 12:54:52 +0000 Subject: [PATCH 07/14] Update file workhorse_spec.rb --- spec/configuration/workhorse_spec.rb | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/spec/configuration/workhorse_spec.rb b/spec/configuration/workhorse_spec.rb index e033cb3b51..d799026cda 100644 --- a/spec/configuration/workhorse_spec.rb +++ b/spec/configuration/workhorse_spec.rb @@ -336,7 +336,7 @@ describe 'Workhorse configuration' do redis_config = toml['redis'] expect(redis_config.keys).to match_array(%w[Password SentinelMaster Sentinel]) expect(redis_config['SentinelMaster']).to eq('workhorse.redis') - expect(redis_config['Sentinel']).to match_array(["{{ $scheme }}://s1.workhorse.redis:26379", "{{ $scheme }}://s2.workhorse.redis:26379"]) + expect(redis_config['Sentinel']).to match_array(%w[redis://s1.workhorse.redis:26379 redis://s2.workhorse.redis:26379]) expect(redis_config['Password']).to eq(workhorse_redis_password) expect(template.dig("ConfigMap/test-workhorse-default", "data", 'workhorse-config.toml.tpl')).to include('redis/workhorse-password') expect(template.dig('ConfigMap/test-workhorse-default', 'data', 'configure')).to include('init-config/redis/workhorse-password') @@ -355,7 +355,7 @@ describe 'Workhorse configuration' do redis_config = toml['redis'] expect(redis_config.keys).to match_array(%w[SentinelMaster Sentinel]) expect(redis_config['SentinelMaster']).to eq('workhorse.redis') - expect(redis_config['Sentinel']).to match_array(["{{ $scheme }}://s1.workhorse.redis:26379", "{{ $scheme }}://s2.workhorse.redis:26379"]) + expect(redis_config['Sentinel']).to match_array(%w[redis://s1.workhorse.redis:26379 redis://s2.workhorse.redis:26379]) end end @@ -399,7 +399,7 @@ describe 'Workhorse configuration' do redis_config = toml['redis'] expect(redis_config.keys).to match_array(%w[Password SentinelMaster Sentinel SentinelPassword]) expect(redis_config['SentinelMaster']).to eq('workhorse.redis') - expect(redis_config['Sentinel']).to match_array(["{{ $scheme }}://s1.workhorse.redis:26379", "{{ $scheme }}://s2.workhorse.redis:26379"]) + expect(redis_config['Sentinel']).to match_array(%w[redis://s1.workhorse.redis:26379 redis://s2.workhorse.redis:26379]) expect(redis_config['Password']).to eq(workhorse_redis_password) expect(redis_config['SentinelPassword']).to eq(global_redis_sentinel_password) -- GitLab From 2dbe0925f849e555a7dd22337e2a2fdfafd84427 Mon Sep 17 00:00:00 2001 From: joawin Date: Sat, 9 Nov 2024 19:21:32 +0000 Subject: [PATCH 08/14] Update values.yaml --- values.yaml | 2 ++ 1 file changed, 2 insertions(+) diff --git a/values.yaml b/values.yaml index 6d72bb8658..cadcdc97cc 100644 --- a/values.yaml +++ b/values.yaml @@ -180,6 +180,8 @@ global: enabled: false # secret: # key: + workhorse: + scheme: redis ## https://docs.gitlab.com/charts/charts/globals#configure-gitaly-settings gitaly: -- GitLab From 8e39819859d14596fbf42073b55641b09945f56a Mon Sep 17 00:00:00 2001 From: joawin Date: Mon, 11 Nov 2024 08:12:51 +0000 Subject: [PATCH 09/14] Update values.yaml --- charts/gitlab/charts/webservice/values.yaml | 1 - 1 file changed, 1 deletion(-) diff --git a/charts/gitlab/charts/webservice/values.yaml b/charts/gitlab/charts/webservice/values.yaml index 8909c332a8..4d7fb0771c 100644 --- a/charts/gitlab/charts/webservice/values.yaml +++ b/charts/gitlab/charts/webservice/values.yaml @@ -299,7 +299,6 @@ global: redis: # host: '0.0.0.0' auth: {} - scheme: redis gitaly: internal: names: ["default"] -- GitLab From 922b34a1ed029e871d294a026a679c785c0fef17 Mon Sep 17 00:00:00 2001 From: joawin Date: Wed, 13 Nov 2024 09:59:24 +0000 Subject: [PATCH 10/14] revert last changes --- charts/gitlab/charts/webservice/values.yaml | 1 + values.yaml | 2 -- 2 files changed, 1 insertion(+), 2 deletions(-) diff --git a/charts/gitlab/charts/webservice/values.yaml b/charts/gitlab/charts/webservice/values.yaml index 4d7fb0771c..8909c332a8 100644 --- a/charts/gitlab/charts/webservice/values.yaml +++ b/charts/gitlab/charts/webservice/values.yaml @@ -299,6 +299,7 @@ global: redis: # host: '0.0.0.0' auth: {} + scheme: redis gitaly: internal: names: ["default"] diff --git a/values.yaml b/values.yaml index cadcdc97cc..6d72bb8658 100644 --- a/values.yaml +++ b/values.yaml @@ -180,8 +180,6 @@ global: enabled: false # secret: # key: - workhorse: - scheme: redis ## https://docs.gitlab.com/charts/charts/globals#configure-gitaly-settings gitaly: -- GitLab From 483dd767665445a515b49df496052fed5d1e3411 Mon Sep 17 00:00:00 2001 From: Joachim Winkler Date: Mon, 3 Feb 2025 13:31:50 +0100 Subject: [PATCH 11/14] implement suggestions --- spec/configuration/workhorse_spec.rb | 18 ++++++++++++++++++ 1 file changed, 18 insertions(+) diff --git a/spec/configuration/workhorse_spec.rb b/spec/configuration/workhorse_spec.rb index d799026cda..efbe948313 100644 --- a/spec/configuration/workhorse_spec.rb +++ b/spec/configuration/workhorse_spec.rb @@ -304,6 +304,7 @@ describe 'Workhorse configuration' do global: redis: host: global.redis + scheme: rediss auth: enabled: true secret: global-secret @@ -336,12 +337,29 @@ describe 'Workhorse configuration' do redis_config = toml['redis'] expect(redis_config.keys).to match_array(%w[Password SentinelMaster Sentinel]) expect(redis_config['SentinelMaster']).to eq('workhorse.redis') + # Workhorse sentinels don't use global rediss scheme expect(redis_config['Sentinel']).to match_array(%w[redis://s1.workhorse.redis:26379 redis://s2.workhorse.redis:26379]) expect(redis_config['Password']).to eq(workhorse_redis_password) expect(template.dig("ConfigMap/test-workhorse-default", "data", 'workhorse-config.toml.tpl')).to include('redis/workhorse-password') expect(template.dig('ConfigMap/test-workhorse-default', 'data', 'configure')).to include('init-config/redis/workhorse-password') end + context 'with workhorse rediss scheme' do + before do + values["global"]["redis"]["workhorse"]["scheme"] = 'rediss' + end + + it 'uses the rediss scheme' do + expect(template.exit_code).to eq(0), "Unexpected error code #{template.exit_code} -- #{template.stderr}" + + toml = render_toml(raw_toml) + redis_config = toml['redis'] + + expect(redis_config['Sentinel']).to match_array(%w[rediss://s1.workhorse.redis:26379 rediss://s2.workhorse.redis:26379]) + end + end + + context 'when workhorse redis does not have password' do before do values["global"]["redis"]["workhorse"]["password"]["enabled"] = false -- GitLab From 8aec26d976e1faf52a3c3109c079f664597ea033 Mon Sep 17 00:00:00 2001 From: Joachim Winkler Date: Mon, 3 Feb 2025 13:39:28 +0100 Subject: [PATCH 12/14] fix whitespaces --- spec/configuration/workhorse_spec.rb | 7 ++----- 1 file changed, 2 insertions(+), 5 deletions(-) diff --git a/spec/configuration/workhorse_spec.rb b/spec/configuration/workhorse_spec.rb index efbe948313..ea19cf2e1f 100644 --- a/spec/configuration/workhorse_spec.rb +++ b/spec/configuration/workhorse_spec.rb @@ -348,18 +348,15 @@ describe 'Workhorse configuration' do before do values["global"]["redis"]["workhorse"]["scheme"] = 'rediss' end - + it 'uses the rediss scheme' do expect(template.exit_code).to eq(0), "Unexpected error code #{template.exit_code} -- #{template.stderr}" - toml = render_toml(raw_toml) redis_config = toml['redis'] - expect(redis_config['Sentinel']).to match_array(%w[rediss://s1.workhorse.redis:26379 rediss://s2.workhorse.redis:26379]) end end - - + context 'when workhorse redis does not have password' do before do values["global"]["redis"]["workhorse"]["password"]["enabled"] = false -- GitLab From b8b8fd0701e9be19eb4dd2ebbd72e7ac867eb5ba Mon Sep 17 00:00:00 2001 From: Joachim Winkler Date: Mon, 3 Feb 2025 13:43:15 +0100 Subject: [PATCH 13/14] fix BlockAlignment --- spec/configuration/workhorse_spec.rb | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/spec/configuration/workhorse_spec.rb b/spec/configuration/workhorse_spec.rb index ea19cf2e1f..5020632e9a 100644 --- a/spec/configuration/workhorse_spec.rb +++ b/spec/configuration/workhorse_spec.rb @@ -351,12 +351,13 @@ describe 'Workhorse configuration' do it 'uses the rediss scheme' do expect(template.exit_code).to eq(0), "Unexpected error code #{template.exit_code} -- #{template.stderr}" + toml = render_toml(raw_toml) redis_config = toml['redis'] expect(redis_config['Sentinel']).to match_array(%w[rediss://s1.workhorse.redis:26379 rediss://s2.workhorse.redis:26379]) - end + end end - + context 'when workhorse redis does not have password' do before do values["global"]["redis"]["workhorse"]["password"]["enabled"] = false -- GitLab From b835a9d58f6a3bf79d3d21a9a52a654ed6764239 Mon Sep 17 00:00:00 2001 From: Joachim Winkler Date: Mon, 3 Feb 2025 14:56:43 +0100 Subject: [PATCH 14/14] remove scheme from redis --- charts/gitlab/charts/webservice/values.yaml | 1 - 1 file changed, 1 deletion(-) diff --git a/charts/gitlab/charts/webservice/values.yaml b/charts/gitlab/charts/webservice/values.yaml index 8909c332a8..4d7fb0771c 100644 --- a/charts/gitlab/charts/webservice/values.yaml +++ b/charts/gitlab/charts/webservice/values.yaml @@ -299,7 +299,6 @@ global: redis: # host: '0.0.0.0' auth: {} - scheme: redis gitaly: internal: names: ["default"] -- GitLab