kubelet: Delete static pods gracefully

Add a new static pod after checking if its mirror pod is pending termination.
This commit is contained in:
Geonju Kim 2021-01-16 00:57:48 +09:00 committed by Geonju Kim
parent faaae71427
commit 9bcb451d7d

View File

@ -1499,6 +1499,13 @@ func (kl *Kubelet) syncPod(o syncPodOptions) error {
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
// first time the pod was seen by the API server.
var firstSeenTime time.Time
@ -1634,7 +1641,6 @@ func (kl *Kubelet) syncPod(o syncPodOptions) error {
// Create Mirror Pod for Static Pod if it doesn't already exist
if kubetypes.IsStaticPod(pod) {
podFullName := kubecontainer.GetPodFullName(pod)
deleted := false
if mirrorPod != nil {
if mirrorPod.DeletionTimestamp != nil || !kl.podManager.IsMirrorPodOf(mirrorPod, pod) {