Skip to content

Commit ca7155f

Browse files
committed
fix(chart): node preStop - refresh node status in loop
Signed-off-by: Viet Nguyen Duc <[email protected]>
1 parent 819e4cd commit ca7155f

File tree

4 files changed

+24
-6
lines changed

4 files changed

+24
-6
lines changed

Diff for: README.md

+7-3
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,10 @@
1-
![Build & test](https://github.com/SeleniumHQ/docker-selenium/workflows/Build%20&%20test/badge.svg?branch=trunk)
2-
![Deployments](https://github.com/SeleniumHQ/docker-selenium/workflows/Deploys/badge.svg)
3-
![Helm Charts](https://github.com/SeleniumHQ/docker-selenium/workflows/Lint%20and%20Test%20Helm%20Charts/badge.svg)
1+
[![Build & test](https://github.com/SeleniumHQ/docker-selenium/actions/workflows/build-test.yml/badge.svg)](https://github.com/SeleniumHQ/docker-selenium/actions/workflows/build-test.yml)
2+
[![Test Docker Selenium](https://github.com/SeleniumHQ/docker-selenium/actions/workflows/test-video.yml/badge.svg)](https://github.com/SeleniumHQ/docker-selenium/actions/workflows/test-video.yml)
3+
[![Test Helm Charts](https://github.com/SeleniumHQ/docker-selenium/actions/workflows/helm-chart-test.yml/badge.svg)](https://github.com/SeleniumHQ/docker-selenium/actions/workflows/helm-chart-test.yml)
4+
[![Deploys](https://github.com/SeleniumHQ/docker-selenium/actions/workflows/deploy.yml/badge.svg)](https://github.com/SeleniumHQ/docker-selenium/actions/workflows/deploy.yml)
5+
[![Release Charts](https://github.com/SeleniumHQ/docker-selenium/actions/workflows/helm-chart-release.yml/badge.svg)](https://github.com/SeleniumHQ/docker-selenium/actions/workflows/helm-chart-release.yml)
6+
[![Nightly](https://github.com/SeleniumHQ/docker-selenium/actions/workflows/nightly.yaml/badge.svg)](https://github.com/SeleniumHQ/docker-selenium/actions/workflows/nightly.yaml)
7+
[![Update Dev/Beta Browser Images](https://github.com/SeleniumHQ/docker-selenium/actions/workflows/update-dev-beta-browser-images.yml/badge.svg)](https://github.com/SeleniumHQ/docker-selenium/actions/workflows/update-dev-beta-browser-images.yml)
48

59
# Docker images for the Selenium Grid Server
610

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

+15-3
Original file line numberDiff line numberDiff line change
@@ -3,12 +3,14 @@
33
probe_name="lifecycle.${1:-"preStop"}"
44

55
max_time=3
6+
retry_time=5
67

78
ID=$(echo $RANDOM)
89
tmp_node_file="/tmp/nodeProbe${ID}"
910

1011
function on_exit() {
1112
rm -rf ${tmp_node_file}
13+
echo "$(date +%FT%T%Z) [${probe_name}] - Exiting Node preStop..."
1214
}
1315
trap on_exit EXIT
1416

@@ -89,8 +91,12 @@ if curl -m ${max_time} -sfk ${SE_SERVER_PROTOCOL}://127.0.0.1:${SE_NODE_PORT}/st
8991
fi
9092
signal_node_to_drain
9193
# Wait for the current session to be finished if any
92-
while curl -m ${max_time} -sfk ${SE_SERVER_PROTOCOL}://127.0.0.1:${SE_NODE_PORT}/status -o ${tmp_node_file};
93-
do
94+
while true; do
95+
# Attempt the cURL request and capture the exit status
96+
endpoint_http_code=$(curl --retry ${retry_time} -m ${max_time} -sfk ${SE_SERVER_PROTOCOL}://127.0.0.1:${SE_NODE_PORT}/status -o ${tmp_node_file} -w "%{http_code}")
97+
endpoint_status=$?
98+
echo "$(date +%FT%T%Z) [${probe_name}] - Fetch the Node status via cURL with exit status: ${endpoint_status}, HTTP code: ${endpoint_http_code}"
99+
94100
SLOT_HAS_SESSION=$(jq -e ".value.node.slots[]|select(.session != null).id.id" ${tmp_node_file} | tr -d '"' || "")
95101
if [ -z "${SLOT_HAS_SESSION}" ]; then
96102
echo "$(date +%FT%T%Z) [${probe_name}] - There is no session running. Node is ready to be terminated."
@@ -99,7 +105,13 @@ if curl -m ${max_time} -sfk ${SE_SERVER_PROTOCOL}://127.0.0.1:${SE_NODE_PORT}/st
99105
exit 0
100106
else
101107
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")"
102-
sleep 1;
108+
sleep 2;
109+
fi
110+
111+
# If the cURL command failed, break the loop
112+
if [ ${endpoint_status} -ne 0 ] || [ "${endpoint_http_code}" != "200" ]; then
113+
echo "$(date +%FT%T%Z) [${probe_name}] - Node endpoint returned status ${endpoint_http_code:-"exit ${endpoint_status}"}, probably Node draining complete!"
114+
break
103115
fi
104116
done
105117
else

Diff for: tests/bootstrap.sh

+1
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,7 @@ fi
99

1010
python -m pip install selenium==4.19.0 \
1111
docker===7.0.0 \
12+
chardet \
1213
| grep -v 'Requirement already satisfied'
1314

1415
if [ "${SELENIUM_GRID_PROTOCOL}" = "https" ]; then

Diff for: tests/charts/ci/base-auth-ingress-values.yaml

+1
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
global:
22
seleniumGrid:
33
logLevel: INFO
4+
stdoutProbeLog: true
45

56
ingress:
67
className: nginx

0 commit comments

Comments
 (0)