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

Đang mở
#3,213 0 bình luận 0 reaction 0 người được giao Xem trên GitHub

Maintainer thường phản hồi trong vòng 1 ngày

@TOMASEZARATE đang làm issue này rồi.

Từ ngày 26/11/2026.

  • #3333 của @TOMASEZARATE — đang mở

Đánh giá

Độ khó
3/5
Thời gian dự kiến
1-2 ngày
Mức phù hợp với người mới
65/100
Loại issue
Lỗi
Độ rõ ràng
Khá rõ ràng
Mức độ hoạt động
Sôi nổi
Công nghệ
helm, kubernetes
Lĩnh vực
devops, infrastructure

Hướng nghiên cứu

Bắt đầu trong templates/_helpers.tpl tại seleniumGrid.node.terminationGracePeriodSeconds, sau đó đọc phần README của chart mô tả việc ghi đè theo từng node. Chạy ba lệnh helm template và yq từ issue để tái hiện đầu ra của job và deployment. Hoàn tất nghĩa là hành vi được chấp nhận đã được triển khai hoặc giới hạn của job-mode đã được ghi rõ trong tài liệu, với kết quả được render khớp với quyết định đó.

Do mô hình lập chỉ mục viết ra từ nội dung của issue.

Mô tả

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

Ngôn ngữ chính
Go
Star
8.7k
Fork
2.5k
Merge trung bình
1 ngày 15 giờ
Pull request đã merge (30 ngày)
37

Chuẩn bị môi trường

Bắt đầu từ đâu

  1. Đọc hết issue, rồi đọc hướng dẫn đóng góp của dự án.
  2. Bình luận trên issue rằng bạn sẽ nhận — tránh hai người làm cùng một việc.
  3. Fork repository và làm thay đổi trên một nhánh.
  4. Mở pull request có tham chiếu số hiệu của issue.

Issue khác của SeleniumHQ/docker-selenium

Tất cả issue của SeleniumHQ/docker-selenium

Issue tương tự

Thêm issue về Go

Nhận issue mới trong hộp thư của bạn

Bản tóm tắt ngắn những issue GitHub phù hợp với người mới.