Skip to content

Commit fed2e1c

Browse files
committed
feat(chart): enable automatic browser leftovers cleanup in chart
Signed-off-by: Viet Nguyen Duc <[email protected]>
1 parent ed2b538 commit fed2e1c

File tree

6 files changed

+38
-3
lines changed

6 files changed

+38
-3
lines changed

Diff for: README.md

+2-2
Original file line numberDiff line numberDiff line change
@@ -952,15 +952,15 @@ of jobs that have already finished but failed to fully stop the browser, or temp
952952
file system (notably on Chrome-based browsers). To avoid these filling up resources like process IDs and file system
953953
usage in the container, there is an automatic cleanup script running every hour in the node containers. This will
954954
clean up old processes and old temporary files. By default, this is disabled. When enabled, this will clean up browsers
955-
running for longer than 20 minutes, and files older than 1 day. These can be enabled and tweaked with the following
955+
running for longer than 2 hours, and files older than 1 day. These can be enabled and tweaked with the following
956956
environment variables:
957957

958958
* `SE_ENABLE_BROWSER_LEFTOVERS_CLEANUP`: default value `false`, set to `true` to enable the cleanup.
959959
* `SE_BROWSER_LEFTOVERS_INTERVAL_SECS`: default value `3600` (1 hour), cleanup interval in seconds.
960960
* `SE_BROWSER_LEFTOVERS_PROCESSES_SECS`: default value `7200` (2 hours), browsers running for longer than this time will be killed.
961961
* `SE_BROWSER_LEFTOVERS_TEMPFILES_DAYS`: default value `1` (1 day), files generated by Chrome-based browsers in `/tmp` will be removed after these number of days (ignored when using Firefox).
962962

963-
If you use Selenium for long-running sessions and expect browsers to be running for longer than 20 minutes, either do
963+
If you use Selenium for long-running sessions and expect browsers to be running for longer than 2 hours, either do
964964
not set `SE_ENABLE_BROWSER_LEFTOVERS_CLEANUP` to `true` (leave the default value of `false`), or tweak
965965
`SE_BROWSER_LEFTOVERS_PROCESSES_SECS` to set a value higher than your expected long-running browser processes.
966966

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

+12
Original file line numberDiff line numberDiff line change
@@ -26,6 +26,18 @@ data:
2626
SE_DRAIN_AFTER_SESSION_COUNT: '{{- and (eq (include "seleniumGrid.useKEDA" .) "true") (eq .Values.autoscaling.scalingType "job") | ternary "1" "0" -}}'
2727
SE_NODE_GRID_URL: '{{ include "seleniumGrid.url" .}}'
2828
SE_NODE_GRID_GRAPHQL_URL: '{{ include "seleniumGrid.graphqlURL" . }}'
29+
{{- if $.Values.nodeConfigMap.leftoversCleanup.enabled }}
30+
SE_ENABLE_BROWSER_LEFTOVERS_CLEANUP: 'true'
31+
{{- with $.Values.nodeConfigMap.leftoversCleanup.jobIntervalInSecs }}
32+
SE_BROWSER_LEFTOVERS_INTERVAL_SECS: '{{ . }}'
33+
{{- end }}
34+
{{- with $.Values.nodeConfigMap.leftoversCleanup.browserElapsedTimeInSecs }}
35+
SE_BROWSER_LEFTOVERS_PROCESSES_SECS: '{{ . }}'
36+
{{- end }}
37+
{{- with $.Values.nodeConfigMap.leftoversCleanup.tmpFilesAfterDays }}
38+
SE_BROWSER_LEFTOVERS_TEMPFILES_DAYS: '{{ . }}'
39+
{{- end }}
40+
{{- end }}
2941
{{- $fileProceeded := list -}}
3042
{{- range $path, $_ := .Files.Glob $.Values.nodeConfigMap.extraScriptsImportFrom }}
3143
{{- $fileName := base $path -}}

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

+7-1
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,7 @@ global:
2222
# liveness probe method `exec.command` is using a script is mounted from `nodeConfigMap.extraScripts.nodeProbe.sh`
2323
defaultNodeLivenessProbe: exec
2424
# probe logs output can be retrieved using `kubectl logs`
25-
stdoutProbeLog: true
25+
stdoutProbeLog: false
2626

2727
tls:
2828
enabled: false
@@ -117,6 +117,12 @@ nodeConfigMap:
117117
nodeProbe.sh:
118118
# Name of volume mount is used to mount scripts in the ConfigMap
119119
scriptVolumeMountName:
120+
# Automatic browser leftovers cleanup stuck browser processes, tmp files
121+
leftoversCleanup:
122+
enabled: false
123+
jobIntervalInSecs: 3600
124+
browserElapsedTimeInSecs: 7200
125+
tmpFilesAfterDays: 1
120126
# Custom annotations for configmap
121127
annotations: {}
122128

Diff for: tests/charts/templates/render/dummy.yaml

+2
Original file line numberDiff line numberDiff line change
@@ -120,6 +120,8 @@ videoRecorder:
120120
RCLONE_CONFIG_S3_NO_CHECK_BUCKET: "true"
121121

122122
nodeConfigMap:
123+
leftoversCleanup:
124+
enabled: true
123125
extraScripts:
124126
nodeCustomTask.sh: |
125127
#!/bin/bash

Diff for: tests/charts/templates/render/dummy_solution.yaml

+2
Original file line numberDiff line numberDiff line change
@@ -104,6 +104,8 @@ selenium-grid:
104104
RCLONE_CONFIG_S3_NO_CHECK_BUCKET: "true"
105105

106106
nodeConfigMap:
107+
leftoversCleanup:
108+
enabled: true
107109
extraScripts:
108110
nodeCustomTask.sh: |
109111
#!/bin/bash

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

+13
Original file line numberDiff line numberDiff line change
@@ -203,6 +203,19 @@ def test_terminationGracePeriodSeconds_in_deployment_autoscaling(self):
203203
count += 1
204204
self.assertEqual(count, len(resources_name), "node.terminationGracePeriodSeconds doesn't inherit the global value autoscaling.terminationGracePeriodSeconds")
205205

206+
def test_enable_leftovers_cleanup(self):
207+
resources_name = ['{0}selenium-node-config'.format(RELEASE_NAME)]
208+
count = 0
209+
for doc in LIST_OF_DOCUMENTS:
210+
if doc['metadata']['name'] in resources_name and doc['kind'] == 'ConfigMap':
211+
logger.info(f"Assert ENV vars for function leftovers cleanup is set to Node ConfigMap")
212+
self.assertEqual(doc['data']['SE_ENABLE_BROWSER_LEFTOVERS_CLEANUP'], 'true')
213+
self.assertEqual(doc['data']['SE_BROWSER_LEFTOVERS_INTERVAL_SECS'], '3600')
214+
self.assertEqual(doc['data']['SE_BROWSER_LEFTOVERS_PROCESSES_SECS'], '7200')
215+
self.assertEqual(doc['data']['SE_BROWSER_LEFTOVERS_TEMPFILES_DAYS'], '1')
216+
count += 1
217+
self.assertEqual(count, len(resources_name), "No node config resources found")
218+
206219
if __name__ == '__main__':
207220
failed = False
208221
try:

0 commit comments

Comments
 (0)