mirror of
https://github.com/k3s-io/kubernetes.git
synced 2025-07-21 19:01:49 +00:00
Merge pull request #27737 from yifan-gu/grace_period
Automatic merge from submit-queue rkt: Refactor grace termination period. Add `TimeoutStopSec` service option to support grace termination. Found we can improve the grace-period-termination by adding a systemd service option. cc @kubernetes/sig-rktnetes
This commit is contained in:
commit
89bb77d3e8
@ -1149,6 +1149,7 @@ func (r *Runtime) preparePod(pod *api.Pod, podIP string, pullSecrets []api.Secre
|
||||
newUnitOption("Service", "ExecStopPost", markPodFinished),
|
||||
// This enables graceful stop.
|
||||
newUnitOption("Service", "KillMode", "mixed"),
|
||||
newUnitOption("Service", "TimeoutStopSec", fmt.Sprintf("%ds", getPodTerminationGracePeriodInSecond(pod))),
|
||||
// Track pod info for garbage collection
|
||||
newUnitOption(unitKubernetesSection, unitPodUID, string(pod.UID)),
|
||||
newUnitOption(unitKubernetesSection, unitPodName, pod.Name),
|
||||
@ -1572,14 +1573,22 @@ func (r *Runtime) GetPods(all bool) ([]*kubecontainer.Pod, error) {
|
||||
return result, nil
|
||||
}
|
||||
|
||||
func (r *Runtime) waitPreStopHooks(pod *api.Pod, runningPod *kubecontainer.Pod) {
|
||||
gracePeriod := int64(minimumGracePeriodInSeconds)
|
||||
func getPodTerminationGracePeriodInSecond(pod *api.Pod) int64 {
|
||||
var gracePeriod int64
|
||||
switch {
|
||||
case pod.DeletionGracePeriodSeconds != nil:
|
||||
gracePeriod = *pod.DeletionGracePeriodSeconds
|
||||
case pod.Spec.TerminationGracePeriodSeconds != nil:
|
||||
gracePeriod = *pod.Spec.TerminationGracePeriodSeconds
|
||||
}
|
||||
if gracePeriod < minimumGracePeriodInSeconds {
|
||||
gracePeriod = minimumGracePeriodInSeconds
|
||||
}
|
||||
return gracePeriod
|
||||
}
|
||||
|
||||
func (r *Runtime) waitPreStopHooks(pod *api.Pod, runningPod *kubecontainer.Pod) {
|
||||
gracePeriod := getPodTerminationGracePeriodInSecond(pod)
|
||||
|
||||
done := make(chan struct{})
|
||||
go func() {
|
||||
|
Loading…
Reference in New Issue
Block a user