From d76dc4cda1e54db939ae77e01660943ff57bbae0 Mon Sep 17 00:00:00 2001 From: Viet Nguyen Duc Date: Mon, 29 Jan 2024 09:57:22 +0530 Subject: [PATCH] feat(chart): Log Node preStop exec to console Signed-off-by: Viet Nguyen Duc --- .github/workflows/helm-chart-test.yml | 4 ++-- charts/selenium-grid/configs/node/nodePreStop.sh | 8 +++++++- charts/selenium-grid/templates/_helpers.tpl | 2 +- 3 files changed, 10 insertions(+), 4 deletions(-) diff --git a/.github/workflows/helm-chart-test.yml b/.github/workflows/helm-chart-test.yml index 7d6697e82..a1a72fd77 100644 --- a/.github/workflows/helm-chart-test.yml +++ b/.github/workflows/helm-chart-test.yml @@ -1,4 +1,4 @@ -name: Lint and Test Helm Charts +name: Test Helm Charts on: push: @@ -14,7 +14,7 @@ permissions: jobs: build-and-test: - name: Test Helm charts + name: Build & test runs-on: ubuntu-latest strategy: fail-fast: false diff --git a/charts/selenium-grid/configs/node/nodePreStop.sh b/charts/selenium-grid/configs/node/nodePreStop.sh index 7b6397b6d..d125ddbc0 100644 --- a/charts/selenium-grid/configs/node/nodePreStop.sh +++ b/charts/selenium-grid/configs/node/nodePreStop.sh @@ -8,7 +8,13 @@ fi if curl -sfk ${SE_SERVER_PROTOCOL}://127.0.0.1:${SE_NODE_PORT}/status; then curl -k -X POST ${SE_SERVER_PROTOCOL}://127.0.0.1:${SE_NODE_PORT}/se/grid/node/drain --header "${HEADERS}" - while curl -sfk ${SE_SERVER_PROTOCOL}://127.0.0.1:${SE_NODE_PORT}/status; do sleep 1; done + while curl -sfk ${SE_SERVER_PROTOCOL}://127.0.0.1:${SE_NODE_PORT}/status -o /tmp/preStopOutput; + do + echo "Node preStop is waiting for current session to be finished if any.\nNode details: \ + .value.message: $(jq -r '.value.message' /tmp/preStopOutput || "unknown"), \ + .value.node.availability: $(jq -r '.value.node.availability' /tmp/preStopOutput || "unknown")" + sleep 1; + done else echo "Node is already drained. Shutting down gracefully!" fi diff --git a/charts/selenium-grid/templates/_helpers.tpl b/charts/selenium-grid/templates/_helpers.tpl index ee293c1eb..449dacd07 100644 --- a/charts/selenium-grid/templates/_helpers.tpl +++ b/charts/selenium-grid/templates/_helpers.tpl @@ -668,7 +668,7 @@ Define preStop hook for the node pod. Node preStop script is stored in a ConfigM {{- define "seleniumGrid.node.deregisterLifecycle" -}} preStop: exec: - command: ["bash", "-c", "{{ $.Values.nodeConfigMap.extraScriptsDirectory }}/nodePreStop.sh"] + command: ["bash", "-c", "{{ $.Values.nodeConfigMap.extraScriptsDirectory }}/nodePreStop.sh >> /proc/1/fd/1"] {{- end -}} {{/*