Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

K8s: Default Node register period is longer with a short cycle #2662

Merged
merged 1 commit into from
Feb 19, 2025
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
9 changes: 5 additions & 4 deletions ENV_VARIABLES.md
Original file line number Diff line number Diff line change
Expand Up @@ -72,13 +72,13 @@
| SE_VNC_NO_PASSWORD | | | |
| SE_VNC_VIEW_ONLY | | | |
| SE_VNC_PASSWORD | | | |
| SE_EVENT_BUS_PUBLISH_PORT | | | |
| SE_EVENT_BUS_SUBSCRIBE_PORT | | | |
| SE_EVENT_BUS_PUBLISH_PORT | 4442 | | |
| SE_EVENT_BUS_SUBSCRIBE_PORT | 4443 | | |
| SE_NODE_SESSION_TIMEOUT | 300 | | |
| SE_NODE_ENABLE_MANAGED_DOWNLOADS | | | |
| SE_NODE_ENABLE_CDP | | | |
| SE_NODE_REGISTER_PERIOD | | | |
| SE_NODE_REGISTER_CYCLE | | | |
| SE_NODE_REGISTER_PERIOD | 120 | | |
| SE_NODE_REGISTER_CYCLE | 10 | | |
| SE_NODE_HEARTBEAT_PERIOD | 30 | | |
| SE_REGISTRATION_SECRET | | | |
| SE_BROWSER_LEFTOVERS_PROCESSES_SECS | 7200 | | |
Expand Down Expand Up @@ -143,3 +143,4 @@
| SE_SESSIONS_MAP_EXTERNAL_SCHEME | | | |
| SE_NODE_RELAY_STEREOTYPE | | Capabilities in JSON string to overwrite the default Node relay stereotype | |
| SE_NODE_RELAY_STEREOTYPE_EXTRA | | Extra capabilities in JSON string that wants to merge to the default Node relay stereotype | |
| SE_NODE_REGISTER_SHUTDOWN_ON_FAILURE | true | If this flag is enabled, the Node will shut down after the register period is completed. This is useful for container environments to restart and register again. If restarted multiple times, the Node container status will be CrashLoopBackOff | --register-shutdown-on-failure |
5 changes: 5 additions & 0 deletions NodeBase/Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -38,12 +38,17 @@ ENV LANG_WHICH=${LANG_WHICH} \
#========================
# Selenium Configuration
#========================
SE_EVENT_BUS_PUBLISH_PORT="4442" \
SE_EVENT_BUS_SUBSCRIBE_PORT="4443" \
# Drain the Node after N sessions (a value higher than zero enables the feature)
SE_DRAIN_AFTER_SESSION_COUNT="0" \
SE_NODE_MAX_SESSIONS="1" \
SE_NODE_SESSION_TIMEOUT="300" \
SE_NODE_OVERRIDE_MAX_SESSIONS="false" \
SE_NODE_HEARTBEAT_PERIOD="30" \
SE_NODE_REGISTER_PERIOD="120" \
SE_NODE_REGISTER_CYCLE="10" \
SE_NODE_REGISTER_SHUTDOWN_ON_FAILURE="true" \
SE_OTEL_SERVICE_NAME="selenium-node" \
# Setting Selenium Manager to work offline
SE_OFFLINE="true" \
Expand Down
10 changes: 6 additions & 4 deletions NodeBase/generate_config
Original file line number Diff line number Diff line change
Expand Up @@ -14,10 +14,12 @@ else
FILENAME="$CONFIG_FILE"
fi

echo "[events]
publish = \"tcp://${SE_EVENT_BUS_HOST}:${SE_EVENT_BUS_PUBLISH_PORT}\"
subscribe = \"tcp://${SE_EVENT_BUS_HOST}:${SE_EVENT_BUS_SUBSCRIBE_PORT}\"
" >"$FILENAME"
if [[ -n "${SE_EVENT_BUS_HOST}" ]]; then
echo "[events]
publish = \"tcp://${SE_EVENT_BUS_HOST}:${SE_EVENT_BUS_PUBLISH_PORT}\"
subscribe = \"tcp://${SE_EVENT_BUS_HOST}:${SE_EVENT_BUS_SUBSCRIBE_PORT}\"
" >"$FILENAME"
fi

if [[ -z "${SE_NODE_HOST}" ]] && [[ -z "${SE_NODE_PORT}" ]]; then
echo "Configuring server..."
Expand Down
4 changes: 4 additions & 0 deletions NodeBase/start-selenium-node.sh
Original file line number Diff line number Diff line change
Expand Up @@ -69,6 +69,10 @@ if [ ! -z "$SE_NODE_REGISTER_CYCLE" ]; then
append_se_opts "--register-cycle" "${SE_NODE_REGISTER_CYCLE}"
fi

