每次节点被杀死时,Selenium Grid 都会重新启动
Selenium Grid restarts every time a node is killed
TL;DR;如果 Selenium Grid 中的节点死亡,Selenium Hub 将重新启动。为什么?
我使用 https://github.com/kubernetes/examples/tree/master/staging/selenium.
中的文件在 Kubernetes 中使用 Selenium Grid
我注意到每次 Chrome 或 Firefox 节点因为达到资源限制而被杀死时,集线器也会重新启动,最终断开所有其他节点几分钟。为什么?这是预期的行为吗?我原以为只有一个节点断开连接,但所有其他节点都可用。
它与 Kubernetes 无关,因为我在 Docker Swarm 中也重现了这个问题。另外,它没有具体说明 Selenium 的版本,我已经用 3.7、3.11 和最新的 3.12 复制了它。
其实重现很容易,只要启动网格限制节点到 500MB,将它们启动到 Youtube,最终一个会崩溃。发生这种情况时,您甚至无法访问 Grid 的控制台,因为它也崩溃了。
我注意到该问题仅在节点崩溃时触发。如果你只是杀死节点(例如 docker rm -f selenium-node-firefox-x62gxj
),一切都很好,它会重新加入网格而不会受到任何干扰。
下面是相关代码,虽然我认为这是直接与Grid有关的问题。
def get_driver(browser, selenium_grid):
if browser == 'CHROME':
options = webdriver.ChromeOptions()
options.add_argument('--ignore-certificate-errors')
options.add_argument('--autoplay-policy=no-user-gesture-required')
capabilities = options.to_capabilities()
else:
capabilities = getattr(DesiredCapabilities, browser)
return webdriver.Remote(
command_executor=selenium_grid,
desired_capabilities=capabilities
)
driver = get_driver(browser, selenium_grid)
driver.get(channel_url)
channel_url
是 YouTube 视频的 link。 selenium_grid
网格的 URL 和 browser
字符串 "CHROME" 或 "FIREFOX".
好的,我在 IRC 的#selenium 频道中得到了答案。
原因如下:
when a node dies, the hub removes it by querying it a few times and
after no answer it removes it. While that happens, if you get the grid
console, it gets slow (some internals how the node list is managed, we
should improve that) and since it gets slow, I imagine that
livenessProbe timesout so perhaps that kills the hub and brings a new
one
有效增加健康检查,解决问题
TL;DR;如果 Selenium Grid 中的节点死亡,Selenium Hub 将重新启动。为什么?
我使用 https://github.com/kubernetes/examples/tree/master/staging/selenium.
中的文件在 Kubernetes 中使用 Selenium Grid我注意到每次 Chrome 或 Firefox 节点因为达到资源限制而被杀死时,集线器也会重新启动,最终断开所有其他节点几分钟。为什么?这是预期的行为吗?我原以为只有一个节点断开连接,但所有其他节点都可用。
它与 Kubernetes 无关,因为我在 Docker Swarm 中也重现了这个问题。另外,它没有具体说明 Selenium 的版本,我已经用 3.7、3.11 和最新的 3.12 复制了它。
其实重现很容易,只要启动网格限制节点到 500MB,将它们启动到 Youtube,最终一个会崩溃。发生这种情况时,您甚至无法访问 Grid 的控制台,因为它也崩溃了。
我注意到该问题仅在节点崩溃时触发。如果你只是杀死节点(例如 docker rm -f selenium-node-firefox-x62gxj
),一切都很好,它会重新加入网格而不会受到任何干扰。
下面是相关代码,虽然我认为这是直接与Grid有关的问题。
def get_driver(browser, selenium_grid):
if browser == 'CHROME':
options = webdriver.ChromeOptions()
options.add_argument('--ignore-certificate-errors')
options.add_argument('--autoplay-policy=no-user-gesture-required')
capabilities = options.to_capabilities()
else:
capabilities = getattr(DesiredCapabilities, browser)
return webdriver.Remote(
command_executor=selenium_grid,
desired_capabilities=capabilities
)
driver = get_driver(browser, selenium_grid)
driver.get(channel_url)
channel_url
是 YouTube 视频的 link。 selenium_grid
网格的 URL 和 browser
字符串 "CHROME" 或 "FIREFOX".
好的,我在 IRC 的#selenium 频道中得到了答案。
原因如下:
when a node dies, the hub removes it by querying it a few times and after no answer it removes it. While that happens, if you get the grid console, it gets slow (some internals how the node list is managed, we should improve that) and since it gets slow, I imagine that livenessProbe timesout so perhaps that kills the hub and brings a new one
有效增加健康检查,解决问题