Skip to content

Commit 77e0802

Browse files
feat: add support for secondary visibility store (dual visibility) (#839)
* feat: add support for secondary visibility store (dual visibility) Add support for secondaryVisibilityStore configuration to enable dual visibility feature in Temporal server. This allows writing to two visibility stores simultaneously for migration scenarios.
1 parent 3ced297 commit 77e0802

File tree

4 files changed

+131
-2
lines changed

4 files changed

+131
-2
lines changed

charts/temporal/templates/_helpers.tpl

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -140,6 +140,7 @@ app.kubernetes.io/part-of: {{ $global.Chart.Name }}
140140
{{- $config := deepCopy . -}}
141141
{{- $defaultStore := $config.defaultStore -}}
142142
{{- $visibilityStore := $config.visibilityStore -}}
143+
{{- $secondaryVisibilityStore := $config.secondaryVisibilityStore | default "" -}}
143144
{{- $patchedDatastores := dict -}}
144145
{{- range $name, $ds := $config.datastores -}}
145146
{{- $dsCopy := deepCopy $ds -}}
@@ -151,6 +152,8 @@ app.kubernetes.io/part-of: {{ $global.Chart.Name }}
151152
{{- $_ := set $storeConfig "password" "__ENV_TEMPORAL_DEFAULT_STORE_PASSWORD__" -}}
152153
{{- else if eq $name $visibilityStore -}}
153154
{{- $_ := set $storeConfig "password" "__ENV_TEMPORAL_VISIBILITY_STORE_PASSWORD__" -}}
155+
{{- else if eq $name $secondaryVisibilityStore -}}
156+
{{- $_ := set $storeConfig "password" "__ENV_TEMPORAL_SECONDARY_VISIBILITY_STORE_PASSWORD__" -}}
154157
{{- else -}}
155158
{{- $_ := unset $storeConfig "password" -}}
156159
{{- end -}}
@@ -168,6 +171,10 @@ app.kubernetes.io/part-of: {{ $global.Chart.Name }}
168171
{{- $stores := dict -}}
169172
{{- $_ := set $stores "default" (include "temporal.persistence.getStoreByType" (list $ "default") | fromYaml) -}}
170173
{{- $_ := set $stores "visibility" (include "temporal.persistence.getStoreByType" (list $ "visibility") | fromYaml) -}}
174+
{{- $secondaryVisibility := include "temporal.persistence.getStoreByType" (list $ "secondaryVisibility") | fromYaml -}}
175+
{{- if $secondaryVisibility -}}
176+
{{- $_ := set $stores "secondaryVisibility" $secondaryVisibility -}}
177+
{{- end -}}
171178
{{- $stores | toYaml -}}
172179
{{- end -}}
173180

@@ -214,7 +221,11 @@ app.kubernetes.io/part-of: {{ $global.Chart.Name }}
214221
{{- $root := index . 0 -}}
215222
{{- $type := index . 1 -}}
216223
{{- $storeName := get $root.Values.server.config.persistence (printf "%sStore" $type) -}}
224+
{{- if $storeName -}}
217225
{{- include "temporal.persistence.getStore" (list $root $storeName) -}}
226+
{{- else -}}
227+
{{- dict | toYaml -}}
228+
{{- end -}}
218229
{{- end -}}
219230

220231
{{- define "temporal.persistence.schema" -}}

charts/temporal/templates/server-deployment.yaml

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
{{- if $.Values.server.enabled }}
22
{{- $defaultStore := include "temporal.persistence.getStoreByType" (list $ "default") | fromYaml -}}
33
{{- $visibilityStore := include "temporal.persistence.getStoreByType" (list $ "visibility") | fromYaml -}}
4+
{{- $secondaryVisibilityStore := include "temporal.persistence.getStoreByType" (list $ "secondaryVisibility") | fromYaml -}}
45
{{- range $service := (list "frontend" "internal-frontend" "history" "matching" "worker") }}
56
{{- $serviceValues := index $.Values.server $service }}
67
{{- if or (not (hasKey $serviceValues "enabled")) $serviceValues.enabled }}
@@ -66,6 +67,10 @@ spec:
6667
{{- include "temporal.password-env" (list $ $defaultStore) | nindent 14 }}
6768
- name: TEMPORAL_VISIBILITY_STORE_PASSWORD
6869
{{- include "temporal.password-env" (list $ $visibilityStore) | nindent 14 }}
70+
{{- if $secondaryVisibilityStore }}
71+
- name: TEMPORAL_SECONDARY_VISIBILITY_STORE_PASSWORD
72+
{{- include "temporal.password-env" (list $ $secondaryVisibilityStore) | nindent 14 }}
73+
{{- end }}
6974
{{- if (index $.Values.server "internal-frontend").enabled }}
7075
- name: USE_INTERNAL_FRONTEND
7176
value: "1"

charts/temporal/tests/server_configmap_test.yaml

Lines changed: 57 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -134,6 +134,62 @@ tests:
134134
- matchRegex:
135135
path: data['config_template.yaml']
136136
pattern: 'password: \{\{ env "TEMPORAL_VISIBILITY_STORE_PASSWORD" \| quote \}\}'
137+
- it: handles secondary visibility store for dual visibility
138+
set:
139+
server:
140+
enabled: true
141+
config:
142+
persistence:
143+
defaultStore: default
144+
visibilityStore: visibility
145+
secondaryVisibilityStore: secondary-visibility
146+
numHistoryShards: 512
147+
datastores:
148+
default:
149+
sql:
150+
pluginName: mysql8
151+
driverName: mysql8
152+
databaseName: temporal
153+
connectAddr: "mysql.example.com:3306"
154+
user: temporal_user
155+
password: "secret"
156+
visibility:
157+
elasticsearch:
158+
version: v8
159+
url:
160+
scheme: https
161+
host: "elasticsearch.example.com:9200"
162+
username: elastic
163+
password: "secret"
164+
indices:
165+
visibility: temporal_visibility_v1
166+
secondary-visibility:
167+
elasticsearch:
168+
version: v8
169+
url:
170+
scheme: https
171+
host: "elasticsearch.example.com:9200"
172+
username: elastic
173+
password: "secret2"
174+
indices:
175+
visibility: temporal_visibility_v1_secondary
176+
template: templates/server-configmap.yaml
177+
documentSelector:
178+
path: metadata.name
179+
value: RELEASE-NAME-temporal-config
180+
asserts:
181+
- matchRegex:
182+
path: data['config_template.yaml']
183+
pattern: 'secondaryVisibilityStore: secondary-visibility'
184+
- matchRegex:
185+
path: data['config_template.yaml']
186+
pattern: 'secondary-visibility:'
187+
- matchRegex:
188+
path: data['config_template.yaml']
189+
pattern: 'password: \{\{ env "TEMPORAL_SECONDARY_VISIBILITY_STORE_PASSWORD" \| quote \}\}'
190+
- matchRegex:
191+
path: data['config_template.yaml']
192+
pattern: 'visibility: temporal_visibility_v1_secondary'
137193

138194
- it: handles metrics config
139195
set:
@@ -175,4 +231,4 @@ tests:
175231
pattern: "withoutUnitSuffix: false"
176232
- matchRegex:
177233
path: data['config_template.yaml']
178-
pattern: "prometheus:\\s+listenAddress: 0.0.0.0:9090"
234+
pattern: "prometheus:\\s+listenAddress: 0.0.0.0:9090"

charts/temporal/tests/server_deployment_test.yaml

Lines changed: 58 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -295,6 +295,7 @@ tests:
295295
- equal:
296296
path: spec.template.spec.containers[0].readinessProbe.tcpSocket.port
297297
value: rpc
298+
298299
- it: additional environment variables are set on all services
299300
template: templates/server-deployment.yaml
300301
documentSelector:
@@ -315,6 +316,62 @@ tests:
315316
- equal:
316317
path: spec.template.spec.containers[0].envFrom[0].secretRef.name
317318
value: secret-env
318-
- equal:
319+
- equal:
319320
path: spec.template.spec.containers[0].envFrom[1].configMapRef.name
320321
value: configmap-env
322+
323+
- it: injects secondary visibility store password env var when configured
324+
template: templates/server-deployment.yaml
325+
set:
326+
server:
327+
config:
328+
persistence:
329+
defaultStore: default
330+
visibilityStore: visibility
331+
secondaryVisibilityStore: secondary-visibility
332+
datastores:
333+
default:
334+
sql:
335+
password: "secret"
336+
visibility:
337+
elasticsearch:
338+
password: "secret"
339+
secondary-visibility:
340+
elasticsearch:
341+
password: "secret2"
342+
documentSelector:
343+
path: metadata.name
344+
value: RELEASE-NAME-temporal-frontend
345+
asserts:
346+
- contains:
347+
path: spec.template.spec.containers[0].env
348+
content:
349+
name: TEMPORAL_SECONDARY_VISIBILITY_STORE_PASSWORD
350+
valueFrom:
351+
secretKeyRef:
352+
name: RELEASE-NAME-temporal-secondary-visibility-store
353+
key: password
354+
355+
- it: does not inject secondary visibility env var when not configured
356+
template: templates/server-deployment.yaml
357+
set:
358+
server:
359+
config:
360+
persistence:
361+
defaultStore: default
362+
visibilityStore: visibility
363+
datastores:
364+
default:
365+
sql:
366+
password: "secret"
367+
visibility:
368+
elasticsearch:
369+
password: "secret"
370+
documentSelector:
371+
path: metadata.name
372+
value: RELEASE-NAME-temporal-frontend
373+
asserts:
374+
- notContains:
375+
path: spec.template.spec.containers[0].env
376+
content:
377+
name: TEMPORAL_SECONDARY_VISIBILITY_STORE_PASSWORD

0 commit comments

Comments
 (0)