diff --git a/ENV_VARIABLES.md b/ENV_VARIABLES.md index 4066c27845..f7646eac0e 100644 --- a/ENV_VARIABLES.md +++ b/ENV_VARIABLES.md @@ -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 | | | @@ -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 | diff --git a/NodeBase/Dockerfile b/NodeBase/Dockerfile index ad2e6f4ca5..18ad6dccb3 100644 --- a/NodeBase/Dockerfile +++ b/NodeBase/Dockerfile @@ -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" \ diff --git a/NodeBase/generate_config b/NodeBase/generate_config index e72377b1f1..aaa5c44997 100755 --- a/NodeBase/generate_config +++ b/NodeBase/generate_config @@ -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..." diff --git a/NodeBase/start-selenium-node.sh b/NodeBase/start-selenium-node.sh index 2b3241d661..db39862625 100755 --- a/NodeBase/start-selenium-node.sh +++ b/NodeBase/start-selenium-node.sh @@ -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 diff --git a/charts/selenium-grid/CONFIGURATION.md b/charts/selenium-grid/CONFIGURATION.md index 73b26ffee8..82e54e4a84 100644 --- a/charts/selenium-grid/CONFIGURATION.md +++ b/charts/selenium-grid/CONFIGURATION.md @@ -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) | @@ -454,6 +456,8 @@ 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 | @@ -461,6 +465,7 @@ A Helm chart for creating a Selenium Grid Server in Kubernetes | 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 | @@ -508,6 +513,8 @@ 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 | @@ -515,6 +522,7 @@ A Helm chart for creating a Selenium Grid Server in Kubernetes | 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 | @@ -562,6 +570,8 @@ 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 | @@ -569,6 +579,7 @@ A Helm chart for creating a Selenium Grid Server in Kubernetes | 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 | @@ -616,6 +627,8 @@ 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 | @@ -623,6 +636,7 @@ A Helm chart for creating a Selenium Grid Server in Kubernetes | 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 | diff --git a/charts/selenium-grid/templates/_helpers.tpl b/charts/selenium-grid/templates/_helpers.tpl index 92de53cabf..2c189b098a 100644 --- a/charts/selenium-grid/templates/_helpers.tpl +++ b/charts/selenium-grid/templates/_helpers.tpl @@ -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: @@ -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: @@ -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 }} diff --git a/charts/selenium-grid/values.yaml b/charts/selenium-grid/values.yaml index 267c1383d2..b99dbdfcce 100644 --- a/charts/selenium-grid/values.yaml +++ b/charts/selenium-grid/values.yaml @@ -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 @@ -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 @@ -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 @@ -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 @@ -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 @@ -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 @@ -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 @@ -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 @@ -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 diff --git a/scripts/generate_list_env_vars/description.yaml b/scripts/generate_list_env_vars/description.yaml index 43ee3edfc9..85eaf341b2 100644 --- a/scripts/generate_list_env_vars/description.yaml +++ b/scripts/generate_list_env_vars/description.yaml @@ -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 diff --git a/scripts/generate_list_env_vars/value.yaml b/scripts/generate_list_env_vars/value.yaml index 81038fabc8..bc36aec2b3 100644 --- a/scripts/generate_list_env_vars/value.yaml +++ b/scripts/generate_list_env_vars/value.yaml @@ -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 @@ -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