You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
fix(controller): cancel in-flight spark-submit on controller shutdown
When the controller leader receives SIGTERM during spark-submit, the reconcile
context is cancelled immediately and the JVM subprocess may keep running until
the process exits or the kubelet sends SIGKILL. That can create a driver pod
the controller never records, contributing to duplicate submissions on restart.
- Add SparkSubmitter.runSparkSubmit using exec.CommandContext; send SIGTERM
on cancellation and wait up to ShutdownGracePeriod before force-killing.
- Reuse --driver-pod-creation-grace-period for ShutdownGracePeriod and
Manager.GracefulShutdownTimeout (no separate graceful-shutdown flag).
- Helm: controller pod terminationGracePeriodSeconds default 60.
- Add runSparkSubmit unit tests and chart deployment tests.
Refs #2788
Signed-off-by: Amir Alavi <amiralavi7@gmail.com>
Co-authored-by: Cursor <cursoragent@cursor.com>
| controller.logLevel | string |`"info"`| Configure the verbosity of logging, can be one of `debug`, `info`, `error`. |
104
104
| controller.logEncoder | string |`"console"`| Configure the encoder of logging, can be one of `console` or `json`. |
105
-
| controller.driverPodCreationGracePeriod | string |`"10s"`| Grace period after a successful spark-submit when driver pod not found errors will be retried. Useful if the driver pod can take some time to be created. |
105
+
| controller.driverPodCreationGracePeriod | string |`"10s"`| Grace period after a successful spark-submit when driver pod not found errors will be retried. Also caps how long an in-flight spark-submit is given to exit after SIGTERM during controller shutdown (reconcile context is cancelled immediately on SIGTERM; this window is for reaping the JVM subprocess). Set lower than `terminationGracePeriodSeconds` so the manager exits before the kubelet sends SIGKILL. |
106
+
| controller.terminationGracePeriodSeconds | int |`60`| Termination grace period for the controller pod. The kubelet sends SIGKILL when this elapses. Must be set higher than `controller.driverPodCreationGracePeriod` so the manager has time to interrupt and reap in-flight `spark-submit` subprocesses before the process is forcibly killed. |
106
107
| controller.maxTrackedExecutorPerApp | int |`1000`| Specifies the maximum number of Executor pods that can be tracked by the controller per SparkApplication. |
107
108
| controller.kubeAPIQPS | int |`20`| Maximum QPS to the API server from the controller client. |
108
109
| controller.kubeAPIBurst | int |`30`| Maximum burst for throttle from the controller client. |
- it: Should add leader election parameters if `controller.leaderElection.leaseDuration`, `controller.leaderElection.renewDeadline` and `controller.leaderElection.retryPeriod` are set.
Copy file name to clipboardExpand all lines: charts/spark-operator-chart/values.yaml
+11-1Lines changed: 11 additions & 1 deletion
Original file line number
Diff line number
Diff line change
@@ -107,9 +107,19 @@ controller:
107
107
# -- Configure the encoder of logging, can be one of `console` or `json`.
108
108
logEncoder: console
109
109
110
-
# -- Grace period after a successful spark-submit when driver pod not found errors will be retried. Useful if the driver pod can take some time to be created.
110
+
# -- Grace period after a successful spark-submit when driver pod not found errors will be retried.
111
+
# Also caps how long an in-flight spark-submit is given to exit after SIGTERM during controller
112
+
# shutdown (reconcile context is cancelled immediately on SIGTERM; this window is for reaping the
113
+
# JVM subprocess). Set lower than `terminationGracePeriodSeconds` so the manager exits before the
114
+
# kubelet sends SIGKILL.
111
115
driverPodCreationGracePeriod: 10s
112
116
117
+
# -- Termination grace period for the controller pod. The kubelet sends SIGKILL when this
118
+
# elapses. Must be set higher than `controller.driverPodCreationGracePeriod` so the manager
119
+
# has time to interrupt and reap in-flight `spark-submit` subprocesses before the process is
120
+
# forcibly killed.
121
+
terminationGracePeriodSeconds: 60
122
+
113
123
# -- Specifies the maximum number of Executor pods that can be tracked by the controller per SparkApplication.
command.Flags().DurationVar(&driverPodCreationGracePeriod, "driver-pod-creation-grace-period", 10*time.Second, "Grace period after a successful spark-submit when driver pod not found errors will be retried. Useful if the driver pod can take some time to be created.")
225
+
command.Flags().DurationVar(&driverPodCreationGracePeriod, "driver-pod-creation-grace-period", 10*time.Second, "Grace period after a successful spark-submit when driver pod not found errors will be retried, and maximum time to wait for an in-flight spark-submit to exit after SIGTERM during controller shutdown. Useful if driver pod creation can take some time. Should be set lower than the pod's terminationGracePeriodSeconds.")
226
226
227
227
command.Flags().Float32Var(&kubeAPIQPS, "kube-api-qps", 20, "Maximum QPS to the API server from the controller client.")
228
228
command.Flags().IntVar(&kubeAPIBurst, "kube-api-burst", 30, "Maximum burst for throttle from the controller client.")
0 commit comments