Skip to content

Commit 7dda02d

Browse files
authored
K8s: Fix video uploader secrets pass to Node single container (#2886)
* K8s: Update list default values for cross-browsers * K8s: Fix video uploader secrets pass to Node single container --------- Signed-off-by: Viet Nguyen Duc <[email protected]>
1 parent 18aec03 commit 7dda02d

File tree

15 files changed

+148
-30
lines changed

15 files changed

+148
-30
lines changed

.github/workflows/build-test.yml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -44,6 +44,7 @@ on:
4444
- '**/*.md'
4545
- 'CHANGELOG/**'
4646
- 'tests/build-backward-compatible/**'
47+
- 'scripts/generate_list_env_vars/**'
4748

4849
concurrency:
4950
group: ${{ github.workflow }}-${{ github.ref == github.ref_protected && github.run_id || github.event.pull_request.number || github.ref }}

ENV_VARIABLES.md

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -29,8 +29,8 @@
2929
| SE_HUB_PORT | 4444 | Hub config, port the Hub should listen on (default 4444) | --port |
3030
| SE_ROUTER_PORT | 4444 | Router config, port the Router should listen on (default 4444) | --port |
3131
| SE_NODE_GRID_GRAPHQL_URL | | Video recording config, GraphQL URL to query test metadata for dynamic file name | |
32-
| SE_VIDEO_FILE_NAME_TRIM_REGEX | [:alnum:]-_ | Bash regex to trim the file name if it is too long | |
33-
| SE_VIDEO_FILE_NAME_SUFFIX | | Append a suffix session id along with test metadata | |
32+
| SE_VIDEO_FILE_NAME_TRIM_REGEX | [^a-zA-Z0-9-_] | Python regex to trim the file name if it is too long | |
33+
| SE_VIDEO_FILE_NAME_SUFFIX | true | Append a suffix session id along with test metadata | |
3434
| SE_RCLONE_CONFIG | | | |
3535
| SE_UPLOAD_COMMAND | | | |
3636
| SE_UPLOAD_OPTS | | | |

README.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -639,7 +639,7 @@ If your test name is handled by the test framework, and it is unique for sure, y
639639

640640
File name will be trimmed to 255 characters to avoid long file names. Moreover, `space` character will be replaced by `_` and only characters alphabets, numbers, `-` (hyphen), `_` (underscore) are retained in the file name.
641641

642-
The trim regex is able to be customized by setting `SE_VIDEO_FILE_NAME_TRIM_REGEX` environment variable. The default value is `[:alnum:]-_`. The regex should be compatible with the `tr` command in bash.
642+
The trim regex is able to be customized by setting `SE_VIDEO_FILE_NAME_TRIM_REGEX` environment variable. The default value is `[^a-zA-Z0-9-_]`. The regex should be compatible with Python `re.compile()` function.
643643
644644
At deployment level, the recorder container is up always. In addition, you can disable video recording process via session capability `se:recordVideo`. For example in Python binding:
645645

Video/Dockerfile

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -44,7 +44,8 @@ ENV DISPLAY_NUM="99" \
4444
SE_PRESET="-preset ultrafast" \
4545
VIDEO_FOLDER="/videos" \
4646
SE_VIDEO_FILE_NAME="video.mp4" \
47-
SE_VIDEO_FILE_NAME_TRIM_REGEX="[:alnum:]-_" \
47+
SE_VIDEO_FILE_NAME_TRIM_REGEX="[^a-zA-Z0-9-_]" \
48+
SE_VIDEO_FILE_NAME_SUFFIX="true" \
4849
# Environment variables for the uploader
4950
RCLONE_CONFIG="/opt/selenium/upload.conf" \
5051
SE_VIDEO_UPLOAD_ENABLED="false" \

Video/video_nodeQuery.py

Lines changed: 7 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -4,8 +4,8 @@
44
import os
55
import re
66
import sys
7-
from typing import List, Tuple
87

8+
default_trim_pattern = "[^a-zA-Z0-9-_]"
99

1010
def main() -> None:
1111
"""
@@ -26,7 +26,7 @@ def main() -> None:
2626
video_cap_name = os.environ.get("VIDEO_CAP_NAME", "se:recordVideo")
2727
test_name_cap = os.environ.get("TEST_NAME_CAP", "se:name")
2828
video_name_cap = os.environ.get("VIDEO_NAME_CAP", "se:videoName")
29-
video_file_name_trim = os.environ.get("SE_VIDEO_FILE_NAME_TRIM_REGEX", "[:alnum:]-_")
29+
video_file_name_trim = os.environ.get("SE_VIDEO_FILE_NAME_TRIM_REGEX", default_trim_pattern)
3030
video_file_name_suffix = os.environ.get("SE_VIDEO_FILE_NAME_SUFFIX", "true")
3131

3232
# Initialize variables
@@ -79,7 +79,7 @@ def normalize_filename(filename: str, trim_pattern: str) -> str:
7979
8080
Args:
8181
filename: The original filename
82-
trim_pattern: Pattern defining allowed characters (e.g., "[:alnum:]-_")
82+
trim_pattern: Pattern defining allowed characters
8383
8484
Returns:
8585
Normalized filename
@@ -90,21 +90,10 @@ def normalize_filename(filename: str, trim_pattern: str) -> str:
9090
# Replace spaces with underscores
9191
normalized = filename.replace(" ", "_")
9292

93-
# Convert trim pattern to regex
94-
# Handle character classes like [:alnum:]
95-
posix_classes = {
96-
"[:alnum:]": "a-zA-Z0-9",
97-
"[:alpha:]": "a-zA-Z",
98-
"[:digit:]": "0-9",
99-
"[:space:]": " \t\n\r\f\v"
100-
}
101-
102-
allowed_chars = trim_pattern
103-
for posix_class, replacement in posix_classes.items():
104-
if posix_class in allowed_chars:
105-
allowed_chars = allowed_chars.replace(posix_class, replacement)
106-
107-
pattern = f"[^{re.escape(allowed_chars)}]"
93+
try:
94+
pattern = re.compile(trim_pattern)
95+
except re.error:
96+
pattern = re.compile(default_trim_pattern)
10897

10998
# Remove disallowed characters
11099
normalized = re.sub(pattern, "", normalized)

charts/selenium-grid/CONFIGURATION.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -672,6 +672,7 @@ A Helm chart for creating a Selenium Grid Server in Kubernetes
672672
| videoRecorder.uploader.configFileName | string | `"upload.conf"` | Uploader config file name |
673673
| videoRecorder.uploader.entryPointFileName | string | `"upload.sh"` | Uploader entry point file name |
674674
| videoRecorder.uploader.secrets | string | `nil` | For environment variables used in uploader which contains sensitive information, store in secret and refer envFrom Set config for rclone via ENV var with format: RCLONE_CONFIG_ + name of remote + _ + name of config file option (make it all uppercase) |
675+
| videoRecorder.uploader.extraEnvFrom | list | `[]` | Custom environment variables by sourcing entire configMap, Secret, etc. for uploader |
675676
| videoRecorder.ports | list | `[9000]` | Video recording container port |
676677
| videoRecorder.resources.requests | object | `{"cpu":"0.1","memory":"128Mi"}` | Request resources for video recorder pods |
677678
| videoRecorder.resources.limits | object | `{"cpu":"0.5","memory":"1Gi"}` | Limit resources for video recorder pods |

charts/selenium-grid/multiple-nodes-platform-version.yaml

Lines changed: 60 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,26 @@ crossBrowsers:
1313
hpa:
1414
platformName: 'Linux'
1515
browserVersion: ''
16+
- nameOverride: '{{ $.Release.Name }}-node-chrome-137'
17+
imageTag: '137.0-20250707'
18+
hpa:
19+
platformName: 'Linux'
20+
browserVersion: '137.0'
21+
- nameOverride: '{{ $.Release.Name }}-node-chrome-136'
22+
imageTag: '136.0-20250707'
23+
hpa:
24+
platformName: 'Linux'
25+
browserVersion: '136.0'
26+
- nameOverride: '{{ $.Release.Name }}-node-chrome-135'
27+
imageTag: '135.0-20250707'
28+
hpa:
29+
platformName: 'Linux'
30+
browserVersion: '135.0'
31+
- nameOverride: '{{ $.Release.Name }}-node-chrome-134'
32+
imageTag: '134.0-20250707'
33+
hpa:
34+
platformName: 'Linux'
35+
browserVersion: '134.0'
1636
- nameOverride: '{{ $.Release.Name }}-node-chrome-133'
1737
imageTag: '133.0-20250707'
1838
hpa:
@@ -204,6 +224,26 @@ crossBrowsers:
204224
hpa:
205225
platformName: 'Linux'
206226
browserVersion: ''
227+
- nameOverride: '{{ $.Release.Name }}-node-firefox-139'
228+
imageTag: '139.0-20250707'
229+
hpa:
230+
platformName: 'Linux'
231+
browserVersion: '139.0'
232+
- nameOverride: '{{ $.Release.Name }}-node-firefox-138'
233+
imageTag: '138.0-20250707'
234+
hpa:
235+
platformName: 'Linux'
236+
browserVersion: '138.0'
237+
- nameOverride: '{{ $.Release.Name }}-node-firefox-137'
238+
imageTag: '137.0-20250707'
239+
hpa:
240+
platformName: 'Linux'
241+
browserVersion: '137.0'
242+
- nameOverride: '{{ $.Release.Name }}-node-firefox-136'
243+
imageTag: '136.0-20250707'
244+
hpa:
245+
platformName: 'Linux'
246+
browserVersion: '136.0'
207247
- nameOverride: '{{ $.Release.Name }}-node-firefox-135'
208248
imageTag: '135.0-20250707'
209249
hpa:
@@ -400,6 +440,26 @@ crossBrowsers:
400440
hpa:
401441
platformName: 'Linux'
402442
browserVersion: ''
443+
- nameOverride: '{{ $.Release.Name }}-node-edge-137'
444+
imageTag: '137.0-20250707'
445+
hpa:
446+
platformName: 'Linux'
447+
browserVersion: '137.0'
448+
- nameOverride: '{{ $.Release.Name }}-node-edge-136'
449+
imageTag: '136.0-20250707'
450+
hpa:
451+
platformName: 'Linux'
452+
browserVersion: '136.0'
453+
- nameOverride: '{{ $.Release.Name }}-node-edge-135'
454+
imageTag: '135.0-20250707'
455+
hpa:
456+
platformName: 'Linux'
457+
browserVersion: '135.0'
458+
- nameOverride: '{{ $.Release.Name }}-node-edge-134'
459+
imageTag: '134.0-20250707'
460+
hpa:
461+
platformName: 'Linux'
462+
browserVersion: '134.0'
403463
- nameOverride: '{{ $.Release.Name }}-node-edge-133'
404464
imageTag: '133.0-20250707'
405465
hpa:

charts/selenium-grid/templates/_helpers.tpl

Lines changed: 17 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -450,6 +450,15 @@ template:
450450
{{- with .recorder.extraEnvFrom }}
451451
{{- tpl (toYaml .) $ | nindent 10 }}
452452
{{- end }}
453+
{{- if and .recorder.uploader.enabled (empty .recorder.uploader.name) }}
454+
{{- with $.Values.uploaderConfigMap.secretVolumeMountName }}
455+
- secretRef:
456+
name: {{ tpl . $ }}
457+
{{- end }}
458+
{{- with .recorder.uploader.extraEnvFrom }}
459+
{{- tpl (toYaml .) $ | nindent 10 }}
460+
{{- end }}
461+
{{- end }}
453462
{{- end }}
454463
ports:
455464
- containerPort: {{ .node.port }}
@@ -580,13 +589,20 @@ template:
580589
name: {{ template "seleniumGrid.recorder.configmap.fullname" $ }}
581590
- configMapRef:
582591
name: {{ template "seleniumGrid.server.configmap.fullname" $ }}
592+
- secretRef:
593+
name: {{ template "seleniumGrid.common.secrets.fullname" $ }}
583594
{{- if $.Values.basicAuth.enabled }}
584595
- secretRef:
585596
name: {{ template "seleniumGrid.basicAuth.secrets.fullname" $ }}
586597
{{- end }}
587598
{{- if and .recorder.uploader.enabled (empty .recorder.uploader.name) }}
599+
{{- with $.Values.uploaderConfigMap.secretVolumeMountName }}
588600
- secretRef:
589-
name: {{ tpl (default (include "seleniumGrid.common.secrets.fullname" $) $.Values.uploaderConfigMap.secretVolumeMountName) $ }}
601+
name: {{ tpl . $ }}
602+
{{- end }}
603+
{{- with .recorder.uploader.extraEnvFrom }}
604+
{{- tpl (toYaml .) $ | nindent 10 }}
605+
{{- end }}
590606
{{- end }}
591607
{{- with .recorder.extraEnvFrom }}
592608
{{- tpl (toYaml .) $ | nindent 10 }}

charts/selenium-grid/values.yaml

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1968,6 +1968,8 @@ videoRecorder:
19681968
# RCLONE_CONFIG_GS_SECRET_ACCESS_KEY: "xxx"
19691969
# RCLONE_CONFIG_GS_ENDPOINT: "https://storage.googleapis.com"
19701970
# RCLONE_CONFIG_GS_NO_CHECK_BUCKET: "true"
1971+
# -- Custom environment variables by sourcing entire configMap, Secret, etc. for uploader
1972+
extraEnvFrom: []
19711973
# -- Video recording container port
19721974
ports:
19731975
- 9000

scripts/generate_list_env_vars/description.yaml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -90,7 +90,7 @@
9090
file name
9191
cli: ''
9292
- name: SE_VIDEO_FILE_NAME_TRIM_REGEX
93-
description: Bash regex to trim the file name if it is too long
93+
description: Python regex to trim the file name if it is too long
9494
cli: ''
9595
- name: SE_VIDEO_FILE_NAME_SUFFIX
9696
description: Append a suffix session id along with test metadata

0 commit comments

Comments
 (0)