if [ "$SE_NODE_REGISTER_SHUTDOWN_ON_FAILURE" = "true" ]; then
append_se_opts "--register-shutdown-on-failure"
fi

if [ ! -z "$SE_NODE_HEARTBEAT_PERIOD" ]; then
append_se_opts "--heartbeat-period" "${SE_NODE_HEARTBEAT_PERIOD}"
fi
Expand Down
14 changes: 14 additions & 0 deletions charts/selenium-grid/CONFIGURATION.md
Original file line number Diff line number Diff line change
Expand Up @@ -49,6 +49,8 @@ A Helm chart for creating a Selenium Grid Server in Kubernetes
| global.seleniumGrid.affinity | object | `{}` | Specify affinity for all components, can be overridden individually |
| global.seleniumGrid.topologySpreadConstraints | list | `[]` | Specify topologySpreadConstraints for all components, can be overridden individually |
| global.seleniumGrid.nodeMaxSessions | int | `1` | Specify number of max sessions per node. Can be overridden by individual component (this is also set to scaler trigger parameter `nodeMaxSessions` if `autoscaling` is enabled) |
| global.seleniumGrid.nodeRegisterPeriod | int | `120` | How long, in seconds, will the Node try to register to the Distributor for the first time. After this period is completed, the Node will not attempt to register again. |
| global.seleniumGrid.nodeRegisterCycle | int | `5` | How often, in seconds, the Node will try to register itself for the first time to the Distributor. |
| tls.create | bool | `true` | Create a Secret resource for TLS certificate and key. If using an external secret set to false and provide its name in `nameOverride` below |
| tls.nameOverride | string | `nil` | Name of external secret containing the TLS certificate and key |
| tls.enabled | bool | `false` | Enable or disable TLS for the server components (and ingress proxy) |
Expand Down Expand Up @@ -454,13 +456,16 @@ A Helm chart for creating a Selenium Grid Server in Kubernetes
| chromeNode.extraVolumeMounts | list | `[]` | Extra volume mounts for chrome-node container |
| chromeNode.extraVolumes | list | `[]` | Extra volumes for chrome-node pod |
| chromeNode.nodeMaxSessions | string | `nil` | Override the number of max sessions per node |
| chromeNode.nodeRegisterPeriod | string | `nil` | Override the same config at the global level |
| chromeNode.nodeRegisterCycle | string | `nil` | Override the same config at the global level |
| chromeNode.scaledOptions | string | `nil` | Override the scaled options for chrome nodes |
| chromeNode.scaledJobOptions | string | `nil` | Override the scaledJobOptions for chrome nodes |
| chromeNode.scaledObjectOptions | string | `nil` | Override the scaledObjectOptions for chrome nodes |
| chromeNode.hpa.browserName | string | `"chrome"` | browserName should match with Node stereotype and request capability is scaled by this scaler |
| chromeNode.hpa.sessionBrowserName | string | `"chrome"` | sessionBrowserName if the browserName is different from the sessionBrowserName |
| chromeNode.hpa.browserVersion | string | `""` | browserVersion should match with Node stereotype and request capability is scaled by this scaler |
| chromeNode.hpa.platformName | string | `""` | platformName should match with Node stereotype and request capability is scaled by this scaler |
| chromeNode.hpa.capabilities | string | `""` | Setting more custom capabilities for matching specific Nodes |
| chromeNode.hpa.unsafeSsl | string | `"{{ template \"seleniumGrid.graphqlURL.unsafeSsl\" . }}"` | Skip check SSL when connecting to the Graphql endpoint |
| chromeNode.initContainers | list | `[]` | It is used to add initContainers in the same pod of the browser node. It should be set using the --set-json option |
| chromeNode.sidecars | list | `[]` | It is used to add sidecars proxy in the same pod of the browser node. It means it will add a new container to the deployment itself. It should be set using the --set-json option |
Expand Down Expand Up @@ -508,13 +513,16 @@ A Helm chart for creating a Selenium Grid Server in Kubernetes
| firefoxNode.extraVolumeMounts | list | `[]` | Extra volume mounts for firefox-node container |
| firefoxNode.extraVolumes | list | `[]` | Extra volumes for firefox-node pod |
| firefoxNode.nodeMaxSessions | string | `nil` | Override the number of max sessions per node |
| firefoxNode.nodeRegisterPeriod | string | `nil` | Override the same config at the global level |
| firefoxNode.nodeRegisterCycle | string | `nil` | Override the same config at the global level |
| firefoxNode.scaledOptions | string | `nil` | Override the scaled options for firefox nodes |
| firefoxNode.scaledJobOptions | string | `nil` | Override the scaledJobOptions for firefox nodes |
| firefoxNode.scaledObjectOptions | string | `nil` | Override the scaledObjectOptions for firefox nodes |
| firefoxNode.hpa.browserName | string | `"firefox"` | browserName should match with Node stereotype and request capability is scaled by this scaler |
| firefoxNode.hpa.sessionBrowserName | string | `"firefox"` | sessionBrowserName if the browserName is different from the sessionBrowserName |
| firefoxNode.hpa.browserVersion | string | `""` | browserVersion should match with Node stereotype and request capability is scaled by this scaler |
| firefoxNode.hpa.platformName | string | `""` | platformName should match with Node stereotype and request capability is scaled by this scaler |
| firefoxNode.hpa.capabilities | string | `""` | Setting more custom capabilities for matching specific Nodes |
| firefoxNode.hpa.unsafeSsl | string | `"{{ template \"seleniumGrid.graphqlURL.unsafeSsl\" . }}"` | Skip check SSL when connecting to the Graphql endpoint |
| firefoxNode.initContainers | list | `[]` | It is used to add initContainers in the same pod of the browser node. It should be set using the --set-json option |
| firefoxNode.sidecars | list | `[]` | It is used to add sidecars proxy in the same pod of the browser node. It means it will add a new container to the deployment itself. It should be set using the --set-json option |
Expand Down Expand Up @@ -562,13 +570,16 @@ A Helm chart for creating a Selenium Grid Server in Kubernetes
| edgeNode.extraVolumeMounts | list | `[]` | Extra volume mounts for edge-node container |
| edgeNode.extraVolumes | list | `[]` | Extra volumes for edge-node pod |
| edgeNode.nodeMaxSessions | string | `nil` | Override the number of max sessions per node |
| edgeNode.nodeRegisterPeriod | string | `nil` | Override the same config at the global level |
| edgeNode.nodeRegisterCycle | string | `nil` | Override the same config at the global level |
| edgeNode.scaledOptions | string | `nil` | Override the scaled options for edge nodes |
| edgeNode.scaledJobOptions | string | `nil` | Override the scaledJobOptions for edge nodes |
| edgeNode.scaledObjectOptions | string | `nil` | Override the scaledObjectOptions for edge nodes |
| edgeNode.hpa.browserName | string | `"MicrosoftEdge"` | browserName should match with Node stereotype and request capability is scaled by this scaler |
| edgeNode.hpa.sessionBrowserName | string | `"msedge"` | sessionBrowserName if the browserName is different from the sessionBrowserName |
| edgeNode.hpa.browserVersion | string | `""` | browserVersion should match with Node stereotype and request capability is scaled by this scaler |
| edgeNode.hpa.platformName | string | `""` | platformName should match with Node stereotype and request capability is scaled by this scaler |
| edgeNode.hpa.capabilities | string | `""` | Setting more custom capabilities for matching specific Nodes |
| edgeNode.hpa.unsafeSsl | string | `"{{ template \"seleniumGrid.graphqlURL.unsafeSsl\" . }}"` | Skip check SSL when connecting to the Graphql endpoint |
| edgeNode.initContainers | list | `[]` | It is used to add initContainers in the same pod of the browser node. It should be set using the --set-json option |
| edgeNode.sidecars | list | `[]` | It is used to add sidecars proxy in the same pod of the browser node. It means it will add a new container to the deployment itself. It should be set using the --set-json option |
Expand Down Expand Up @@ -616,13 +627,16 @@ A Helm chart for creating a Selenium Grid Server in Kubernetes
| relayNode.extraVolumeMounts | list | `[]` | Extra volume mounts for relay-node container |
| relayNode.extraVolumes | list | `[]` | Extra volumes for relay-node pod |
| relayNode.nodeMaxSessions | string | `nil` | Override the number of max sessions per node |
| relayNode.nodeRegisterPeriod | string | `nil` | Override the same config at the global level |
| relayNode.nodeRegisterCycle | string | `nil` | Override the same config at the global level |
| relayNode.scaledOptions | string | `nil` | Override the scaled options for relay nodes |
| relayNode.scaledJobOptions | string | `nil` | Override the scaledJobOptions for relay nodes |
| relayNode.scaledObjectOptions | string | `nil` | Override the scaledObjectOptions for relay nodes |
| relayNode.hpa.browserName | string | `"chrome"` | browserName should match with Node stereotype and request capability is scaled by this scaler |
| relayNode.hpa.sessionBrowserName | string | `""` | sessionBrowserName if the browserName is different from the sessionBrowserName |
| relayNode.hpa.browserVersion | string | `""` | browserVersion should match with Node stereotype and request capability is scaled by this scaler |
| relayNode.hpa.platformName | string | `"Android"` | platformName should match with Node stereotype and request capability is scaled by this scaler |
| relayNode.hpa.capabilities | string | `""` | Setting more custom capabilities for matching specific Nodes |
| relayNode.hpa.unsafeSsl | string | `"{{ template \"seleniumGrid.graphqlURL.unsafeSsl\" . }}"` | Skip check SSL when connecting to the Graphql endpoint |
| relayNode.initContainers | list | `[]` | It is used to add initContainers in the same pod of the browser node. It should be set using the --set-json option |
| relayNode.sidecars | list | `[]` | It is used to add sidecars proxy in the same pod of the browser node. It means it will add a new container to the deployment itself. It should be set using the --set-json option |
Expand Down
14 changes: 8 additions & 6 deletions charts/selenium-grid/templates/_helpers.tpl
Original file line number Diff line number Diff line change
Expand Up @@ -284,6 +284,8 @@ Common pod template
{{- $videoImageRegistry := default $.Values.global.seleniumGrid.imageRegistry .recorder.imageRegistry -}}
{{- $videoImageTag := default $.Values.global.seleniumGrid.videoImageTag .recorder.imageTag -}}
{{- $nodeMaxSessions := default $.Values.global.seleniumGrid.nodeMaxSessions .node.nodeMaxSessions | int64 -}}
{{- $nodeRegisterPeriod := default $.Values.global.seleniumGrid.nodeRegisterPeriod .node.nodeRegisterPeriod | int64 -}}
{{- $nodeRegisterCycle := default $.Values.global.seleniumGrid.nodeRegisterCycle .node.nodeRegisterCycle | int64 -}}
template:
metadata:
labels:
Expand Down Expand Up @@ -356,6 +358,10 @@ template:
{{- if and (eq (include "seleniumGrid.useKEDA" $) "true") }}
- name: SE_NODE_PLATFORM_NAME
value: {{ if hasKey .node.hpa "platformName" }}{{ .node.hpa.platformName | quote }}{{ else }}""{{ end }}
{{- end }}
{{- if and (eq (include "seleniumGrid.useKEDA" $) "true") }}
- name: SE_NODE_STEREOTYPE_EXTRA
value: {{ if hasKey .node.hpa "capabilities" }}{{ .node.hpa.capabilities | quote }}{{ else }}""{{ end }}
{{- end }}
- name: SE_NODE_CONTAINER_NAME
valueFrom:
Expand All @@ -373,14 +379,10 @@ template:
fieldPath: status.podIP
- name: SE_NODE_PORT
value: {{ .node.port | quote }}
{{- with .node.startupProbe.timeoutSeconds }}
- name: SE_NODE_REGISTER_PERIOD
value: {{ . | quote }}
{{- end }}
{{- with .node.startupProbe.periodSeconds }}
value: {{ $nodeRegisterPeriod | quote }}
- name: SE_NODE_REGISTER_CYCLE
value: {{ . | quote }}
{{- end }}
value: {{ $nodeRegisterCycle | quote }}
{{- with .node.extraEnvironmentVariables }}
{{- tpl (toYaml .) $ | nindent 10 }}
{{- end }}
Expand Down
28 changes: 28 additions & 0 deletions charts/selenium-grid/values.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -50,6 +50,10 @@ global:
# Note: If not define labelSelector, it will be added automatically based on "app" label in each component
# -- Specify number of max sessions per node. Can be overridden by individual component (this is also set to scaler trigger parameter `nodeMaxSessions` if `autoscaling` is enabled)
nodeMaxSessions: 1
# -- How long, in seconds, will the Node try to register to the Distributor for the first time. After this period is completed, the Node will not attempt to register again.
nodeRegisterPeriod: 120
# -- How often, in seconds, the Node will try to register itself for the first time to the Distributor.
nodeRegisterCycle: 5

