mirror of
https://github.com/k3s-io/kubernetes.git
synced 2025-07-24 20:24:09 +00:00
Merge pull request #98103 from gjkim42/delete-static-pod-gracefully
Delete static pod gracefully and fix mirrorPodTerminationMap leak
This commit is contained in:
commit
09f4baed35
@ -1498,6 +1498,13 @@ func (kl *Kubelet) syncPod(o syncPodOptions) error {
|
|||||||
return nil
|
return nil
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// If the pod is a static pod and its mirror pod is still gracefully terminating,
|
||||||
|
// we do not want to start the new static pod until the old static pod is gracefully terminated.
|
||||||
|
podFullName := kubecontainer.GetPodFullName(pod)
|
||||||
|
if kl.podKiller.IsMirrorPodPendingTerminationByPodName(podFullName) {
|
||||||
|
return fmt.Errorf("pod %q is pending termination", podFullName)
|
||||||
|
}
|
||||||
|
|
||||||
// Latency measurements for the main workflow are relative to the
|
// Latency measurements for the main workflow are relative to the
|
||||||
// first time the pod was seen by the API server.
|
// first time the pod was seen by the API server.
|
||||||
var firstSeenTime time.Time
|
var firstSeenTime time.Time
|
||||||
@ -1633,7 +1640,6 @@ func (kl *Kubelet) syncPod(o syncPodOptions) error {
|
|||||||
|
|
||||||
// Create Mirror Pod for Static Pod if it doesn't already exist
|
// Create Mirror Pod for Static Pod if it doesn't already exist
|
||||||
if kubetypes.IsStaticPod(pod) {
|
if kubetypes.IsStaticPod(pod) {
|
||||||
podFullName := kubecontainer.GetPodFullName(pod)
|
|
||||||
deleted := false
|
deleted := false
|
||||||
if mirrorPod != nil {
|
if mirrorPod != nil {
|
||||||
if mirrorPod.DeletionTimestamp != nil || !kl.podManager.IsMirrorPodOf(mirrorPod, pod) {
|
if mirrorPod.DeletionTimestamp != nil || !kl.podManager.IsMirrorPodOf(mirrorPod, pod) {
|
||||||
@ -1764,6 +1770,9 @@ func (kl *Kubelet) deletePod(pod *v1.Pod) error {
|
|||||||
}
|
}
|
||||||
podPair := kubecontainer.PodPair{APIPod: pod, RunningPod: &runningPod}
|
podPair := kubecontainer.PodPair{APIPod: pod, RunningPod: &runningPod}
|
||||||
|
|
||||||
|
if _, ok := kl.podManager.GetMirrorPodByPod(pod); ok {
|
||||||
|
kl.podKiller.MarkMirrorPodPendingTermination(pod)
|
||||||
|
}
|
||||||
kl.podKiller.KillPod(&podPair)
|
kl.podKiller.KillPod(&podPair)
|
||||||
|
|
||||||
// We leave the volume/directory cleanup to the periodic cleanup routine.
|
// We leave the volume/directory cleanup to the periodic cleanup routine.
|
||||||
@ -2102,9 +2111,6 @@ func (kl *Kubelet) HandlePodRemoves(pods []*v1.Pod) {
|
|||||||
kl.handleMirrorPod(pod, start)
|
kl.handleMirrorPod(pod, start)
|
||||||
continue
|
continue
|
||||||
}
|
}
|
||||||
if _, ok := kl.podManager.GetMirrorPodByPod(pod); ok {
|
|
||||||
kl.podKiller.MarkMirrorPodPendingTermination(pod)
|
|
||||||
}
|
|
||||||
// Deletion is allowed to fail because the periodic cleanup routine
|
// Deletion is allowed to fail because the periodic cleanup routine
|
||||||
// will trigger deletion again.
|
// will trigger deletion again.
|
||||||
if err := kl.deletePod(pod); err != nil {
|
if err := kl.deletePod(pod); err != nil {
|
||||||
|
Loading…
Reference in New Issue
Block a user