Skip to content

Commit 6c4f76e

Browse files
authored
chart(add): Grid scaler use trigger auth to secure GraphQL endpoint (#2401)
* chart(add): Grid scaler use trigger auth to secure GraphQL endpoint Signed-off-by: Viet Nguyen Duc <[email protected]> * chart(update): remove basic auth credential in grid URL Signed-off-by: Viet Nguyen Duc <[email protected]> --------- Signed-off-by: Viet Nguyen Duc <[email protected]>
1 parent 91969c0 commit 6c4f76e

28 files changed

+242
-93
lines changed

Diff for: Base/check-grid.sh

+2-1
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,7 @@ set -e
55

66
HOST="localhost"
77
PORT="4444"
8+
BASIC_AUTH="$(echo -n "${SE_ROUTER_USERNAME}:${SE_ROUTER_PASSWORD}" | base64)"
89

910
echoerr() { echo "$@" 1>&2; }
1011

@@ -26,4 +27,4 @@ while [[ $# -gt 0 ]]; do
2627
esac
2728
done
2829

29-
curl -skSL ${SE_SERVER_PROTOCOL:-"http"}://${HOST}:${PORT}/wd/hub/status | jq -r '.value.ready' | grep -q "true" || exit 1
30+
curl -skSL -H "Authorization: Basic ${BASIC_AUTH}" ${SE_SERVER_PROTOCOL:-"http"}://${HOST}:${PORT}/wd/hub/status | jq -r '.value.ready' | grep -q "true" || exit 1

Diff for: Video/video.sh

+8-1
Original file line numberDiff line numberDiff line change
@@ -203,8 +203,15 @@ else
203203
if [[ "$session_id" != "null" && "$session_id" != "" && "$session_id" != "reserved" && "$recording_started" = "false" ]]; then
204204
echo "$(date +%FT%T%Z) [${process_name}] - Session: $session_id is created"
205205
return_list=($(bash ${VIDEO_CONFIG_DIRECTORY}/video_graphQLQuery.sh "$session_id"))
206-
caps_se_video_record=${return_list[0]}
206+
caps_se_video_record="${return_list[0]}"
207207
video_file_name="${return_list[1]}.mp4"
208+
endpoint_status="${return_list[2]}"
209+
endpoint_url="${return_list[3]}"
210+
if [[ "${endpoint_status}" = "401" ]]; then
211+
echo "$(date +%FT%T%Z) [${process_name}] - GraphQL endpoint requires authentication, please set env variables SE_ROUTER_USERNAME and SE_ROUTER_PASSWORD"
212+
elif [[ "${endpoint_status}" = "404" ]]; then
213+
echo "$(date +%FT%T%Z) [${process_name}] -GraphQL endpoint could not be found, please check the endpoint ${endpoint_url}"
214+
fi
208215
echo "$(date +%FT%T%Z) [${process_name}] - Start recording: $caps_se_video_record, video file name: $video_file_name"
209216
log_node_response
210217
fi

Diff for: Video/video_graphQLQuery.sh

+6-1
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,8 @@ if [[ -n ${GRAPHQL_ENDPOINT} ]] && [[ ! ${GRAPHQL_ENDPOINT} == */graphql ]]; the
1414
GRAPHQL_ENDPOINT="${GRAPHQL_ENDPOINT}/graphql"
1515
fi
1616

17+
BASIC_AUTH="$(echo -n "${SE_ROUTER_USERNAME}:${SE_ROUTER_PASSWORD}" | base64)"
18+
1719
VIDEO_CAP_NAME=${VIDEO_CAP_NAME:-"se:recordVideo"}
1820
TEST_NAME_CAP=${TEST_NAME_CAP:-"se:name"}
1921
VIDEO_NAME_CAP=${VIDEO_NAME_CAP:-"se:videoName"}
@@ -27,12 +29,15 @@ if [ -n "${GRAPHQL_ENDPOINT}" ]; then
2729
# Send GraphQL query
2830
endpoint_checks=$(curl --noproxy "*" -m ${max_time} -k -X POST \
2931
-H "Content-Type: application/json" \
32+
-H "Authorization: Basic ${BASIC_AUTH}" \
3033
--data '{"query":"{ session (id: \"'${SESSION_ID}'\") { id, capabilities, startTime, uri, nodeId, nodeUri, sessionDurationMillis, slot { id, stereotype, lastStarted } } } "}' \
3134
-s "${GRAPHQL_ENDPOINT}" -o "/tmp/graphQL_${SESSION_ID}.json" -w "%{http_code}")
3235
current_check=$((current_check + 1))
3336
# Check if the response contains "capabilities"
3437
if [[ "$endpoint_checks" = "404" ]] || [[ $current_check -eq $retry_time ]]; then
3538
break
39+
elif [[ "$endpoint_checks" = "401" ]] || [[ $current_check -eq $retry_time ]]; then
40+
break
3641
elif [[ "$endpoint_checks" = "200" ]] && [[ $(jq -e '.data.session.capabilities | fromjson | ."'se:vncEnabled'"' /tmp/graphQL_${SESSION_ID}.json >/dev/null) -eq 0 ]]; then
3742
break
3843
fi
@@ -73,7 +78,7 @@ fi
7378
# Normalize the video file name
7479
TEST_NAME="$(echo "${TEST_NAME}" | tr ' ' '_' | tr -dc "${VIDEO_FILE_NAME_TRIM}" | cut -c 1-251)"
7580

76-
return_array=("${RECORD_VIDEO}" "${TEST_NAME}")
81+
return_array=("${RECORD_VIDEO}" "${TEST_NAME}" "${endpoint_checks}" "${GRAPHQL_ENDPOINT}")
7782

7883
# stdout the values for other scripts consuming
7984
echo "${return_array[@]}"

Diff for: Video/video_gridUrl.sh

+2-5
Original file line numberDiff line numberDiff line change
@@ -2,18 +2,15 @@
22

33
max_time=3
44

5-
if [ -n "${SE_ROUTER_USERNAME}" ] && [ -n "${SE_ROUTER_PASSWORD}" ]; then
6-
BASIC_AUTH="${SE_ROUTER_USERNAME}:${SE_ROUTER_PASSWORD}@"
7-
fi
85
if [ "${SE_SUB_PATH}" = "/" ]; then
96
SE_SUB_PATH=""
107
fi
118

129
grid_url="${SE_NODE_GRID_URL}"
1310
if [ -n "${SE_HUB_HOST:-$SE_ROUTER_HOST}" ] && [ -n "${SE_HUB_PORT:-$SE_ROUTER_PORT}" ]; then
14-
grid_url=${SE_SERVER_PROTOCOL}://${BASIC_AUTH}${SE_HUB_HOST:-$SE_ROUTER_HOST}:${SE_HUB_PORT:-$SE_ROUTER_PORT}${SE_SUB_PATH}
11+
grid_url=${SE_SERVER_PROTOCOL}://${SE_HUB_HOST:-$SE_ROUTER_HOST}:${SE_HUB_PORT:-$SE_ROUTER_PORT}${SE_SUB_PATH}
1512
elif [ -n "${DISPLAY_CONTAINER_NAME}" ] && [ "${SE_VIDEO_RECORD_STANDALONE}" = "true" ]; then
16-
grid_url="${SE_SERVER_PROTOCOL}://${BASIC_AUTH}${DISPLAY_CONTAINER_NAME}:${SE_NODE_PORT:-4444}${SE_SUB_PATH}" # For standalone mode
13+
grid_url="${SE_SERVER_PROTOCOL}://${DISPLAY_CONTAINER_NAME}:${SE_NODE_PORT:-4444}${SE_SUB_PATH}" # For standalone mode
1714
fi
1815

1916
if [[ ${grid_url} == */ ]]; then

Diff for: charts/selenium-grid/CONFIGURATION.md

+4-3
Original file line numberDiff line numberDiff line change
@@ -66,9 +66,12 @@ A Helm chart for creating a Selenium Grid Server in Kubernetes
6666
| tls.disableHostnameVerification | bool | `true` | Disable verification the hostname included in the server's TLS/SSL certificates matches the hostnames provided |
6767
| registrationSecret.enabled | bool | `false` | Enable feature node registration secret to make sure that the node is one you control and not a rouge node |
6868
| registrationSecret.value | string | `"HappyTesting"` | The secret value to be used for node registration |
69+
| basicAuth.nameOverride | string | `""` | External secret containing the basic auth username and password for reference |
6970
| basicAuth.enabled | bool | `false` | Enable or disable basic auth for the Hub/Router |
7071
| basicAuth.username | string | `"admin"` | Username for basic auth |
7172
| basicAuth.password | string | `"admin"` | Password for basic auth |
73+
| basicAuth.embeddedUrl | bool | `false` | Embed the basic auth "username:password@" in few URLs e.g. SE_NODE_GRID_URL |
74+
| basicAuth.annotations | object | `{}` | Annotations for basic auth secret resource |
7275
| isolateComponents | bool | `false` | Deploy Router, Distributor, EventBus, SessionMap and Nodes separately |
7376
| serviceAccount.create | bool | `true` | Create a service account for all components |
7477
| serviceAccount.nameOverride | string | `nil` | Override to use an external service account |
@@ -300,6 +303,7 @@ A Helm chart for creating a Selenium Grid Server in Kubernetes
300303
| autoscaling.enabled | bool | `false` | Enable autoscaling. Implies installing KEDA |
301304
| autoscaling.enableWithExistingKEDA | bool | `false` | Enable autoscaling without automatically installing KEDA |
302305
| autoscaling.scalingType | string | `"job"` | Which type of KEDA scaling to use: job or deployment |
306+
| autoscaling.authenticationRef | object | `{"name":""}` | Specify an external KEDA TriggerAuthentication resource is used for scaler triggers config. Apply for all browser nodes |
303307
| autoscaling.annotations | object | `{"helm.sh/hook":"post-install,post-upgrade,post-rollback","helm.sh/hook-weight":"1"}` | Annotations for KEDA resources: ScaledObject and ScaledJob |
304308
| autoscaling.patchObjectFinalizers.nameOverride | string | `nil` | Override the name of the patch job |
305309
| autoscaling.patchObjectFinalizers.enabled | bool | `true` | Enable patching finalizers for KEDA scaled resources. Workaround for Hook post-upgrade selenium-grid/templates/x-node-hpa.yaml failed: object is being deleted: scaledobjects.keda.sh "x" already exists |
@@ -361,7 +365,6 @@ A Helm chart for creating a Selenium Grid Server in Kubernetes
361365
| chromeNode.scaledOptions | string | `nil` | Override the scaled options for chrome nodes |
362366
| chromeNode.scaledJobOptions | string | `nil` | Override the scaledJobOptions for chrome nodes |
363367
| chromeNode.scaledObjectOptions | string | `nil` | Override the scaledObjectOptions for chrome nodes |
364-
| chromeNode.hpa.url | string | `"{{ template \"seleniumGrid.graphqlURL\" . }}"` | Graphql endpoint for the HPA to fetch metrics |
365368
| chromeNode.hpa.browserName | string | `"chrome"` | browserName from the capability |
366369
| chromeNode.hpa.sessionBrowserName | string | `"chrome"` | sessionBrowserName if the browserName is different from the sessionBrowserName |
367370
| chromeNode.hpa.platformName | string | `"linux"` | platformName from the capability |
@@ -411,7 +414,6 @@ A Helm chart for creating a Selenium Grid Server in Kubernetes
411414
| firefoxNode.scaledOptions | string | `nil` | Override the scaled options for firefox nodes |
412415
| firefoxNode.scaledJobOptions | string | `nil` | Override the scaledJobOptions for firefox nodes |
413416
| firefoxNode.scaledObjectOptions | string | `nil` | Override the scaledObjectOptions for firefox nodes |
414-
| firefoxNode.hpa.url | string | `"{{ template \"seleniumGrid.graphqlURL\" . }}"` | Graphql endpoint for the HPA to fetch metrics |
415417
| firefoxNode.hpa.browserName | string | `"firefox"` | browserName from the capability |
416418
| firefoxNode.hpa.sessionBrowserName | string | `"firefox"` | sessionBrowserName if the browserName is different from the sessionBrowserName |
417419
| firefoxNode.hpa.platformName | string | `"linux"` | platformName from the capability |
@@ -461,7 +463,6 @@ A Helm chart for creating a Selenium Grid Server in Kubernetes
461463
| edgeNode.scaledOptions | string | `nil` | Override the scaled options for edge nodes |
462464
| edgeNode.scaledJobOptions | string | `nil` | Override the scaledJobOptions for edge nodes |
463465
| edgeNode.scaledObjectOptions | string | `nil` | Override the scaledObjectOptions for edge nodes |
464-
| edgeNode.hpa.url | string | `"{{ template \"seleniumGrid.graphqlURL\" . }}"` | Graphql endpoint for the HPA to fetch metrics |
465466
| edgeNode.hpa.browserName | string | `"MicrosoftEdge"` | browserName from the capability |
466467
| edgeNode.hpa.sessionBrowserName | string | `"msedge"` | sessionBrowserName if the browserName is different from the sessionBrowserName |
467468
| edgeNode.hpa.platformName | string | `"linux"` | platformName from the capability |

Diff for: charts/selenium-grid/README.md

+10-2
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,7 @@ This chart enables the creation of a Selenium Grid Server in Kubernetes.
1111
* [Installing the Nightly chart](#installing-the-nightly-chart)
1212
* [Chart Release Name convention](#chart-release-name-convention)
1313
* [Enable Selenium Grid Autoscaling](#enable-selenium-grid-autoscaling)
14+
* [Preview new changes in Selenium Grid Scaler implementation](#preview-new-changes-in-selenium-grid-scaler-implementation)
1415
* [Settings common for both `job` and `deployment` scalingType](#settings-common-for-both-job-and-deployment-scalingtype)
1516
* [Settings when scalingType with `deployment`](#settings-when-scalingtype-with-deployment-)
1617
* [Settings when scalingType with `job`](#settings-when-scalingtype-with-job)
@@ -127,7 +128,9 @@ or [jobs](https://keda.sh/docs/latest/concepts/scaling-jobs/) and the charts sup
127128
chart support both modes. It is controlled with `autoscaling.scalingType` that can be set to either
128129
job (default) or deployment.
129130

130-
Preview new changes in Selenium Grid scaler implementation. Refer to [README](../../.keda/README.md)
131+
### Preview new changes in Selenium Grid Scaler implementation
132+
133+
Refer to [README](../../.keda/README.md)
131134

132135
### Settings common for both `job` and `deployment` scalingType
133136

@@ -338,8 +341,13 @@ hub:
338341
```
339342
# Source: selenium-grid/templates/node-configmap.yaml
340343

341-
SE_NODE_GRID_URL: 'http://admin:admin@10.10.10.10/selenium'
344+
SE_NODE_GRID_URL: 'http://10.10.10.10/selenium'
342345
```
346+
347+
For security reasons, it is not recommend to put the credentials in the URL in env variable `SE_NODE_GRID_URL`. For any utilities that need to access the Grid, basic auth should get from env variables `SE_ROUTER_USERNAME` and `SE_ROUTER_PASSWORD`.
348+
349+
If you want to keep basic auth credential is embedded in few URLs (in case Websocket URLs construct in session capabilities), you can set `basicAuth.embeddedUrl` to `true`. By default, it is `false`.
350+
343351
Besides that, from the outside of the cluster, you can access via NodePort `http://10.10.10.10:30444/selenium`
344352
345353
### Configuration of Nodes

Diff for: charts/selenium-grid/configs/distributor/distributorProbe.sh

+6-5
Original file line numberDiff line numberDiff line change
@@ -7,27 +7,28 @@ ts_format=${SE_LOG_TIMESTAMP_FORMAT:-"+%T.%3N"}
77
ROUTER_CONFIG_DIRECTORY=${ROUTER_CONFIG_DIRECTORY:-"/opt/bin"}
88

99
GRID_GRAPHQL_URL=$(bash ${ROUTER_CONFIG_DIRECTORY}/routerGraphQLUrl.sh)
10+
BASIC_AUTH="$(echo -n "${SE_ROUTER_USERNAME}:${SE_ROUTER_PASSWORD}" | base64)"
1011

1112
if [ -z "${GRID_GRAPHQL_URL}" ]; then
1213
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."
1314
exit 0
1415
fi
1516

16-
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})
17+
GRAPHQL_PRE_CHECK=$(curl --noproxy "*" -m ${max_time} -k -X POST -H "Authorization: Basic ${BASIC_AUTH}" -H "Content-Type: application/json" --data '{"query":"{ grid { sessionCount } }"}' -s -o /dev/null -w "%{http_code}" ${GRID_GRAPHQL_URL})
1718

1819
if [ ${GRAPHQL_PRE_CHECK} -ne 200 ]; then
1920
echo "$(date ${ts_format}) DEBUG [${probe_name}] - GraphQL endpoint ${GRID_GRAPHQL_URL} is not reachable. Status code: ${GRAPHQL_PRE_CHECK}."
2021
exit 1
2122
fi
2223

23-
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')
24+
SESSION_QUEUE_SIZE=$(curl --noproxy "*" --retry ${retry_time} -m ${max_time} -k -X POST -H "Authorization: Basic ${BASIC_AUTH}" -H "Content-Type: application/json" --data '{"query":"{ grid { sessionQueueSize } }"}' -s ${GRID_GRAPHQL_URL} | jq -r '.data.grid.sessionQueueSize')
2425

25-
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')
26+
SESSION_COUNT=$(curl --noproxy "*" --retry ${retry_time} -m ${max_time} -k -X POST -H "Authorization: Basic ${BASIC_AUTH}" -H "Content-Type: application/json" --data '{"query": "{ grid { sessionCount } }"}' -s ${GRID_GRAPHQL_URL} | jq -r '.data.grid.sessionCount')
2627

27-
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')
28+
MAX_SESSION=$(curl --noproxy "*" --retry ${retry_time} -m ${max_time} -k -X POST -H "Authorization: Basic ${BASIC_AUTH}" -H "Content-Type: application/json" --data '{"query":"{ grid { maxSession } }"}' -s ${GRID_GRAPHQL_URL} | jq -r '.data.grid.maxSession')
2829

2930
if [ "${SE_LOG_LISTEN_GRAPHQL:-"false"}" = "true" ]; then
30-
echo "$(curl --noproxy "*" --retry ${retry_time} -m ${max_time} -k -X POST -H "Content-Type: application/json" --data '{"query":"{ grid { sessionCount, maxSession, totalSlots }, nodesInfo { nodes { id, status, sessionCount, maxSession, slotCount, stereotypes, sessions { id, capabilities, slot { id, stereotype } } } }, sessionsInfo { sessionQueueRequests } }"}' -s ${GRID_GRAPHQL_URL} )"
31+
echo "$(curl --noproxy "*" --retry ${retry_time} -m ${max_time} -k -X POST -H "Authorization: Basic ${BASIC_AUTH}" -H "Content-Type: application/json" --data '{"query":"{ grid { sessionCount, maxSession, totalSlots }, nodesInfo { nodes { id, status, sessionCount, maxSession, slotCount, stereotypes, sessions { id, capabilities, slot { id, stereotype } } } }, sessionsInfo { sessionQueueRequests } }"}' -s ${GRID_GRAPHQL_URL} )"
3132
fi
3233

3334
if [ ${SESSION_QUEUE_SIZE} -gt 0 ] && [ ${SESSION_COUNT} -eq 0 ]; then

Diff for: charts/selenium-grid/configs/node/nodeGridUrl.sh

+9-13
Original file line numberDiff line numberDiff line change
@@ -2,33 +2,29 @@
22

33
max_time=3
44

5-
if [ -n "${SE_ROUTER_USERNAME}" ] && [ -n "${SE_ROUTER_PASSWORD}" ]; then
6-
BASIC_AUTH="${SE_ROUTER_USERNAME}:${SE_ROUTER_PASSWORD}@"
7-
fi
5+
BASIC_AUTH="$(echo -n "${SE_ROUTER_USERNAME}:${SE_ROUTER_PASSWORD}" | base64)"
6+
87
if [ "${SE_SUB_PATH}" = "/" ]; then
98
SE_SUB_PATH=""
109
fi
1110

1211
if [ -z "${SE_HUB_HOST:-$SE_ROUTER_HOST}" ] || [ -z "${SE_HUB_PORT:-$SE_ROUTER_PORT}" ]; then
1312
grid_url=""
1413
else
15-
grid_url=${SE_SERVER_PROTOCOL}://${BASIC_AUTH}${SE_HUB_HOST:-$SE_ROUTER_HOST}:${SE_HUB_PORT:-$SE_ROUTER_PORT}${SE_SUB_PATH}
14+
grid_url=${SE_SERVER_PROTOCOL}://${SE_HUB_HOST:-$SE_ROUTER_HOST}:${SE_HUB_PORT:-$SE_ROUTER_PORT}${SE_SUB_PATH}
1615
fi
1716

1817
if [ -z "${grid_url}" ]; then
1918
grid_url="${SE_NODE_GRID_URL}"
2019
fi
2120

2221
if [ -z "${grid_url}" ]; then
23-
grid_url="${SE_SERVER_PROTOCOL}://${BASIC_AUTH}127.0.0.1:4444${SE_SUB_PATH}" # For standalone mode
22+
grid_url="${SE_SERVER_PROTOCOL}://127.0.0.1:4444${SE_SUB_PATH}" # For standalone mode
2423
fi
2524

26-
grid_url_checks=$(curl --noproxy "*" -m ${max_time} -s -k -o /dev/null -w "%{http_code}" ${grid_url})
27-
if [ "${grid_url_checks}" = "401" ]; then
28-
return ${grid_url_checks}
29-
fi
30-
if [ "${grid_url_checks}" = "404" ]; then
31-
return ${grid_url_checks}
32-
fi
25+
grid_url_checks=$(curl --noproxy "*" -H "Authorization: Basic ${BASIC_AUTH}" -m ${max_time} -s -k -o /dev/null -w "%{http_code}" ${grid_url})
26+
27+
return_array=("${grid_url}" "${grid_url_checks}")
3328

34-
echo "${grid_url}"
29+
# stdout the values for other scripts consuming
30+
echo "${return_array[@]}"

Diff for: charts/selenium-grid/configs/node/nodePreStop.sh

+13-5
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@ tmp_node_file="/tmp/nodeProbe${ID}"
1212

1313
function on_exit() {
1414
rm -rf ${tmp_node_file}
15-
echo "$(date +%FT%T%Z) [${probe_name}] - Exiting Node preStop..."
15+
echo "$(date +%FT%T%Z) [${probe_name}] - Exiting Node ${probe_name}..."
1616
exit 0
1717
}
1818
trap on_exit EXIT
@@ -30,12 +30,20 @@ else
3030
fi
3131

3232
function signal_hub_to_drain_node() {
33-
grid_url=$(bash ${NODE_CONFIG_DIRECTORY}/nodeGridUrl.sh)
33+
return_list=($(bash ${NODE_CONFIG_DIRECTORY}/nodeGridUrl.sh))
34+
grid_url=${return_list[0]}
35+
grid_check=${return_list[1]}
36+
BASIC_AUTH="$(echo -n "${SE_ROUTER_USERNAME}:${SE_ROUTER_PASSWORD}" | base64)"
3437
if [ -n "${grid_url}" ]; then
38+
if [ "${grid_check}" = "401" ]; then
39+
echo "$(date +%FT%T%Z) [${probe_name}] - Hub/Router requires authentication. Please check SE_ROUTER_USERNAME and SE_ROUTER_PASSWORD."
40+
elif [ "${grid_check}" = "404" ]; then
41+
echo "$(date +%FT%T%Z) [${probe_name}] - Hub/Router endpoint could not be found. Please check the endpoint ${grid_url}"
42+
fi
3543
echo "$(date +%FT%T%Z) [${probe_name}] - Signaling Hub/Router to drain node"
36-
curl --noproxy "*" -m ${max_time} -k -X POST ${grid_url}/se/grid/distributor/node/${NODE_ID}/drain --header "${HEADERS}"
44+
curl --noproxy "*" -m ${max_time} -k -X POST -H "Authorization: Basic ${BASIC_AUTH}" ${grid_url}/se/grid/distributor/node/${NODE_ID}/drain --header "${HEADERS}"
3745
else
38-
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."
46+
echo "$(date +%FT%T%Z) [${probe_name}] - There is no configured HUB/ROUTER host or SE_NODE_GRID_URL isn't set. ${probe_name} ignores to send drain request to upstream."
3947
fi
4048
}
4149

@@ -66,7 +74,7 @@ if curl --noproxy "*" -m ${max_time} -sfk ${SE_SERVER_PROTOCOL}://127.0.0.1:${SE
6674
echo
6775
exit 0
6876
else
69-
echo "$(date +%FT%T%Z) [${probe_name}] - Node preStop is waiting for current session on slot ${SLOT_HAS_SESSION} to be finished. Node details: message: $(jq -r '.value.message' ${tmp_node_file} || "unknown"), availability: $(jq -r '.value.node.availability' ${tmp_node_file} || "unknown")"
77+
echo "$(date +%FT%T%Z) [${probe_name}] - Node ${probe_name} is waiting for current session on slot ${SLOT_HAS_SESSION} to be finished. Node details: message: $(jq -r '.value.message' ${tmp_node_file} || "unknown"), availability: $(jq -r '.value.node.availability' ${tmp_node_file} || "unknown")"
7078
sleep 2;
7179
fi
7280

0 commit comments

Comments
 (0)