-
-
Notifications
You must be signed in to change notification settings - Fork 2.5k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat(chart): probe checks for Distributor and Router (#2272)
- Loading branch information
Showing
15 changed files
with
360 additions
and
25 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
39 changes: 39 additions & 0 deletions
39
charts/selenium-grid/configs/distributor/distributorProbe.sh
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,39 @@ | ||
#!/bin/bash | ||
|
||
max_time=3 | ||
retry_time=3 | ||
probe_name="Probe.${1:-"Liveness"}" | ||
ts_format=${SE_LOG_TIMESTAMP_FORMAT:-"+%T.%3N"} | ||
|
||
if [ -n "${ROUTER_USERNAME}" ] && [ -n "${ROUTER_PASSWORD}" ]; then | ||
BASIC_AUTH="${ROUTER_USERNAME}:${ROUTER_PASSWORD}@" | ||
fi | ||
|
||
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}}${SE_SUB_PATH}/graphql" | ||
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." | ||
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}) | ||
|
||
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}." | ||
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_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') | ||
|
||
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') | ||
|
||
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}" | ||
echo "$(date ${ts_format}) DEBUG [${probe_name}] - It seems the Distributor is delayed in processing a new session in the queue. Probe checks failed." | ||
exit 1 | ||
else | ||
echo "$(date ${ts_format}) DEBUG [${probe_name}] - Distributor is healthy." | ||
exit 0 | ||
fi |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,27 @@ | ||
#!/bin/bash | ||
|
||
max_time=3 | ||
retry_time=3 | ||
probe_name="Probe.${1:-"Liveness"}" | ||
ts_format=${SE_LOG_TIMESTAMP_FORMAT:-"+%T.%3N"} | ||
|
||
if [ -n "${ROUTER_USERNAME}" ] && [ -n "${ROUTER_PASSWORD}" ]; then | ||
BASIC_AUTH="${ROUTER_USERNAME}:${ROUTER_PASSWORD}@" | ||
fi | ||
|
||
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}}${SE_SUB_PATH}/graphql" | ||
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." | ||
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}) | ||
|
||
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}." | ||
exit 1 | ||
else | ||
echo "$(date ${ts_format}) DEBUG [${probe_name}] - GraphQL endpoint is healthy." | ||
exit 0 | ||
fi |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,31 @@ | ||
apiVersion: v1 | ||
kind: ConfigMap | ||
metadata: | ||
name: {{ template "seleniumGrid.distributor.configmap.fullname" $ }} | ||
namespace: {{ .Release.Namespace }} | ||
{{- with .Values.distributorConfigMap.annotations }} | ||
annotations: {{- toYaml . | nindent 4 }} | ||
{{- end }} | ||
labels: | ||
{{- include "seleniumGrid.commonLabels" . | nindent 4 }} | ||
{{- with .Values.customLabels }} | ||
{{- toYaml . | nindent 4 }} | ||
{{- end }} | ||
data: | ||
SE_GRID_GRAPHQL_URL: '{{ include "seleniumGrid.graphqlURL" $ }}' | ||
{{- $fileProceeded := list -}} | ||
{{- range $path, $_ := .Files.Glob $.Values.distributorConfigMap.extraScriptsImportFrom }} | ||
{{- $fileName := base $path -}} | ||
{{- $value := index $.Values.distributorConfigMap.extraScripts $fileName -}} | ||
{{- if empty $value }} | ||
{{- $fileName | nindent 2 -}}: {{- toYaml ($.Files.Get $path) | indent 4 }} | ||
{{- else }} | ||
{{- $fileName | nindent 2 -}}: {{- toYaml $value | indent 4 }} | ||
{{- end }} | ||
{{- $fileProceeded = append $fileProceeded $fileName -}} | ||
{{- end }} | ||
{{- range $fileName, $value := .Values.distributorConfigMap.extraScripts }} | ||
{{- if not (has $fileName $fileProceeded) }} | ||
{{- $fileName | nindent 2 -}}: {{- toYaml (default "" $value) | indent 4 }} | ||
{{- end }} | ||
{{- end }} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.