Skip to content

Commit 6216a4d

Browse files
committed
chart(feat): updateStrategy default RollingUpdate for browsers and Recreate for components
Signed-off-by: Viet Nguyen Duc <[email protected]>
1 parent 59397b1 commit 6216a4d

12 files changed

+77
-3
lines changed

Diff for: charts/selenium-grid/templates/_helpers.tpl

+20
Original file line numberDiff line numberDiff line change
@@ -246,6 +246,26 @@ triggers:
246246
{{- end }}
247247
{{- end -}}
248248

249+
{{/*
250+
Component update strategy template
251+
*/}}
252+
{{- define "seleniumGrid.updateStrategy" -}}
253+
{{- $value := index . 0 -}}
254+
{{- $global := index . 1 -}}
255+
{{- $spec := toYaml (dict) -}}
256+
{{- if not (empty $global.updateStrategy) -}}
257+
{{- $spec = merge $global.updateStrategy ($spec | fromYaml) | toYaml -}}
258+
{{- end -}}
259+
{{- if not (empty $value.updateStrategy) -}}
260+
{{- $spec = merge $value.updateStrategy ($spec | fromYaml) | toYaml -}}
261+
{{- end -}}
262+
{{/* If final result is Recreate, update a clean object */}}
263+
{{- if eq ($spec | fromYaml).type "Recreate" }}
264+
{{- $spec = toYaml (dict "type" "Recreate") -}}
265+
{{- end -}}
266+
{{ $spec | nindent 4 }}
267+
{{- end -}}
268+
249269
{{/*
250270
Common pod template
251271
*/}}

Diff for: charts/selenium-grid/templates/chrome-node-deployment.yaml

+2
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,8 @@ metadata:
1515
{{- toYaml . | nindent 4 }}
1616
{{- end }}
1717
spec:
18+
strategy:
19+
{{- template "seleniumGrid.updateStrategy" (list $.Values.chromeNode $.Values.global.seleniumGrid) }}
1820
{{- if and (not .Values.autoscaling.enabled) (not .Values.autoscaling.enableWithExistingKEDA) }}
1921
replicas: {{ .Values.chromeNode.replicas }}
2022
{{end}}

Diff for: charts/selenium-grid/templates/distributor-deployment.yaml

+2
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,8 @@ metadata:
1212
{{- toYaml . | nindent 4 }}
1313
{{- end }}
1414
spec:
15+
strategy:
16+
{{- template "seleniumGrid.updateStrategy" (list $.Values.components.distributor $.Values.global.seleniumGrid) }}
1517
replicas: 1
1618
revisionHistoryLimit: {{ .Values.global.seleniumGrid.revisionHistoryLimit }}
1719
selector:

Diff for: charts/selenium-grid/templates/edge-node-deployment.yaml

+2
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,8 @@ metadata:
1515
{{- toYaml . | nindent 4 }}
1616
{{- end }}
1717
spec:
18+
strategy:
19+
{{- template "seleniumGrid.updateStrategy" (list $.Values.edgeNode $.Values.global.seleniumGrid) }}
1820
{{- if and (not .Values.autoscaling.enabled) (not .Values.autoscaling.enableWithExistingKEDA) }}
1921
replicas: {{ .Values.edgeNode.replicas }}
2022
{{end}}

Diff for: charts/selenium-grid/templates/event-bus-deployment.yaml

+2
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,8 @@ metadata:
1212
{{- toYaml . | nindent 4 }}
1313
{{- end }}
1414
spec:
15+
strategy:
16+
{{- template "seleniumGrid.updateStrategy" (list $.Values.components.eventBus $.Values.global.seleniumGrid) }}
1517
replicas: 1
1618
revisionHistoryLimit: {{ .Values.global.seleniumGrid.revisionHistoryLimit }}
1719
selector:

Diff for: charts/selenium-grid/templates/firefox-node-deployment.yaml

+2
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,8 @@ metadata:
1515
{{- toYaml . | nindent 4 }}
1616
{{- end }}
1717
spec:
18+
strategy:
19+
{{- template "seleniumGrid.updateStrategy" (list $.Values.firefoxNode $.Values.global.seleniumGrid) }}
1820
{{- if and (not .Values.autoscaling.enabled) (not .Values.autoscaling.enableWithExistingKEDA) }}
1921
replicas: {{ .Values.firefoxNode.replicas }}
2022
{{end}}

Diff for: charts/selenium-grid/templates/hub-deployment.yaml

+2
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,8 @@ metadata:
1515
{{- toYaml . | nindent 4 }}
1616
{{- end }}
1717
spec:
18+
strategy:
19+
{{- template "seleniumGrid.updateStrategy" (list $.Values.hub $.Values.global.seleniumGrid) }}
1820
replicas: 1
1921
revisionHistoryLimit: {{ .Values.global.seleniumGrid.revisionHistoryLimit }}
2022
selector:

Diff for: charts/selenium-grid/templates/router-deployment.yaml

+2
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,8 @@ metadata:
1212
{{- toYaml . | nindent 4 }}
1313
{{- end }}
1414
spec:
15+
strategy:
16+
{{- template "seleniumGrid.updateStrategy" (list $.Values.components.router $.Values.global.seleniumGrid) }}
1517
replicas: 1
1618
revisionHistoryLimit: {{ .Values.global.seleniumGrid.revisionHistoryLimit }}
1719
selector:

