@@ -417,8 +417,9 @@ def _configure_eviction_handling(self):
417417 """
418418 Configures eviction handling for the job pod. Needs to run before
419419
420- If `backoffLimit` is set to 0, we'll tell the Runner to reschedule
421- its flow run when it receives a SIGTERM.
420+ If `backoffLimit` is set to 0 and `PREFECT_FLOW_RUN_EXECUTE_SIGTERM_BEHAVIOR` is
421+ not set in env, we'll tell the Runner to reschedule its flow run when it receives
422+ a SIGTERM.
422423
423424 If `backoffLimit` is set to a positive number, we'll ensure that the
424425 reschedule SIGTERM handling is not set. Having both a `backoffLimit` and
@@ -428,7 +429,8 @@ def _configure_eviction_handling(self):
428429 # its flow run when it receives a SIGTERM.
429430 if self .job_manifest ["spec" ].get ("backoffLimit" ) == 0 :
430431 if isinstance (self .env , dict ):
431- self .env ["PREFECT_FLOW_RUN_EXECUTE_SIGTERM_BEHAVIOR" ] = "reschedule"
432+ if not self .env .get ("PREFECT_FLOW_RUN_EXECUTE_SIGTERM_BEHAVIOR" ):
433+ self .env ["PREFECT_FLOW_RUN_EXECUTE_SIGTERM_BEHAVIOR" ] = "reschedule"
432434 elif not any (
433435 v .get ("name" ) == "PREFECT_FLOW_RUN_EXECUTE_SIGTERM_BEHAVIOR"
434436 for v in self .env
@@ -646,7 +648,9 @@ class KubernetesWorkerVariables(BaseVariables):
646648 title = "Backoff Limit" ,
647649 description = (
648650 "The number of times Kubernetes will retry a job after pod eviction. "
649- "If set to 0, Prefect will reschedule the flow run when the pod is evicted."
651+ "If set to 0, Prefect will reschedule the flow run when the pod is evicted "
652+ "unless PREFECT_FLOW_RUN_EXECUTE_SIGTERM_BEHAVIOR is set to value "
653+ "different from 'reschedule'."
650654 ),
651655 )
652656 finished_job_ttl : Optional [int ] = Field (
0 commit comments