tls:
# -- Create a Secret resource for TLS certificate and key. If using an external secret set to false and provide its name in `nameOverride` below
Expand Down Expand Up @@ -1259,6 +1263,10 @@ chromeNode:

# -- Override the number of max sessions per node
nodeMaxSessions:
# -- Override the same config at the global level
nodeRegisterPeriod:
# -- Override the same config at the global level
nodeRegisterCycle:
# -- Override the scaled options for chrome nodes
scaledOptions:
# -- Override the scaledJobOptions for chrome nodes
Expand All @@ -1274,6 +1282,8 @@ chromeNode:
browserVersion: ""
# -- platformName should match with Node stereotype and request capability is scaled by this scaler
platformName: ""
# -- Setting more custom capabilities for matching specific Nodes
capabilities: ""
# browserVersion: '91.0' # Optional. Only required when supporting multiple versions of browser in your Selenium Grid.
# -- Skip check SSL when connecting to the Graphql endpoint
unsafeSsl: '{{ template "seleniumGrid.graphqlURL.unsafeSsl" . }}' # Optional
Expand Down Expand Up @@ -1448,6 +1458,10 @@ firefoxNode:

# -- Override the number of max sessions per node
nodeMaxSessions:
# -- Override the same config at the global level
nodeRegisterPeriod:
# -- Override the same config at the global level
nodeRegisterCycle:
# -- Override the scaled options for firefox nodes
scaledOptions:
# -- Override the scaledJobOptions for firefox nodes
Expand All @@ -1463,6 +1477,8 @@ firefoxNode:
browserVersion: ""
# -- platformName should match with Node stereotype and request capability is scaled by this scaler
platformName: ""
# -- Setting more custom capabilities for matching specific Nodes
capabilities: ""
# -- Skip check SSL when connecting to the Graphql endpoint
unsafeSsl: '{{ template "seleniumGrid.graphqlURL.unsafeSsl" . }}' # Optional