Diff for: charts/selenium-grid/templates/session-map-deployment.yaml

+2
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,8 @@ metadata:
1212
{{- toYaml . | nindent 4 }}
1313
{{- end }}
1414
spec:
15+
strategy:
16+
{{- template "seleniumGrid.updateStrategy" (list $.Values.components.sessionMap $.Values.global.seleniumGrid) }}
1517
replicas: 1
1618
revisionHistoryLimit: {{ .Values.global.seleniumGrid.revisionHistoryLimit }}
1719
selector:

Diff for: charts/selenium-grid/templates/session-queue-deployment.yaml

+2
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,8 @@ metadata:
1212
{{- toYaml . | nindent 4 }}
1313
{{- end }}
1414
spec:
15+
strategy:
16+
{{- template "seleniumGrid.updateStrategy" (list $.Values.components.sessionQueue $.Values.global.seleniumGrid) }}
1517
replicas: 1
1618
revisionHistoryLimit: {{ .Values.global.seleniumGrid.revisionHistoryLimit }}
1719
selector:

Diff for: charts/selenium-grid/values.yaml

+16-3
Original file line numberDiff line numberDiff line change
@@ -33,6 +33,13 @@ global:
3333
structuredLogs: false
3434
# Enable http logging. Tracing should be enabled to log http logs.
3535
httpLogs: false
36+
# Define update strategy for all components
37+
updateStrategy:
38+
type: Recreate
39+
# type: RollingUpdate
40+
rollingUpdate:
41+
maxSurge: 1
42+
maxUnavailable: 0
3643

3744
tls:
3845
# Name of external secret containing the TLS certificate and key
@@ -721,7 +728,9 @@ chromeNode:
721728
# true (default) - if you want long-living pods
722729
# false - for provisioning your own custom type such as Jobs
723730
deploymentEnabled: true
724-
731+
# Global update strategy will be overwritten by individual component
732+
updateStrategy:
733+
type: RollingUpdate
725734
# Number of chrome nodes
726735
replicas: 1
727736
# imageRegistry: selenium
@@ -882,7 +891,9 @@ firefoxNode:
882891
# true (default) - if you want long living pods
883892
# false - for provisioning your own custom type such as Jobs
884893
deploymentEnabled: true
885-
894+
# Global update strategy will be overwritten by individual component
895+
updateStrategy:
896+
type: RollingUpdate
886897
# Number of firefox nodes
887898
replicas: 1
888899
# imageRegistry: selenium
@@ -1042,7 +1053,9 @@ edgeNode:
10421053
# true (default) - if you want long living pods
10431054
# false - for provisioning your own custom type such as Jobs
10441055
deploymentEnabled: true
1045-
1056+
# Global update strategy will be overwritten by individual component
1057+
updateStrategy:
1058+
type: RollingUpdate
10461059
# Number of edge nodes
10471060
replicas: 1
10481061
# imageRegistry: selenium

Diff for: tests/charts/templates/test.py

+23
Original file line numberDiff line numberDiff line change
@@ -261,6 +261,29 @@ def test_enable_tracing(self):
261261
count += 1
262262
self.assertEqual(count, len(resources_name), "No node config resources found")
263263

264+
def test_update_strategy_in_all_components(self):
265+
recreate = ['{0}selenium-distributor'.format(RELEASE_NAME),
266+
'{0}selenium-event-bus'.format(RELEASE_NAME),
267+
'{0}selenium-router'.format(RELEASE_NAME),
268+
'{0}selenium-session-map'.format(RELEASE_NAME),
269+
'{0}selenium-session-queue'.format(RELEASE_NAME),]
270+
rolling = ['{0}selenium-chrome-node'.format(RELEASE_NAME),
271+
'{0}selenium-edge-node'.format(RELEASE_NAME),
272+
'{0}selenium-firefox-node'.format(RELEASE_NAME),]
273+
count_recreate = 0
274+
count_rolling = 0
275+
for doc in LIST_OF_DOCUMENTS:
276+
if doc['metadata']['name'] in rolling and doc['kind'] == 'Deployment':
277+
logger.info(f"Assert updateStrategy is set in resource {doc['metadata']['name']}")
278+
self.assertTrue(doc['spec']['strategy']['type'] == 'RollingUpdate', f"Resource {doc['metadata']['name']} doesn't have strategy RollingUpdate")
279+
count_rolling += 1
280+
if doc['metadata']['name'] in recreate and doc['kind'] == 'Deployment':
281+
logger.info(f"Assert updateStrategy is set in resource {doc['metadata']['name']}")
282+
self.assertTrue(doc['spec']['strategy']['type'] == 'Recreate', f"Resource {doc['metadata']['name']} doesn't have strategy Recreate")
283+
count_recreate += 1
284+
self.assertEqual(count_rolling, len(rolling), "No deployment resources found with strategy RollingUpdate")
285+
self.assertEqual(count_recreate, len(recreate), "No deployment resources found with strategy Recreate")
286+
264287
if __name__ == '__main__':
265288
failed = False
266289
try:

0 commit comments

Comments
 (0)