[🐛 Bug]: terminationGracePeriodSeconds is hardcoded to 30 for scalingType job, ignoring both configured values

未关闭
#3,213 0 条评论 0 个 reaction 已指派 0 人 在 GitHub 查看

维护者通常 1 天内回复

@TOMASEZARATE 已经在做这个了。

开始于 2026年11月26日。

  • #3333 来自 @TOMASEZARATE —— 未关闭

评估

难度
3/5
预计耗时
1-2 天
新手友好度
65/100
Issue 类型
缺陷
描述清晰度
基本清楚
活跃度
活跃
技术栈
helm, kubernetes

调研方向

从 templates/_helpers.tpl 中的 seleniumGrid.node.terminationGracePeriodSeconds 开始,然后阅读 chart README 中描述按节点覆盖的部分。运行 issue 中的三个 helm template 和 yq 命令,以复现 job 和 deployment 的输出。完成的标准是:已实现接受的行为,或已明确记录 job-mode 的限制,并且渲染结果与该决定一致。

由索引模型根据 Issue 内容生成。

描述

What happened?

With autoscaling.scalingType: job, a browser node pod always renders terminationGracePeriodSeconds: 30. Both configurable values are ignored.

seleniumGrid.node.terminationGracePeriodSeconds in templates/_helpers.tpl reads autoscaling.terminationGracePeriodSeconds and the per-node <node>.terminationGracePeriodSeconds, then discards both and returns a literal 30 when KEDA is enabled and scalingType is job:

{{- $autoscalingPeriod := default 0 .Values.autoscaling.terminationGracePeriodSeconds | int -}}
{{- $nodePeriod := default 0 .node.terminationGracePeriodSeconds | int -}}
{{- $period := $nodePeriod -}}
{{- if and (eq .Values.autoscaling.scalingType "deployment") (eq (include "seleniumGrid.useKEDA" $) "true") -}}
  {{- $period = ternary $nodePeriod $autoscalingPeriod (gt $nodePeriod $autoscalingPeriod) -}}
{{- else if and (eq .Values.autoscaling.scalingType "job") (eq (include "seleniumGrid.useKEDA" $) "true") }}
  {{- $period = 30 -}}
{{- end -}}

The chart README documents the per-node override with a worked chromeNode: terminationGracePeriodSeconds: 7200 example. That example sits under a heading scoped to deployment, but the README never states what job mode uses, and nothing warns that the override is inert there. So on a job-scaled grid the documented setting renders no change and gives no signal that it was ignored.

Why this matters in practice: in job mode the preStop hook drains the node and waits for the running session to finish. That is fine while pods complete on their own, which is the normal job lifecycle. But when a pod is deleted mid-session — a chart upgrade rolling the control plane, a node drain, or cluster-autoscaler consolidation — the hook is killed once the window expires and the session dies. With the window fixed at 30s there is no supported way to widen it, so any session longer than that is unprotected against pod deletion.

Two possible resolutions, and I would rather ask than assume:

  1. Honour the configured value in job mode (falling back to 30 when neither is set). This is the one that would actually help, since it makes the window tunable to real session lengths.
  2. If the fixed window is deliberate for job scaling, then documenting it — stating what job mode uses and that the override does not apply there — would at least remove the trap.

Happy to open a PR for either once you say which you would accept.

Command used to start Selenium Grid with Docker (or Kubernetes)
# 1. job mode + per-node override -> renders 30
helm template t ./charts/selenium-grid \
  --set autoscaling.enabled=true --set autoscaling.scalingType=job \
  --set chromeNode.terminationGracePeriodSeconds=7200 \
  | yq 'select(.kind=="ScaledJob" and (.metadata.name|test("chrome"))) | .spec.jobTargetRef.template.spec.terminationGracePeriodSeconds'

# 2. job mode + autoscaling-level value -> renders 30
helm template t ./charts/selenium-grid \
  --set autoscaling.enabled=true --set autoscaling.scalingType=job \
  --set autoscaling.terminationGracePeriodSeconds=7200 \
  | yq 'select(.kind=="ScaledJob" and (.metadata.name|test("chrome"))) | .spec.jobTargetRef.template.spec.terminationGracePeriodSeconds'

# 3. deployment mode + per-node override -> renders 7200 (works as documented)
helm template t ./charts/selenium-grid \
  --set autoscaling.enabled=true --set autoscaling.scalingType=deployment \
  --set chromeNode.terminationGracePeriodSeconds=7200 \
  | yq 'select(.kind=="Deployment" and (.metadata.name|test("chrome"))) | .spec.template.spec.terminationGracePeriodSeconds'
Relevant log output
# rendered terminationGracePeriodSeconds from the three commands above
1. job mode,        chromeNode.terminationGracePeriodSeconds=7200  -> 30
2. job mode,        autoscaling.terminationGracePeriodSeconds=7200 -> 30
3. deployment mode, chromeNode.terminationGracePeriodSeconds=7200  -> 7200

# what it looks like when a pod is deleted while a session is still running:
# the hook is still waiting for the slot to clear when the window expires
Warning  FailedPreStopHook  pod/<release>-selenium-node-chrome-xxxxx-yyyyy   PreStopHook failed
Operating System

Linux (GKE)

Docker Selenium version (image tag)

4.47.0-20260808

Selenium Grid chart version (chart version)

0.58.0

主要语言
Go
星标
8.7k
派生
2.5k
平均合并
1 天 15 小时
30 天内合并 PR
37

环境准备

从这里开始

  1. 先读完整个 Issue,再读项目的贡献指南。
  2. 在 Issue 下留言说明你要接手 —— 这能避免两个人做同样的事。
  3. Fork 仓库,在一个分支上完成修改。
  4. 提交 Pull Request,并在描述里引用这个 Issue 编号。

SeleniumHQ/docker-selenium 的其他 Issue

查看 SeleniumHQ/docker-selenium 的全部 Issue

相似的 Issue

更多 Go Issue

把新 issue 发到你的邮箱

精选适合新手参与的 GitHub issue 摘要。