Skip to content

Commit c239ba5

Browse files
authored
K8s: Resilient Helm config to override SE_DRAIN_AFTER_SESSION_COUNT (#2902)
Signed-off-by: Viet Nguyen Duc <[email protected]> [skip ci]
1 parent 6118358 commit c239ba5

File tree

5 files changed

+23
-3
lines changed

5 files changed

+23
-3
lines changed

Makefile

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1004,7 +1004,7 @@ chart_test_autoscaling_disabled:
10041004
chart_test_autoscaling_deployment_https:
10051005
PLATFORMS=$(PLATFORMS) CHART_FULL_DISTRIBUTED_MODE=true CHART_ENABLE_BASIC_AUTH=true TEST_EXTERNAL_DATASTORE=postgresql TEST_MULTIPLE_VERSIONS=true AUTOSCALING_COOLDOWN_PERIOD=30 SELENIUM_GRID_MONITORING=false TEST_PATCHED_KEDA=$(TEST_PATCHED_KEDA) \
10061006
SECURE_INGRESS_ONLY_DEFAULT=true INGRESS_DISABLE_USE_HTTP2=true SELENIUM_GRID_PROTOCOL=https CHART_ENABLE_INGRESS_HOSTNAME=true SELENIUM_GRID_PORT=443 \
1007-
SELENIUM_GRID_AUTOSCALING_MIN_REPLICA=0 MAX_SESSIONS_FIREFOX=1 MAX_SESSIONS_EDGE=1 MAX_SESSIONS_CHROME=1 TEST_NAME_OVERRIDE=true \
1007+
SELENIUM_GRID_AUTOSCALING_MIN_REPLICA=0 MAX_SESSIONS_FIREFOX=1 MAX_SESSIONS_EDGE=1 MAX_SESSIONS_CHROME=1 TEST_NODE_DRAIN_AFTER_SESSION_COUNT=3 TEST_NAME_OVERRIDE=true \
10081008
VERSION=$(TAG_VERSION) VIDEO_TAG=$(FFMPEG_TAG_VERSION)-$(BUILD_DATE) KEDA_BASED_NAME=$(KEDA_BASED_NAME) KEDA_BASED_TAG=$(KEDA_BASED_TAG) NAMESPACE=$(NAMESPACE) BINDING_VERSION=$(BINDING_VERSION) BASE_VERSION=$(BASE_VERSION) \
10091009
TEMPLATE_OUTPUT_FILENAME="k8s_fullDistributed_basicAuth_secureIngress_defaultCerts_ingressHostName_disableHttp2_autoScaling_patchKEDA_scaledObject_subPath.yaml" \
10101010
./tests/charts/make/chart_test.sh DeploymentAutoscaling
@@ -1013,7 +1013,7 @@ chart_test_autoscaling_deployment:
10131013
PLATFORMS=$(PLATFORMS) TEST_EXISTING_KEDA=true RELEASE_NAME=selenium CHART_ENABLE_TRACING=true TEST_PATCHED_KEDA=$(TEST_PATCHED_KEDA) AUTOSCALING_COOLDOWN_PERIOD=30 \
10141014
TRACING_EXPORTER_ENDPOINT="http://\$$KUBERNETES_NODE_HOST_IP:4317" TEST_CUSTOM_SPECIFIC_NAME=true \
10151015
SECURE_CONNECTION_SERVER=true SECURE_USE_EXTERNAL_CERT=true SERVICE_TYPE_NODEPORT=true SELENIUM_GRID_PROTOCOL=https SELENIUM_GRID_HOST=$$(hostname -I | cut -d' ' -f1) SELENIUM_GRID_PORT=31444 \
1016-
SELENIUM_GRID_AUTOSCALING_MIN_REPLICA=1 SET_MAX_REPLICAS=3 TEST_DELAY_AFTER_TEST=2 SELENIUM_GRID_MONITORING=false \
1016+
SELENIUM_GRID_AUTOSCALING_MIN_REPLICA=1 SET_MAX_REPLICAS=3 TEST_DELAY_AFTER_TEST=2 TEST_NODE_DRAIN_AFTER_SESSION_COUNT=3 SELENIUM_GRID_MONITORING=false \
10171017
VERSION=$(TAG_VERSION) VIDEO_TAG=$(FFMPEG_TAG_VERSION)-$(BUILD_DATE) KEDA_BASED_NAME=$(KEDA_BASED_NAME) KEDA_BASED_TAG=$(KEDA_BASED_TAG) NAMESPACE=$(NAMESPACE) BINDING_VERSION=$(BINDING_VERSION) BASE_VERSION=$(BASE_VERSION) \
10181018
TEMPLATE_OUTPUT_FILENAME="k8s_prefixSelenium_enableTracing_secureServer_externalCerts_nodePort_autoScaling_scaledObject_existingKEDA_subPath.yaml" \
10191019
./tests/charts/make/chart_test.sh DeploymentAutoscaling

charts/selenium-grid/CONFIGURATION.md

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -50,6 +50,7 @@ A Helm chart for creating a Selenium Grid Server in Kubernetes
5050
| global.seleniumGrid.affinity | object | `{}` | Specify affinity for all components, can be overridden individually |
5151
| global.seleniumGrid.topologySpreadConstraints | list | `[]` | Specify topologySpreadConstraints for all components, can be overridden individually |
5252
| 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) |
53+
| global.seleniumGrid.nodeDrainAfterSessionCount | int | `0` | Set number of sessions will be executed in a Node before detaching it from Hub and shutting it down |
5354
| global.seleniumGrid.nodeEnableManagedDownloads | bool | `true` | This causes the Node to auto manage files downloaded for a given session on the Node (https://www.selenium.dev/documentation/webdriver/drivers/remote_webdriver/#enable-downloads-in-the-grid) |
5455
| global.seleniumGrid.nodeCustomCapabilities | string | `""` | Setting custom capabilities for matching specific Nodes (https://www.selenium.dev/documentation/grid/configuration/toml_options/#setting-custom-capabilities-for-matching-specific-nodes) |
5556
| 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. |
@@ -468,6 +469,7 @@ A Helm chart for creating a Selenium Grid Server in Kubernetes
468469
| chromeNode.extraVolumeMounts | list | `[]` | Extra volume mounts for chrome-node container |
469470
| chromeNode.extraVolumes | list | `[]` | Extra volumes for chrome-node pod |
470471
| chromeNode.nodeMaxSessions | string | `nil` | Override the number of max sessions per node |
472+
| chromeNode.nodeDrainAfterSessionCount | string | `nil` | Override the number of sessions to run before draining the node |
471473
| chromeNode.nodeEnableManagedDownloads | string | `nil` | Override the managed downloads in node |
472474
| chromeNode.nodeCustomCapabilities | string | `""` | Override the same config at the global level |
473475
| chromeNode.nodeRegisterPeriod | string | `nil` | Override the same config at the global level |
@@ -526,6 +528,7 @@ A Helm chart for creating a Selenium Grid Server in Kubernetes
526528
| firefoxNode.extraVolumeMounts | list | `[]` | Extra volume mounts for firefox-node container |
527529
| firefoxNode.extraVolumes | list | `[]` | Extra volumes for firefox-node pod |
528530
| firefoxNode.nodeMaxSessions | string | `nil` | Override the number of max sessions per node |
531+
| firefoxNode.nodeDrainAfterSessionCount | string | `nil` | Override the number of sessions to run before draining the node |
529532
| firefoxNode.nodeEnableManagedDownloads | string | `nil` | Override the managed downloads in node |
530533
| firefoxNode.nodeCustomCapabilities | string | `""` | Override the same config at the global level |
531534
| firefoxNode.nodeRegisterPeriod | string | `nil` | Override the same config at the global level |
@@ -584,6 +587,7 @@ A Helm chart for creating a Selenium Grid Server in Kubernetes
584587
| edgeNode.extraVolumeMounts | list | `[]` | Extra volume mounts for edge-node container |
585588
| edgeNode.extraVolumes | list | `[]` | Extra volumes for edge-node pod |
586589
| edgeNode.nodeMaxSessions | string | `nil` | Override the number of max sessions per node |
590+
| edgeNode.nodeDrainAfterSessionCount | string | `nil` | Override the number of sessions to run before draining the node |
587591
| edgeNode.nodeEnableManagedDownloads | string | `nil` | Override the managed downloads in node |
588592
| edgeNode.nodeCustomCapabilities | string | `""` | Override the same config at the global level |
589593
| edgeNode.nodeRegisterPeriod | string | `nil` | Override the same config at the global level |
@@ -643,6 +647,7 @@ A Helm chart for creating a Selenium Grid Server in Kubernetes
643647
| relayNode.extraVolumeMounts | list | `[]` | Extra volume mounts for relay-node container |
644648
| relayNode.extraVolumes | list | `[]` | Extra volumes for relay-node pod |
645649
| relayNode.nodeMaxSessions | string | `nil` | Override the number of max sessions per node |
650+
| relayNode.nodeDrainAfterSessionCount | string | `nil` | Override the number of sessions to run before draining the node |
646651
| relayNode.nodeEnableManagedDownloads | string | `nil` | Override the managed downloads in node |
647652
| relayNode.nodeCustomCapabilities | string | `""` | Override the same config at the global level |
648653
| relayNode.nodeRegisterPeriod | string | `nil` | Override the same config at the global level |

charts/selenium-grid/templates/_helpers.tpl

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -306,6 +306,7 @@ Common pod template
306306
{{- $videoImageRegistry := default $.Values.global.seleniumGrid.imageRegistry .recorder.imageRegistry -}}
307307
{{- $videoImageTag := default $.Values.global.seleniumGrid.videoImageTag .recorder.imageTag -}}
308308
{{- $nodeMaxSessions := default $.Values.global.seleniumGrid.nodeMaxSessions .node.nodeMaxSessions | int64 -}}
309+
{{- $nodeDrainAfterSessionCount := default $.Values.global.seleniumGrid.nodeDrainAfterSessionCount .node.nodeDrainAfterSessionCount | int64 -}}
309310
{{- $nodeEnableManagedDownloads := default $.Values.global.seleniumGrid.nodeEnableManagedDownloads .node.nodeEnableManagedDownloads -}}
310311
{{- $nodeCustomCapabilities := default $.Values.global.seleniumGrid.nodeCustomCapabilities .node.nodeCustomCapabilities -}}
311312
{{- $nodeRegisterPeriod := default $.Values.global.seleniumGrid.nodeRegisterPeriod .node.nodeRegisterPeriod | int64 -}}
@@ -379,7 +380,7 @@ template:
379380
- name: SE_NODE_STEREOTYPE_EXTRA
380381
value: {{ $nodeCustomCapabilities | quote }}
381382
- name: SE_DRAIN_AFTER_SESSION_COUNT
382-
value: {{ and (eq (include "seleniumGrid.useKEDA" $) "true") (eq .Values.autoscaling.scalingType "job") | ternary $nodeMaxSessions 0 | quote }}
383+
value: {{ and (eq (include "seleniumGrid.useKEDA" $) "true") (eq .Values.autoscaling.scalingType "job") | ternary (max $nodeMaxSessions $nodeDrainAfterSessionCount) $nodeDrainAfterSessionCount | quote }}
383384
{{- with .node.relayUrl }}
384385
- name: SE_NODE_RELAY_URL
385386
value: {{ . | quote }}

charts/selenium-grid/values.yaml

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -52,6 +52,10 @@ global:
5252
# Note: If not define labelSelector, it will be added automatically based on "app" label in each component
5353
# -- 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)
5454
nodeMaxSessions: 1
55+
# Noted:In case of autoscaling enabled, with scaling type `job`, Node will be drained following `nodeMaxSessions` by default
56+
# If changing `nodeDrainAfterSessionCount` > `nodeMaxSessions` it will take precedence over `nodeMaxSessions` in scaling type `job`
57+
# -- Set number of sessions will be executed in a Node before detaching it from Hub and shutting it down
58+
nodeDrainAfterSessionCount: 0
5559
# -- This causes the Node to auto manage files downloaded for a given session on the Node (https://www.selenium.dev/documentation/webdriver/drivers/remote_webdriver/#enable-downloads-in-the-grid)
5660
nodeEnableManagedDownloads: true
5761
# -- Setting custom capabilities for matching specific Nodes (https://www.selenium.dev/documentation/grid/configuration/toml_options/#setting-custom-capabilities-for-matching-specific-nodes)
@@ -1290,6 +1294,8 @@ chromeNode:
12901294

12911295
# -- Override the number of max sessions per node
12921296
nodeMaxSessions:
1297+
# -- Override the number of sessions to run before draining the node
1298+
nodeDrainAfterSessionCount:
12931299
# -- Override the managed downloads in node
12941300
nodeEnableManagedDownloads:
12951301
# -- Override the same config at the global level
@@ -1486,6 +1492,8 @@ firefoxNode:
14861492

14871493
# -- Override the number of max sessions per node
14881494
nodeMaxSessions:
1495+
# -- Override the number of sessions to run before draining the node
1496+
nodeDrainAfterSessionCount:
14891497
# -- Override the managed downloads in node
14901498
nodeEnableManagedDownloads:
14911499
# -- Override the same config at the global level
@@ -1682,6 +1690,8 @@ edgeNode:
16821690

16831691
# -- Override the number of max sessions per node
16841692
nodeMaxSessions:
1693+
# -- Override the number of sessions to run before draining the node
1694+
nodeDrainAfterSessionCount:
16851695
# -- Override the managed downloads in node
16861696
nodeEnableManagedDownloads:
16871697
# -- Override the same config at the global level
@@ -1879,6 +1889,8 @@ relayNode:
18791889

18801890
# -- Override the number of max sessions per node
18811891
nodeMaxSessions:
1892+
# -- Override the number of sessions to run before draining the node
1893+
nodeDrainAfterSessionCount:
18821894
# -- Override the managed downloads in node
18831895
nodeEnableManagedDownloads:
18841896
# -- Override the same config at the global level

tests/charts/make/chart_test.sh

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -54,6 +54,7 @@ else
5454
fi
5555
EXTERNAL_TLS_SECRET_NAME=${EXTERNAL_TLS_SECRET_NAME:-"external-tls-secret-${RESOURCE_ID}"}
5656
SELENIUM_ENABLE_MANAGED_DOWNLOADS=${SELENIUM_ENABLE_MANAGED_DOWNLOADS:-"true"}
57+
TEST_NODE_DRAIN_AFTER_SESSION_COUNT=${TEST_NODE_DRAIN_AFTER_SESSION_COUNT:-"0"}
5758
TEST_NODE_MAX_SESSIONS=${TEST_NODE_MAX_SESSIONS:-"1"}
5859
MAX_SESSIONS_CHROME=${MAX_SESSIONS_CHROME:-${TEST_NODE_MAX_SESSIONS}}
5960
MAX_SESSIONS_FIREFOX=${MAX_SESSIONS_FIREFOX:-${TEST_NODE_MAX_SESSIONS}}
@@ -184,6 +185,7 @@ HELM_COMMAND_SET_IMAGES=" \
184185
--set global.seleniumGrid.httpLogs=${CHART_ENABLE_TRACING} \
185186
--set isolateComponents=${CHART_FULL_DISTRIBUTED_MODE} \
186187
--set global.seleniumGrid.logLevel=${LOG_LEVEL} \
188+
--set global.seleniumGrid.nodeDrainAfterSessionCount=${TEST_NODE_DRAIN_AFTER_SESSION_COUNT} \
187189
--set chromeNode.nodeMaxSessions=${MAX_SESSIONS_CHROME} \
188190
--set firefoxNode.nodeMaxSessions=${MAX_SESSIONS_FIREFOX} \
189191
--set edgeNode.nodeMaxSessions=${MAX_SESSIONS_EDGE} \

0 commit comments

Comments
 (0)