diff --git a/pkg/kubelet/status/status_manager.go b/pkg/kubelet/status/status_manager.go index 60e7e5b576d..b9cbc25681e 100644 --- a/pkg/kubelet/status/status_manager.go +++ b/pkg/kubelet/status/status_manager.go @@ -388,7 +388,7 @@ func (m *manager) syncBatch() { } syncedUID = mirrorUID } - if m.needsUpdate(syncedUID, status) { + if m.needsUpdate(syncedUID, status) || m.couldBeDeleted(uid, status.status) { updatedStatuses = append(updatedStatuses, podStatusSyncRequest{uid, status}) } else if m.needsReconcile(uid, status.status) { // Delete the apiStatusVersions here to force an update on the pod status @@ -466,6 +466,15 @@ func (m *manager) needsUpdate(uid types.UID, status versionedPodStatus) bool { return !ok || latest < status.version } +func (m *manager) couldBeDeleted(uid types.UID, status v1.PodStatus) bool { + // The pod could be a static pod, so we should translate first. + pod, ok := m.podManager.GetPodByUID(uid) + if !ok { + return false + } + return !kubepod.IsMirrorPod(pod) && m.podDeletionSafety.OkToDeletePod(pod) +} + // needsReconcile compares the given status with the status in the pod manager (which // in fact comes from apiserver), returns whether the status needs to be reconciled with // the apiserver. Now when pod status is inconsistent between apiserver and kubelet,