Skip to content
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
10 changes: 5 additions & 5 deletions website_and_docs/content/blog/2022/scaling-grid-with-keda.md
Original file line number Diff line number Diff line change
Expand Up @@ -118,7 +118,7 @@ spec:
lifecycle:
preStop:
exec:
command: ["/bin/sh", "-c", "curl --request POST 'localhost:5555/se/grid/node/drain' --header 'X-REGISTRATION-SECRET;'; tail --pid=$(pgrep -f '[n]ode --bind-host false --config /opt/selenium/config.toml') -f /dev/null; sleep 30s"]
command: ["/bin/sh", "-c", "curl --request POST 'localhost:5555/se/grid/node/drain' --header 'X-REGISTRATION-SECRET;'; while curl -fs localhost:5555/status >/dev/null; do sleep 1; done; sleep 10"]
Comment thread
qodo-code-review[bot] marked this conversation as resolved.
```

#### Breaking this down
Expand All @@ -132,8 +132,8 @@ grace period for your cluster nodes as well.
- We curl the `localhost` of our pod to tell it to drain. The pod will no
longer accept new session requests and will finish its current test. More
information on this [can be found in the Selenium Grid documentation](https://www.selenium.dev/documentation/grid/advanced_features/endpoints/#drain).
- We then tail the internal node process that will continue to run until the node has been drained.
- After this we give the pod 30 seconds to finish anything else before giving the full termination command.
- Poll the Selenium node /status endpoint and wait until it becomes unavailable, indicating that the node has been fully drained and terminated.
- After this we give the pod 10 seconds to finish anything else before giving the full termination command.

And with that our application can now safely scale down our selenium browser deployments!

Expand Down Expand Up @@ -216,7 +216,7 @@ spec:
lifecycle:
preStop:
exec:
command: ["/bin/sh", "-c", "curl --request POST 'localhost:5555/se/grid/node/drain' --header 'X-REGISTRATION-SECRET;'; tail --pid=$(pgrep -f '[n]ode --bind-host false --config /opt/selenium/config.toml') -f /dev/null; sleep 30s"]
command: ["/bin/sh", "-c", "curl --request POST 'localhost:5555/se/grid/node/drain' --header 'X-REGISTRATION-SECRET;'; while curl -fs localhost:5555/status >/dev/null; do sleep 1; done; sleep 10"]
```

That is it, your Selenium Grid pods should now scale up and down properly without any lost sessions!
That is it, your Selenium Grid pods should now scale up and down properly without any lost sessions!