Expand Down Expand Up @@ -1636,6 +1652,10 @@ edgeNode:

# -- Override the number of max sessions per node
nodeMaxSessions:
# -- Override the same config at the global level
nodeRegisterPeriod:
# -- Override the same config at the global level
nodeRegisterCycle:
# -- Override the scaled options for edge nodes
scaledOptions:
# -- Override the scaledJobOptions for edge nodes
Expand All @@ -1651,6 +1671,8 @@ edgeNode:
browserVersion: ""
# -- platformName should match with Node stereotype and request capability is scaled by this scaler
platformName: ""
# -- Setting more custom capabilities for matching specific Nodes
capabilities: ""
# -- Skip check SSL when connecting to the Graphql endpoint
unsafeSsl: '{{ template "seleniumGrid.graphqlURL.unsafeSsl" . }}' # Optional

Expand Down Expand Up @@ -1824,6 +1846,10 @@ relayNode:

# -- Override the number of max sessions per node
nodeMaxSessions:
# -- Override the same config at the global level
nodeRegisterPeriod:
# -- Override the same config at the global level
nodeRegisterCycle:
# -- Override the scaled options for relay nodes
scaledOptions:
# -- Override the scaledJobOptions for relay nodes
Expand All @@ -1839,6 +1865,8 @@ relayNode:
browserVersion: ""
# -- platformName should match with Node stereotype and request capability is scaled by this scaler
platformName: "Android"
# -- Setting more custom capabilities for matching specific Nodes
capabilities: ""
# -- Skip check SSL when connecting to the Graphql endpoint
unsafeSsl: '{{ template "seleniumGrid.graphqlURL.unsafeSsl" . }}' # Optional

