<p>I'm using the SeleniumGrid in the most recent version <code>4.1.2</code> in a Kubernetes cluster.</p>
<p>In many cases (I would say in about half) when I execute a test through the grid, the node fails to kill the processes and does not go back to being idle. The container then keeps using one full CPU all the time until I kill it manually.</p>
<p>The log in the container is the following:</p>
<pre><code>10:51:34.781 INFO [NodeServer$1.lambda$start$1] - Sending registration event...
10:51:35.680 INFO [NodeServer.lambda$createHandlers$2] - Node has been added
Starting ChromeDriver 98.0.4758.102 (273bf7ac8c909cde36982d27f66f3c70846a3718-refs/branch-heads/4758@{#1151}) on port 39592
Only local connections are allowed.
Please see https://chromedriver.chromium.org/security-considerations for suggestions on keeping ChromeDriver safe.
[1C6h4r6o1m2e9D1r2i3v.e9r8 7w]a[sS EsVtEaRrEt]e:d  bsiuncdc(e)s sffauillleyd.:
 Cannot assign requested address (99)
11:08:24.970 WARN [SeleniumSpanExporter$1.lambda$export$0] - {&quot;traceId&quot;: &quot;99100300a4e6b4fe2afe5891b50def09&quot;,&quot;eventTime&quot;: 1646129304968456597,&quot;eventName&quot;: &quot;No slot matched the requested capabilities. &quot;,&quot;attributes&quot;

11:08:44.672 INFO [OsProcess.destroy] - Unable to drain process streams. Ignoring but the exception being swallowed follows.
org.apache.commons.exec.ExecuteException: The stop timeout of 2000 ms was exceeded (Exit value: -559038737)
    at org.apache.commons.exec.PumpStreamHandler.stopThread(PumpStreamHandler.java:295)
    at org.apache.commons.exec.PumpStreamHandler.stop(PumpStreamHandler.java:180)
    at org.openqa.selenium.os.OsProcess.destroy(OsProcess.java:135)
    at org.openqa.selenium.os.CommandLine.destroy(CommandLine.java:152)
    at org.openqa.selenium.remote.service.DriverService.stop(DriverService.java:281)
    at org.openqa.selenium.grid.node.config.DriverServiceSessionFactory.apply(DriverServiceSessionFactory.java:183)
    at org.openqa.selenium.grid.node.config.DriverServiceSessionFactory.apply(DriverServiceSessionFactory.java:65)
    at org.openqa.selenium.grid.node.local.SessionSlot.apply(SessionSlot.java:143)
    at org.openqa.selenium.grid.node.local.LocalNode.newSession(LocalNode.java:314)
    at org.openqa.selenium.grid.node.NewNodeSession.execute(NewNodeSession.java:52)
    at org.openqa.selenium.remote.http.Route$TemplatizedRoute.handle(Route.java:192)
    at org.openqa.selenium.remote.http.Route.execute(Route.java:68)
    at org.openqa.selenium.grid.security.RequiresSecretFilter.lambda$apply$0(RequiresSecretFilter.java:64)
    at org.openqa.selenium.remote.tracing.SpanWrappedHttpHandler.execute(SpanWrappedHttpHandler.java:86)
    at org.openqa.selenium.remote.http.Filter$1.execute(Filter.java:64)
    at org.openqa.selenium.remote.http.Route$CombinedRoute.handle(Route.java:336)
    at org.openqa.selenium.remote.http.Route.execute(Route.java:68)
    at org.openqa.selenium.grid.node.Node.execute(Node.java:240)
    at org.openqa.selenium.remote.http.Route$CombinedRoute.handle(Route.java:336)
    at org.openqa.selenium.remote.http.Route.execute(Route.java:68)
    at org.openqa.selenium.remote.AddWebDriverSpecHeaders.lambda$apply$0(AddWebDriverSpecHeaders.java:35)
    at org.openqa.selenium.remote.ErrorFilter.lambda$apply$0(ErrorFilter.java:44)
    at org.openqa.selenium.remote.http.Filter$1.execute(Filter.java:64)
    at org.openqa.selenium.remote.ErrorFilter.lambda$apply$0(ErrorFilter.java:44)
    at org.openqa.selenium.remote.http.Filter$1.execute(Filter.java:64)
    at org.openqa.selenium.netty.server.SeleniumHandler.lambda$channelRead0$0(SeleniumHandler.java:44)
    at java.base/java.util.concurrent.Executors$RunnableAdapter.call(Executors.java:515)
    at java.base/java.util.concurrent.FutureTask.run(FutureTask.java:264)
    at java.base/java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1128)
    at java.base/java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:628)
    at java.base/java.lang.Thread.run(Thread.java:829)
11:08:44.673 ERROR [OsProcess.destroy] - Unable to kill process Process[pid=75, exitValue=143]
11:08:44.675 WARN [SeleniumSpanExporter$1.lambda$export$0] - {&quot;traceId&quot;: &quot;99100300a4e6b4fe2afe5891b50def09&quot;,&quot;eventTime&quot;: 1646129316638154262,&quot;eventName&quot;: &quot;exception&quot;,&quot;attributes&quot;: {&quot;driver.url&quot;: &quot;http:\u002f\u002f
</code></pre>
<p>Here's an excerpt from the Kubernetes manifest:</p>
<pre class="lang-yaml prettyprint-override"><code>        - name: selenium-node-chrome
          image: selenium/node-chrome:latest
...
          env:
            - name: TZ
              value: Europe/Berlin
            - name: START_XVFB
              value: &quot;false&quot;
            - name: SE_NODE_OVERRIDE_MAX_SESSIONS
              value: &quot;true&quot;
            - name: SE_NODE_MAX_SESSIONS
              value: &quot;1&quot;
          envFrom:
            - configMapRef:
                name: selenium-event-bus-config
...
          volumeMounts:
            - name: dshm
              mountPath: /dev/shm
...
      volumes:
        - name: dshm
          emptyDir:
            medium: Memory
</code></pre>
<p>The <code>selenium-event-bus-config</code> contains the following vars:</p>
<pre class="lang-yaml prettyprint-override"><code>data:
  SE_EVENT_BUS_HOST: selenium-hub
  SE_EVENT_BUS_PUBLISH_PORT: &quot;4442&quot;
  SE_EVENT_BUS_SUBSCRIBE_PORT: &quot;4443&quot;
</code></pre>
<p>Did I misconfigure anything? Has anyone any idea how I can fix this?</p>

<p>If you don't need to use Xvfb you can remove it from your code and your problem will be resolved.</p>
<blockquote>
<p>Apparently the issue resolves when removing the <code>START_XVFB</code> parameter. With a node with only the timezone config I did not yet have the problem.</p>
</blockquote>
<p>For the workaround you can try to change your driver for example to <a href="https://sites.google.com/a/chromium.org/chromedriver/downloads" rel="nofollow noreferrer">Chromedriver</a>. You can read about the differences between them <a href="https://stackoverflow.com/questions/41460168/what-is-difference-between-xvfb-and-chromedriver-and-when-to-use-them">here</a>.</p>
<p>See also <a href="https://github.com/SeleniumHQ/docker-selenium/issues/1500" rel="nofollow noreferrer">this similar problem</a>.</p>
