Skip to content

Commit

Permalink
fix(chart): node probe ignore proxy in sending request
Browse files Browse the repository at this point in the history
Signed-off-by: Viet Nguyen Duc <[email protected]>
  • Loading branch information
VietND96 committed Apr 16, 2024
1 parent ab3f8b8 commit bd50206
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 9 deletions.
12 changes: 6 additions & 6 deletions charts/selenium-grid/configs/node/nodePreStop.sh
Original file line number Diff line number Diff line change
Expand Up @@ -49,7 +49,7 @@ function get_grid_url() {
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 -m ${max_time} -s -o /dev/null -w "%{http_code}" ${grid_url})
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=""
Expand All @@ -62,7 +62,7 @@ function get_grid_url() {
function signal_distributor_to_drain_node() {
if [ "${DISTRIBUTED_MODE}" = true ]; then
echo "$(date +%FT%T%Z) [${probe_name}] - Signaling Distributor to drain node"
curl -m ${max_time} -k -X POST ${SE_SERVER_PROTOCOL}://${SE_DISTRIBUTOR_HOST}:${SE_DISTRIBUTOR_PORT}/se/grid/distributor/node/${NODE_ID}/drain --header "${HEADERS}"
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
}

Expand All @@ -71,17 +71,17 @@ function signal_hub_to_drain_node() {
get_grid_url
if [ -n "${grid_url}" ]; then
echo "$(date +%FT%T%Z) [${probe_name}] - Signaling Hub to drain node"
curl -m ${max_time} -k -X POST ${grid_url}/se/grid/distributor/node/${NODE_ID}/drain --header "${HEADERS}"
curl --noproxy "*" -m ${max_time} -k -X POST ${grid_url}/se/grid/distributor/node/${NODE_ID}/drain --header "${HEADERS}"
fi
fi
}

function signal_node_to_drain() {
echo "$(date +%FT%T%Z) [${probe_name}] - Signaling Node to drain itself"
curl -m ${max_time} -k -X POST ${SE_SERVER_PROTOCOL}://127.0.0.1:${SE_NODE_PORT}/se/grid/node/drain --header "${HEADERS}"
curl --noproxy "*" -m ${max_time} -k -X POST ${SE_SERVER_PROTOCOL}://127.0.0.1:${SE_NODE_PORT}/se/grid/node/drain --header "${HEADERS}"
}

if curl -m ${max_time} -sfk ${SE_SERVER_PROTOCOL}://127.0.0.1:${SE_NODE_PORT}/status > ${tmp_node_file}; then
if curl --noproxy "*" -m ${max_time} -sfk ${SE_SERVER_PROTOCOL}://127.0.0.1:${SE_NODE_PORT}/status > ${tmp_node_file}; then
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}"
Expand All @@ -93,7 +93,7 @@ if curl -m ${max_time} -sfk ${SE_SERVER_PROTOCOL}://127.0.0.1:${SE_NODE_PORT}/st
# Wait for the current session to be finished if any
while true; do
# Attempt the cURL request and capture the exit status
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}")
endpoint_http_code=$(curl --noproxy "*" --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}")
endpoint_status=$?
echo "$(date +%FT%T%Z) [${probe_name}] - Fetch the Node status via cURL with exit status: ${endpoint_status}, HTTP code: ${endpoint_http_code}"

Expand Down
6 changes: 3 additions & 3 deletions charts/selenium-grid/configs/node/nodeProbe.sh
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,7 @@ function get_grid_url() {
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 -m ${max_time} -skf -o /dev/null -w "%{http_code}" ${grid_url})
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
Expand All @@ -48,7 +48,7 @@ function get_grid_url() {
fi
}

if curl -m ${max_time} -sfk ${SE_SERVER_PROTOCOL}://127.0.0.1:${SE_NODE_PORT}/status -o ${tmp_node_file}; then
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} || "")
if [ -n "${NODE_ID}" ]; then
Expand All @@ -60,7 +60,7 @@ if curl -m ${max_time} -sfk ${SE_SERVER_PROTOCOL}://127.0.0.1:${SE_NODE_PORT}/st

get_grid_url

curl -m ${max_time} -sfk "${grid_url}/status" -o ${tmp_grid_file}
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 '"' || "")
if [ -n "${GRID_NODE_ID}" ]; then
echo "$(date +%FT%T%Z) [${probe_name}] - Grid responds a matched Node ID: ${GRID_NODE_ID}"
Expand Down

0 comments on commit bd50206

Please sign in to comment.