Expand Down
6 changes: 6 additions & 0 deletions scripts/generate_list_env_vars/description.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -434,3 +434,9 @@
description: Extra capabilities in JSON string that wants to merge to the default
Node relay stereotype
cli: ''
- name: SE_NODE_REGISTER_SHUTDOWN_ON_FAILURE
description: If this flag is enabled, the Node will shut down after the register
period is completed. This is useful for container environments to restart and
register again. If restarted multiple times, the Node container status will be
CrashLoopBackOff
cli: --register-shutdown-on-failure
10 changes: 6 additions & 4 deletions scripts/generate_list_env_vars/value.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -31,9 +31,9 @@
- name: SE_EVENT_BUS_PORT
default: ''
- name: SE_EVENT_BUS_PUBLISH_PORT
default: ''
default: '4442'
- name: SE_EVENT_BUS_SUBSCRIBE_PORT
default: ''
default: '4443'
- name: SE_EXTERNAL_URL
default: ''
- name: SE_FRAME_RATE
Expand Down Expand Up @@ -107,9 +107,11 @@
- name: SE_NODE_PRESTOP_WAIT_STRATEGY
default: ''
- name: SE_NODE_REGISTER_CYCLE
default: ''
default: '10'
- name: SE_NODE_REGISTER_PERIOD
default: ''
default: '120'
- name: SE_NODE_REGISTER_SHUTDOWN_ON_FAILURE
default: 'true'
- name: SE_NODE_RELAY_BROWSER_NAME
default: ''
- name: SE_NODE_RELAY_MAX_SESSIONS
Expand Down
Loading