diff --git a/Base/Dockerfile b/Base/Dockerfile index 73b318fe9..f279ee83e 100644 --- a/Base/Dockerfile +++ b/Base/Dockerfile @@ -144,6 +144,7 @@ USER ${SEL_UID}:${SEL_GID} #====================================== # Boolean value, maps "--bind-host" ENV SE_BIND_HOST=false \ + SE_SERVER_PROTOCOL="http" \ # Boolean value, maps "--reject-unsupported-caps" SE_REJECT_UNSUPPORTED_CAPS=false \ SE_OTEL_JAVA_GLOBAL_AUTOCONFIGURE_ENABLED=true \ diff --git a/Hub/start-selenium-grid-hub.sh b/Hub/start-selenium-grid-hub.sh index 22010b9d2..5e30b3599 100755 --- a/Hub/start-selenium-grid-hub.sh +++ b/Hub/start-selenium-grid-hub.sh @@ -61,14 +61,14 @@ if [ ! -z "$SE_DISABLE_UI" ]; then SE_OPTS="$SE_OPTS --disable-ui ${SE_DISABLE_UI}" fi -if [ ! -z "$ROUTER_USERNAME" ]; then - echo "Appending Selenium options: --username ${ROUTER_USERNAME}" - SE_OPTS="$SE_OPTS --username ${ROUTER_USERNAME}" +if [ ! -z "$SE_ROUTER_USERNAME" ]; then + echo "Appending Selenium options: --username ${SE_ROUTER_USERNAME}" + SE_OPTS="$SE_OPTS --username ${SE_ROUTER_USERNAME}" fi -if [ ! -z "$ROUTER_PASSWORD" ]; then - echo "Appending Selenium options: --password ${ROUTER_PASSWORD}" - SE_OPTS="$SE_OPTS --password ${ROUTER_PASSWORD}" +if [ ! -z "$SE_ROUTER_PASSWORD" ]; then + echo "Appending Selenium options: --password ${SE_ROUTER_PASSWORD}" + SE_OPTS="$SE_OPTS --password ${SE_ROUTER_PASSWORD}" fi if [ ! -z "$SE_REJECT_UNSUPPORTED_CAPS" ]; then diff --git a/NodeBase/Dockerfile b/NodeBase/Dockerfile index 0e9145a28..ae6bfba47 100644 --- a/NodeBase/Dockerfile +++ b/NodeBase/Dockerfile @@ -50,8 +50,8 @@ ENV LANG_WHICH=${LANG_WHICH} \ #============================ # Some configuration options #============================ - SE_SCREEN_WIDTH=1360 \ - SE_SCREEN_HEIGHT=1020 \ + SE_SCREEN_WIDTH=1920 \ + SE_SCREEN_HEIGHT=1080 \ SE_SCREEN_DEPTH=24 \ SE_SCREEN_DPI=96 \ SE_START_XVFB=true \ diff --git a/README.md b/README.md index 23b4b5e78..9ac56ce7f 100644 --- a/README.md +++ b/README.md @@ -1065,7 +1065,7 @@ $ docker run -d -p 4444:4444 -e SE_SUB_PATH=/selenium-grid/ --name selenium-hub ### Setting Screen Resolution -By default, nodes start with a screen resolution of 1360 x 1020 with a color depth of 24 bits and a dpi of 96. +By default, nodes start with a screen resolution of 1920 x 1080 with a color depth of 24 bits and a dpi of 96. These settings can be adjusted by specifying `SE_SCREEN_WIDTH`, `SE_SCREEN_HEIGHT`, `SE_SCREEN_DEPTH`, and/or `SE_SCREEN_DPI` environmental variables when starting the container. diff --git a/Router/start-selenium-grid-router.sh b/Router/start-selenium-grid-router.sh index 757d57098..8f7f86ede 100755 --- a/Router/start-selenium-grid-router.sh +++ b/Router/start-selenium-grid-router.sh @@ -93,14 +93,14 @@ if [ ! -z "$SE_DISABLE_UI" ]; then SE_OPTS="$SE_OPTS --disable-ui ${SE_DISABLE_UI}" fi -if [ ! -z "$ROUTER_USERNAME" ]; then - echo "Appending Selenium options: --username ${ROUTER_USERNAME}" - SE_OPTS="$SE_OPTS --username ${ROUTER_USERNAME}" +if [ ! -z "$SE_ROUTER_USERNAME" ]; then + echo "Appending Selenium options: --username ${SE_ROUTER_USERNAME}" + SE_OPTS="$SE_OPTS --username ${SE_ROUTER_USERNAME}" fi -if [ ! -z "$ROUTER_PASSWORD" ]; then - echo "Appending Selenium options: --password ${ROUTER_PASSWORD}" - SE_OPTS="$SE_OPTS --password ${ROUTER_PASSWORD}" +if [ ! -z "$SE_ROUTER_PASSWORD" ]; then + echo "Appending Selenium options: --password ${SE_ROUTER_PASSWORD}" + SE_OPTS="$SE_OPTS --password ${SE_ROUTER_PASSWORD}" fi EXTRA_LIBS="" diff --git a/Standalone/start-selenium-standalone.sh b/Standalone/start-selenium-standalone.sh index 471238db4..bc578b351 100755 --- a/Standalone/start-selenium-standalone.sh +++ b/Standalone/start-selenium-standalone.sh @@ -26,14 +26,14 @@ if [ ! -z "$SE_DISABLE_UI" ]; then SE_OPTS="$SE_OPTS --disable-ui ${SE_DISABLE_UI}" fi -if [ ! -z "$ROUTER_USERNAME" ]; then - echo "Appending Selenium options: --username ${ROUTER_USERNAME}" - SE_OPTS="$SE_OPTS --username ${ROUTER_USERNAME}" +if [ ! -z "$SE_ROUTER_USERNAME" ]; then + echo "Appending Selenium options: --username ${SE_ROUTER_USERNAME}" + SE_OPTS="$SE_OPTS --username ${SE_ROUTER_USERNAME}" fi -if [ ! -z "$ROUTER_PASSWORD" ]; then - echo "Appending Selenium options: --password ${ROUTER_PASSWORD}" - SE_OPTS="$SE_OPTS --password ${ROUTER_PASSWORD}" +if [ ! -z "$SE_ROUTER_PASSWORD" ]; then + echo "Appending Selenium options: --password ${SE_ROUTER_PASSWORD}" + SE_OPTS="$SE_OPTS --password ${SE_ROUTER_PASSWORD}" fi if [ ! -z "$SE_NODE_ENABLE_MANAGED_DOWNLOADS" ]; then diff --git a/Video/Dockerfile b/Video/Dockerfile index a449247e1..9a79891e5 100755 --- a/Video/Dockerfile +++ b/Video/Dockerfile @@ -101,8 +101,9 @@ CMD ["/opt/bin/entry_point.sh"] ENV DISPLAY_NUM=99 \ DISPLAY_CONTAINER_NAME=selenium \ - SE_SCREEN_WIDTH=1360 \ - SE_SCREEN_HEIGHT=1020 \ + SE_SERVER_PROTOCOL="http" \ + SE_SCREEN_WIDTH=1920 \ + SE_SCREEN_HEIGHT=1080 \ SE_FRAME_RATE=15 \ SE_CODEC=libx264 \ SE_PRESET="-preset ultrafast" \ diff --git a/charts/selenium-grid/configs/distributor/distributorProbe.sh b/charts/selenium-grid/configs/distributor/distributorProbe.sh index 03c761af4..497874857 100644 --- a/charts/selenium-grid/configs/distributor/distributorProbe.sh +++ b/charts/selenium-grid/configs/distributor/distributorProbe.sh @@ -4,42 +4,27 @@ max_time=3 retry_time=3 probe_name="Probe.${1:-"Liveness"}" ts_format=${SE_LOG_TIMESTAMP_FORMAT:-"+%T.%3N"} +ROUTER_CONFIG_DIRECTORY=${ROUTER_CONFIG_DIRECTORY:-"/opt/selenium"} -if [ -n "${ROUTER_USERNAME}" ] && [ -n "${ROUTER_PASSWORD}" ]; then - BASIC_AUTH="${ROUTER_USERNAME}:${ROUTER_PASSWORD}@" -fi - -if [[ ${SE_SUB_PATH} == */ ]]; then - GRAPHQL_ENDPOINT="${SE_SUB_PATH}graphql" -else - GRAPHQL_ENDPOINT="${SE_SUB_PATH}/graphql" -fi - -if [[ ${GRAPHQL_ENDPOINT} == /* ]]; then - GRAPHQL_ENDPOINT="${GRAPHQL_ENDPOINT}" -else - GRAPHQL_ENDPOINT="/${GRAPHQL_ENDPOINT}" -fi +GRID_GRAPHQL_URL=$(bash ${ROUTER_CONFIG_DIRECTORY}/routerGraphQLUrl.sh) -if [ -z "${SE_GRID_GRAPHQL_URL}" ] && [ -n "${SE_HUB_HOST:-${SE_ROUTER_HOST}}" ] && [ -n "${SE_HUB_PORT:-${SE_ROUTER_PORT}}" ]; then - SE_GRID_GRAPHQL_URL="${SE_SERVER_PROTOCOL}://${BASIC_AUTH}${SE_HUB_HOST:-${SE_ROUTER_HOST}}:${SE_HUB_PORT:-${SE_ROUTER_PORT}}${GRAPHQL_ENDPOINT}" -elif [ -z "${SE_GRID_GRAPHQL_URL}" ]; then - echo "$(date ${ts_format}) DEBUG [${probe_name}] - Could not construct GraphQL endpoint, it can be set directly via SE_GRID_GRAPHQL_URL. Bypass the probe checks for now." +if [ -z "${GRID_GRAPHQL_URL}" ]; then + echo "$(date ${ts_format}) DEBUG [${probe_name}] - Could not construct GraphQL endpoint, please provide SE_HUB_HOST (or SE_ROUTER_HOST) and SE_HUB_PORT (or SE_ROUTER_PORT). Bypass the probe checks for now." exit 0 fi -GRAPHQL_PRE_CHECK=$(curl --noproxy "*" -m ${max_time} -k -X POST -H "Content-Type: application/json" --data '{"query":"{ grid { sessionCount } }"}' -s -o /dev/null -w "%{http_code}" ${SE_GRID_GRAPHQL_URL}) +GRAPHQL_PRE_CHECK=$(curl --noproxy "*" -m ${max_time} -k -X POST -H "Content-Type: application/json" --data '{"query":"{ grid { sessionCount } }"}' -s -o /dev/null -w "%{http_code}" ${GRID_GRAPHQL_URL}) if [ ${GRAPHQL_PRE_CHECK} -ne 200 ]; then - echo "$(date ${ts_format}) DEBUG [${probe_name}] - GraphQL endpoint ${SE_GRID_GRAPHQL_URL} is not reachable. Status code: ${GRAPHQL_PRE_CHECK}." + echo "$(date ${ts_format}) DEBUG [${probe_name}] - GraphQL endpoint ${GRID_GRAPHQL_URL} is not reachable. Status code: ${GRAPHQL_PRE_CHECK}." exit 1 fi -SESSION_QUEUE_SIZE=$(curl --noproxy "*" --retry ${retry_time} -m ${max_time} -k -X POST -H "Content-Type: application/json" --data '{"query":"{ grid { sessionQueueSize } }"}' -s ${SE_GRID_GRAPHQL_URL} | jq -r '.data.grid.sessionQueueSize') +SESSION_QUEUE_SIZE=$(curl --noproxy "*" --retry ${retry_time} -m ${max_time} -k -X POST -H "Content-Type: application/json" --data '{"query":"{ grid { sessionQueueSize } }"}' -s ${GRID_GRAPHQL_URL} | jq -r '.data.grid.sessionQueueSize') -SESSION_COUNT=$(curl --noproxy "*" --retry ${retry_time} -m ${max_time} -k -X POST -H "Content-Type: application/json" --data '{"query": "{ grid { sessionCount } }"}' -s ${SE_GRID_GRAPHQL_URL} | jq -r '.data.grid.sessionCount') +SESSION_COUNT=$(curl --noproxy "*" --retry ${retry_time} -m ${max_time} -k -X POST -H "Content-Type: application/json" --data '{"query": "{ grid { sessionCount } }"}' -s ${GRID_GRAPHQL_URL} | jq -r '.data.grid.sessionCount') -MAX_SESSION=$(curl --noproxy "*" --retry ${retry_time} -m ${max_time} -k -X POST -H "Content-Type: application/json" --data '{"query":"{ grid { maxSession } }"}' -s ${SE_GRID_GRAPHQL_URL} | jq -r '.data.grid.maxSession') +MAX_SESSION=$(curl --noproxy "*" --retry ${retry_time} -m ${max_time} -k -X POST -H "Content-Type: application/json" --data '{"query":"{ grid { maxSession } }"}' -s ${GRID_GRAPHQL_URL} | jq -r '.data.grid.maxSession') if [ ${SESSION_QUEUE_SIZE} -gt 0 ] && [ ${SESSION_COUNT} -eq 0 ]; then echo "$(date ${ts_format}) DEBUG [${probe_name}] - Session Queue Size: ${SESSION_QUEUE_SIZE}, Session Count: ${SESSION_COUNT}, Max Session: ${MAX_SESSION}" diff --git a/charts/selenium-grid/configs/node/nodeGridUrl.sh b/charts/selenium-grid/configs/node/nodeGridUrl.sh new file mode 100644 index 000000000..45ae465f6 --- /dev/null +++ b/charts/selenium-grid/configs/node/nodeGridUrl.sh @@ -0,0 +1,33 @@ +#!/bin/bash + +max_time=3 + +if [ -z "${SE_HUB_HOST:-$SE_ROUTER_HOST}" ] || [ -z "${SE_HUB_PORT:-$SE_ROUTER_PORT}" ]; then + grid_url="" +else + if [ -n "${SE_ROUTER_USERNAME}" ] && [ -n "${SE_ROUTER_PASSWORD}" ]; then + BASIC_AUTH="${SE_ROUTER_USERNAME}:${SE_ROUTER_PASSWORD}@" + fi + if [ "${SE_SUB_PATH}" = "/" ]; then + SE_SUB_PATH="" + fi + grid_url=${SE_SERVER_PROTOCOL}://${BASIC_AUTH}${SE_HUB_HOST:-$SE_ROUTER_HOST}:${SE_HUB_PORT:-$SE_ROUTER_PORT}${SE_SUB_PATH} +fi + +if [ -z "${grid_url}" ]; then + grid_url="${SE_NODE_GRID_URL}" +fi + +if [ -z "${grid_url}" ]; then + return 0 +fi + +grid_url_checks=$(curl --noproxy "*" -m ${max_time} -s -k -o /dev/null -w "%{http_code}" ${grid_url}) +if [ "${grid_url_checks}" = "401" ]; then + return ${grid_url_checks} +fi +if [ "${grid_url_checks}" = "404" ]; then + return ${grid_url_checks} +fi + +echo "${grid_url}" diff --git a/charts/selenium-grid/configs/node/nodePreStop.sh b/charts/selenium-grid/configs/node/nodePreStop.sh index 3e18215b4..0b62df9bf 100644 --- a/charts/selenium-grid/configs/node/nodePreStop.sh +++ b/charts/selenium-grid/configs/node/nodePreStop.sh @@ -1,6 +1,7 @@ #!/bin/bash probe_name="lifecycle.${1:-"preStop"}" +NODE_CONFIG_DIRECTORY=${NODE_CONFIG_DIRECTORY:-"/opt/selenium"} max_time=3 retry_time=5 @@ -26,53 +27,13 @@ else HEADERS="X-REGISTRATION-SECRET;" fi -function is_full_distributed_mode() { - if [ -n "${SE_DISTRIBUTOR_HOST}" ] && [ -n "${SE_DISTRIBUTOR_PORT}" ]; then - DISTRIBUTED_MODE=true - echo "$(date +%FT%T%Z) [${probe_name}] - Detected full distributed mode: ${DISTRIBUTED_MODE}. Since SE_DISTRIBUTOR_HOST and SE_DISTRIBUTOR_PORT are set in Node ConfigMap" - else - DISTRIBUTED_MODE=false - echo "$(date +%FT%T%Z) [${probe_name}] - Detected full distributed mode: ${DISTRIBUTED_MODE}" - fi -} -is_full_distributed_mode - -function get_grid_url() { - if [ -z "${SE_HUB_HOST:-$SE_ROUTER_HOST}" ] || [ -z "${SE_HUB_PORT:-$SE_ROUTER_PORT}" ]; then - echo "$(date +%FT%T%Z) [${probe_name}] - There is no configured HUB or ROUTER host. preStop ignores to send drain request to upstream." - grid_url="" - fi - if [ -n "${SE_BASIC_AUTH}" ] && [ "${SE_BASIC_AUTH}" != "*@" ]; then - SE_BASIC_AUTH="${SE_BASIC_AUTH}@" - fi - if [ "${SE_SUB_PATH}" = "/" ]; then - SE_SUB_PATH="" - fi - grid_url=${SE_SERVER_PROTOCOL}://${SE_BASIC_AUTH}${SE_HUB_HOST:-$SE_ROUTER_HOST}:${SE_HUB_PORT:-$SE_ROUTER_PORT}${SE_SUB_PATH} - grid_url_checks=$(curl --noproxy "*" -m ${max_time} -s -o /dev/null -w "%{http_code}" ${grid_url}) - if [ "${grid_url_checks}" = "401" ]; then - echo "$(date +%FT%T%Z) [${probe_name}] - Host requires Basic Auth. Please add the credentials to the SE_BASIC_AUTH variable (e.g: user:password). preStop ignores to send drain request to upstream." - grid_url="" - fi - if [ "${grid_url_checks}" = "404" ]; then - echo "$(date +%FT%T%Z) [${probe_name}] - The Grid is not available or it might have /subPath configured. Please wait a moment or check the SE_SUB_PATH variable if needed." - fi -} - -function signal_distributor_to_drain_node() { - if [ "${DISTRIBUTED_MODE}" = true ]; then - echo "$(date +%FT%T%Z) [${probe_name}] - Signaling Distributor to drain node" - curl --noproxy "*" -m ${max_time} -k -X POST ${SE_SERVER_PROTOCOL}://${SE_DISTRIBUTOR_HOST}:${SE_DISTRIBUTOR_PORT}/se/grid/distributor/node/${NODE_ID}/drain --header "${HEADERS}" - fi -} - function signal_hub_to_drain_node() { - if [ "${DISTRIBUTED_MODE}" = false ]; then - get_grid_url - if [ -n "${grid_url}" ]; then - echo "$(date +%FT%T%Z) [${probe_name}] - Signaling Hub to drain node" - curl --noproxy "*" -m ${max_time} -k -X POST ${grid_url}/se/grid/distributor/node/${NODE_ID}/drain --header "${HEADERS}" - fi + grid_url=$(bash ${NODE_CONFIG_DIRECTORY}/nodeGridUrl.sh) + if [ -n "${grid_url}" ]; then + echo "$(date +%FT%T%Z) [${probe_name}] - Signaling Hub/Router to drain node" + curl --noproxy "*" -m ${max_time} -k -X POST ${grid_url}/se/grid/distributor/node/${NODE_ID}/drain --header "${HEADERS}" + else + echo "$(date +%FT%T%Z) [${probe_name}] - There is no configured HUB/ROUTER host or SE_NODE_GRID_URL isn't set. preStop ignores to send drain request to upstream." fi } @@ -85,7 +46,6 @@ if curl --noproxy "*" -m ${max_time} -sfk ${SE_SERVER_PROTOCOL}://127.0.0.1:${SE NODE_ID=$(jq -r '.value.node.nodeId' ${tmp_node_file} || "") if [ -n "${NODE_ID}" ]; then echo "$(date +%FT%T%Z) [${probe_name}] - Current Node ID is: ${NODE_ID}" - signal_distributor_to_drain_node signal_hub_to_drain_node echo fi diff --git a/charts/selenium-grid/configs/node/nodeProbe.sh b/charts/selenium-grid/configs/node/nodeProbe.sh index 9af6814be..c7264ff5a 100644 --- a/charts/selenium-grid/configs/node/nodeProbe.sh +++ b/charts/selenium-grid/configs/node/nodeProbe.sh @@ -2,6 +2,7 @@ max_time=3 probe_name="Probe.${1:-"Startup"}" +NODE_CONFIG_DIRECTORY=${NODE_CONFIG_DIRECTORY:-"/opt/selenium"} ID=$(echo $RANDOM) tmp_node_file="/tmp/nodeProbe${ID}" @@ -23,31 +24,6 @@ function help_message() { echo "$(date +%FT%T%Z) [${probe_name}] - If you believe Node is registered successfully but probe still report this message and fail for a long time. Workaround by set 'global.seleniumGrid.defaultNodeStartupProbe' to 'httpGet' and report us an issue for Chart improvement with your scenario." } -function get_grid_url() { - if [ -z "${SE_HUB_HOST:-$SE_ROUTER_HOST}" ] || [ -z "${SE_HUB_PORT:-$SE_ROUTER_PORT}" ]; then - echo "$(date +%FT%T%Z) [${probe_name}] - There is no configured HUB or ROUTER host. Probe ignores the registration checks on upstream." - exit 0 - fi - if [[ -n "${SE_BASIC_AUTH}" && "${SE_BASIC_AUTH}" != *@ ]]; then - SE_BASIC_AUTH="${SE_BASIC_AUTH}@" - fi - if [ "${SE_SUB_PATH}" = "/" ]; then - SE_SUB_PATH="" - fi - grid_url=${SE_SERVER_PROTOCOL}://${SE_BASIC_AUTH}${SE_HUB_HOST:-$SE_ROUTER_HOST}:${SE_HUB_PORT:-$SE_ROUTER_PORT}${SE_SUB_PATH} - grid_url_checks=$(curl --noproxy "*" -m ${max_time} -skf -o /dev/null -w "%{http_code}" ${grid_url}) - if [ "${grid_url_checks}" = "401" ]; then - echo "$(date +%FT%T%Z) [${probe_name}] - Host requires Basic Auth. Please add the credentials to the SE_BASIC_AUTH variable (e.g: user:password)." - help_message - exit 1 - fi - if [ "${grid_url_checks}" = "404" ]; then - echo "$(date +%FT%T%Z) [${probe_name}] - The Grid is not available or it might have /subPath configured. Please wait a moment or check the SE_SUB_PATH variable if needed." - help_message - exit 1 - fi -} - if curl --noproxy "*" -m ${max_time} -sfk ${SE_SERVER_PROTOCOL}://127.0.0.1:${SE_NODE_PORT}/status -o ${tmp_node_file}; then NODE_ID=$(jq -r '.value.node.nodeId' ${tmp_node_file} || "") NODE_STATUS=$(jq -r '.value.node.availability' ${tmp_node_file} || "") @@ -58,7 +34,7 @@ if curl --noproxy "*" -m ${max_time} -sfk ${SE_SERVER_PROTOCOL}://127.0.0.1:${SE exit 1 fi - get_grid_url + grid_url=$(bash ${NODE_CONFIG_DIRECTORY}/nodeGridUrl.sh) curl --noproxy "*" -m ${max_time} -sfk "${grid_url}/status" -o ${tmp_grid_file} GRID_NODE_ID=$(jq -e ".value.nodes[].id|select(. == \"${NODE_ID}\")" ${tmp_grid_file} | tr -d '"' || "") diff --git a/charts/selenium-grid/configs/router/routerGraphQLUrl.sh b/charts/selenium-grid/configs/router/routerGraphQLUrl.sh new file mode 100644 index 000000000..c9c2712a2 --- /dev/null +++ b/charts/selenium-grid/configs/router/routerGraphQLUrl.sh @@ -0,0 +1,25 @@ +#!/bin/bash + +if [ -z "${SE_HUB_HOST:-$SE_ROUTER_HOST}" ] || [ -z "${SE_HUB_PORT:-$SE_ROUTER_PORT}" ]; then + graphql_url="" +else + if [ -n "${SE_ROUTER_USERNAME}" ] && [ -n "${SE_ROUTER_PASSWORD}" ]; then + BASIC_AUTH="${SE_ROUTER_USERNAME}:${SE_ROUTER_PASSWORD}@" + fi + + if [[ ${SE_SUB_PATH} == */ ]]; then + GRAPHQL_ENDPOINT="${SE_SUB_PATH}graphql" + else + GRAPHQL_ENDPOINT="${SE_SUB_PATH}/graphql" + fi + + if [[ ${GRAPHQL_ENDPOINT} == /* ]]; then + GRAPHQL_ENDPOINT="${GRAPHQL_ENDPOINT}" + else + GRAPHQL_ENDPOINT="/${GRAPHQL_ENDPOINT}" + fi + + graphql_url="${SE_SERVER_PROTOCOL}://${BASIC_AUTH}${SE_HUB_HOST:-${SE_ROUTER_HOST}}:${SE_HUB_PORT:-${SE_ROUTER_PORT}}${GRAPHQL_ENDPOINT}" +fi + +echo "${graphql_url}" diff --git a/charts/selenium-grid/configs/router/routerProbe.sh b/charts/selenium-grid/configs/router/routerProbe.sh index d95217e40..7ee8f6ad1 100644 --- a/charts/selenium-grid/configs/router/routerProbe.sh +++ b/charts/selenium-grid/configs/router/routerProbe.sh @@ -4,34 +4,19 @@ max_time=3 retry_time=3 probe_name="Probe.${1:-"Liveness"}" ts_format=${SE_LOG_TIMESTAMP_FORMAT:-"+%T.%3N"} +ROUTER_CONFIG_DIRECTORY=${ROUTER_CONFIG_DIRECTORY:-"/opt/selenium"} -if [ -n "${ROUTER_USERNAME}" ] && [ -n "${ROUTER_PASSWORD}" ]; then - BASIC_AUTH="${ROUTER_USERNAME}:${ROUTER_PASSWORD}@" -fi - -if [[ ${SE_SUB_PATH} == */ ]]; then - GRAPHQL_ENDPOINT="${SE_SUB_PATH}graphql" -else - GRAPHQL_ENDPOINT="${SE_SUB_PATH}/graphql" -fi - -if [[ ${GRAPHQL_ENDPOINT} == /* ]]; then - GRAPHQL_ENDPOINT="${GRAPHQL_ENDPOINT}" -else - GRAPHQL_ENDPOINT="/${GRAPHQL_ENDPOINT}" -fi +GRID_GRAPHQL_URL=$(bash ${ROUTER_CONFIG_DIRECTORY}/routerGraphQLUrl.sh) -if [ -z "${SE_GRID_GRAPHQL_URL}" ] && [ -n "${SE_HUB_HOST:-${SE_ROUTER_HOST}}" ] && [ -n "${SE_HUB_PORT:-${SE_ROUTER_PORT}}" ]; then - SE_GRID_GRAPHQL_URL="${SE_SERVER_PROTOCOL}://${BASIC_AUTH}${SE_HUB_HOST:-${SE_ROUTER_HOST}}:${SE_HUB_PORT:-${SE_ROUTER_PORT}}${GRAPHQL_ENDPOINT}" -elif [ -z "${SE_GRID_GRAPHQL_URL}" ]; then - echo "$(date ${ts_format}) DEBUG [${probe_name}] - Could not construct GraphQL endpoint, it can be set directly via SE_GRID_GRAPHQL_URL. Bypass the probe checks for now." +if [ -z "${GRID_GRAPHQL_URL}" ]; then + echo "$(date ${ts_format}) DEBUG [${probe_name}] - Could not construct GraphQL endpoint, please provide SE_HUB_HOST (or SE_ROUTER_HOST) and SE_HUB_PORT (or SE_ROUTER_PORT). Bypass the probe checks for now." exit 0 fi -GRAPHQL_PRE_CHECK=$(curl --noproxy "*" -m ${max_time} -k -X POST -H "Content-Type: application/json" --data '{"query":"{ grid { sessionCount } }"}' -s -o /dev/null -w "%{http_code}" ${SE_GRID_GRAPHQL_URL}) +GRAPHQL_PRE_CHECK=$(curl --noproxy "*" -m ${max_time} -k -X POST -H "Content-Type: application/json" --data '{"query":"{ grid { sessionCount } }"}' -s -o /dev/null -w "%{http_code}" ${GRID_GRAPHQL_URL}) if [ ${GRAPHQL_PRE_CHECK} -ne 200 ]; then - echo "$(date ${ts_format}) DEBUG [${probe_name}] - GraphQL endpoint ${SE_GRID_GRAPHQL_URL} is not reachable. Status code: ${GRAPHQL_PRE_CHECK}." + echo "$(date ${ts_format}) DEBUG [${probe_name}] - GraphQL endpoint is not reachable. Status code: ${GRAPHQL_PRE_CHECK}." exit 1 else echo "$(date ${ts_format}) DEBUG [${probe_name}] - GraphQL endpoint is healthy." diff --git a/charts/selenium-grid/templates/distributor-configmap.yaml b/charts/selenium-grid/templates/distributor-configmap.yaml index 0aea7d9dc..ede4aaf09 100644 --- a/charts/selenium-grid/templates/distributor-configmap.yaml +++ b/charts/selenium-grid/templates/distributor-configmap.yaml @@ -12,7 +12,6 @@ metadata: {{- toYaml . | nindent 4 }} {{- end }} data: - SE_GRID_GRAPHQL_URL: '{{ include "seleniumGrid.graphqlURL" $ }}' {{- $fileProceeded := list -}} {{- range $path, $_ := .Files.Glob $.Values.distributorConfigMap.extraScriptsImportFrom }} {{- $fileName := base $path -}} diff --git a/charts/selenium-grid/templates/distributor-deployment.yaml b/charts/selenium-grid/templates/distributor-deployment.yaml index 5f22ac6fe..d1431f6a0 100644 --- a/charts/selenium-grid/templates/distributor-deployment.yaml +++ b/charts/selenium-grid/templates/distributor-deployment.yaml @@ -25,6 +25,7 @@ spec: checksum/logging-configmap: {{ include (print $.Template.BasePath "/logging-configmap.yaml") . | sha256sum }} checksum/server-configmap: {{ include (print $.Template.BasePath "/server-configmap.yaml") . | sha256sum }} checksum/distributor-configmap: {{ include (print $.Template.BasePath "/distributor-configmap.yaml") . | sha256sum }} + checksum/router-configmap: {{ include (print $.Template.BasePath "/router-configmap.yaml") . | sha256sum }} checksum/secrets: {{ include (print $.Template.BasePath "/secrets.yaml") . | sha256sum }} {{- with .Values.components.distributor.annotations }} {{- toYaml . | nindent 8 }} @@ -45,6 +46,10 @@ spec: value: '{{ template "seleniumGrid.distributor.fullname" . }}.{{ .Release.Namespace }}' - name: SE_DISTRIBUTOR_PORT value: {{ .Values.components.distributor.port | quote }} + - name: SE_ROUTER_HOST + value: '{{ template "seleniumGrid.router.fullname" . }}.{{ .Release.Namespace }}' + - name: SE_ROUTER_PORT + value: {{ .Values.components.router.port | quote }} - name: SE_SESSIONS_MAP_HOST value: '{{ template "seleniumGrid.sessionMap.fullname" . }}.{{ .Release.Namespace }}' - name: SE_SESSIONS_MAP_PORT @@ -66,6 +71,8 @@ spec: envFrom: - configMapRef: name: {{ template "seleniumGrid.distributor.configmap.fullname" . }} + - configMapRef: + name: {{ template "seleniumGrid.router.configmap.fullname" . }} - configMapRef: name: {{ template "seleniumGrid.eventBus.configmap.fullname" . }} - configMapRef: @@ -83,6 +90,11 @@ spec: mountPath: {{ $.Values.distributorConfigMap.extraScriptsDirectory }}/{{ $fileName }} subPath: {{ $fileName }} {{- end }} + {{- range $fileName, $value := $.Values.routerConfigMap.extraScripts }} + - name: {{ tpl (default (include "seleniumGrid.router.configmap.fullname" $) $.Values.routerConfigMap.scriptVolumeMountName) $ | quote }} + mountPath: {{ $.Values.routerConfigMap.extraScriptsDirectory }}/{{ $fileName }} + subPath: {{ $fileName }} + {{- end }} {{- if eq (include "seleniumGrid.server.secureConnection" $) "true" }} - name: {{ include "seleniumGrid.tls.fullname" . | quote }} mountPath: {{ .Values.tls.certVolumeMountPath | quote }} @@ -170,6 +182,10 @@ spec: configMap: name: {{ template "seleniumGrid.distributor.configmap.fullname" $ }} defaultMode: {{ $.Values.distributorConfigMap.defaultMode }} + - name: {{ tpl (default (include "seleniumGrid.router.configmap.fullname" $) $.Values.routerConfigMap.scriptVolumeMountName) $ | quote }} + configMap: + name: {{ template "seleniumGrid.router.configmap.fullname" $ }} + defaultMode: {{ $.Values.routerConfigMap.defaultMode }} {{- if eq (include "seleniumGrid.server.secureConnection" $) "true" }} - name: {{ include "seleniumGrid.tls.fullname" . | quote }} secret: diff --git a/charts/selenium-grid/templates/hub-deployment.yaml b/charts/selenium-grid/templates/hub-deployment.yaml index dc4363a84..b7393174f 100644 --- a/charts/selenium-grid/templates/hub-deployment.yaml +++ b/charts/selenium-grid/templates/hub-deployment.yaml @@ -27,6 +27,7 @@ spec: checksum/logging-configmap: {{ include (print $.Template.BasePath "/logging-configmap.yaml") . | sha256sum }} checksum/server-configmap: {{ include (print $.Template.BasePath "/server-configmap.yaml") . | sha256sum }} checksum/distributor-configmap: {{ include (print $.Template.BasePath "/distributor-configmap.yaml") . | sha256sum }} + checksum/router-configmap: {{ include (print $.Template.BasePath "/router-configmap.yaml") . | sha256sum }} checksum/secrets: {{ include (print $.Template.BasePath "/secrets.yaml") . | sha256sum }} checksum/tls-cert-secret: {{ include (print $.Template.BasePath "/tls-cert-secret.yaml") . | sha256sum }} {{- with .Values.hub.annotations }} @@ -127,6 +128,8 @@ spec: envFrom: - configMapRef: name: {{ template "seleniumGrid.distributor.configmap.fullname" . }} + - configMapRef: + name: {{ template "seleniumGrid.router.configmap.fullname" . }} - configMapRef: name: {{ template "seleniumGrid.logging.configmap.fullname" . }} - configMapRef: @@ -142,6 +145,11 @@ spec: mountPath: {{ $.Values.distributorConfigMap.extraScriptsDirectory }}/{{ $fileName }} subPath: {{ $fileName }} {{- end }} + {{- range $fileName, $value := $.Values.routerConfigMap.extraScripts }} + - name: {{ tpl (default (include "seleniumGrid.router.configmap.fullname" $) $.Values.routerConfigMap.scriptVolumeMountName) $ | quote }} + mountPath: {{ $.Values.routerConfigMap.extraScriptsDirectory }}/{{ $fileName }} + subPath: {{ $fileName }} + {{- end }} {{- if eq (include "seleniumGrid.server.secureConnection" $) "true" }} - name: {{ include "seleniumGrid.tls.fullname" . | quote }} mountPath: {{ .Values.tls.certVolumeMountPath | quote }} @@ -178,6 +186,10 @@ spec: configMap: name: {{ template "seleniumGrid.distributor.configmap.fullname" $ }} defaultMode: {{ $.Values.distributorConfigMap.defaultMode }} + - name: {{ tpl (default (include "seleniumGrid.router.configmap.fullname" $) $.Values.routerConfigMap.scriptVolumeMountName) $ | quote }} + configMap: + name: {{ template "seleniumGrid.router.configmap.fullname" $ }} + defaultMode: {{ $.Values.routerConfigMap.defaultMode }} {{- if eq (include "seleniumGrid.server.secureConnection" $) "true" }} - name: {{ include "seleniumGrid.tls.fullname" . | quote }} secret: diff --git a/charts/selenium-grid/templates/node-configmap.yaml b/charts/selenium-grid/templates/node-configmap.yaml index 24709c623..7a61a8903 100644 --- a/charts/selenium-grid/templates/node-configmap.yaml +++ b/charts/selenium-grid/templates/node-configmap.yaml @@ -21,7 +21,7 @@ data: SE_HUB_HOST: '{{ include "seleniumGrid.hub.fullname" . }}.{{ .Release.Namespace }}' SE_HUB_PORT: '{{ .Values.hub.port }}' {{- end }} - SE_BASIC_AUTH: '{{ template "seleniumGrid.url.basicAuth" $ }}' + NODE_CONFIG_DIRECTORY: '{{ $.Values.nodeConfigMap.extraScriptsDirectory }}' SE_SUB_PATH: '{{ template "seleniumGrid.url.subPath" $ }}' SE_DRAIN_AFTER_SESSION_COUNT: '{{- and (eq (include "seleniumGrid.useKEDA" .) "true") (eq .Values.autoscaling.scalingType "job") | ternary "1" "0" -}}' SE_NODE_GRID_URL: '{{ include "seleniumGrid.url" $ }}' diff --git a/charts/selenium-grid/templates/router-configmap.yaml b/charts/selenium-grid/templates/router-configmap.yaml index bb8ec158a..11ffe9809 100644 --- a/charts/selenium-grid/templates/router-configmap.yaml +++ b/charts/selenium-grid/templates/router-configmap.yaml @@ -12,6 +12,7 @@ metadata: {{- toYaml . | nindent 4 }} {{- end }} data: + ROUTER_CONFIG_DIRECTORY: '{{ $.Values.routerConfigMap.extraScriptsDirectory }}' {{- $fileProceeded := list -}} {{- range $path, $_ := .Files.Glob $.Values.routerConfigMap.extraScriptsImportFrom }} {{- $fileName := base $path -}} diff --git a/charts/selenium-grid/templates/secrets.yaml b/charts/selenium-grid/templates/secrets.yaml index f3f8038a1..6510a7f1e 100644 --- a/charts/selenium-grid/templates/secrets.yaml +++ b/charts/selenium-grid/templates/secrets.yaml @@ -21,8 +21,8 @@ data: {{- end }} {{- end }} {{- if eq .Values.basicAuth.enabled true }} - ROUTER_USERNAME: {{ .Values.basicAuth.username | b64enc }} - ROUTER_PASSWORD: {{ .Values.basicAuth.password | b64enc }} + SE_ROUTER_USERNAME: {{ .Values.basicAuth.username | b64enc }} + SE_ROUTER_PASSWORD: {{ .Values.basicAuth.password | b64enc }} {{- end }} {{- with $.Values.tls.trustStorePassword }} SE_JAVA_SSL_TRUST_STORE_PASSWORD: {{ . | b64enc }} diff --git a/charts/selenium-grid/templates/session-queuer-deployment.yaml b/charts/selenium-grid/templates/session-queue-deployment.yaml similarity index 100% rename from charts/selenium-grid/templates/session-queuer-deployment.yaml rename to charts/selenium-grid/templates/session-queue-deployment.yaml diff --git a/charts/selenium-grid/templates/session-queuer-service.yaml b/charts/selenium-grid/templates/session-queue-service.yaml similarity index 100% rename from charts/selenium-grid/templates/session-queuer-service.yaml rename to charts/selenium-grid/templates/session-queue-service.yaml diff --git a/charts/selenium-grid/values.yaml b/charts/selenium-grid/values.yaml index f68d1ff08..12a10fd8e 100644 --- a/charts/selenium-grid/values.yaml +++ b/charts/selenium-grid/values.yaml @@ -177,6 +177,7 @@ routerConfigMap: # Directory where the extra scripts are mounted to extraScriptsDirectory: "/opt/selenium" extraScripts: + routerGraphQLUrl.sh: "" routerProbe.sh: "" # Name of volume mount is used to mount scripts in the ConfigMap scriptVolumeMountName: @@ -193,6 +194,7 @@ nodeConfigMap: # Directory where the extra scripts are mounted to extraScriptsDirectory: "/opt/selenium" extraScripts: + nodeGridUrl.sh: "" nodePreStop.sh: "" nodeProbe.sh: "" # Name of volume mount is used to mount scripts in the ConfigMap