mirror of
https://github.com/k3s-io/kubernetes.git
synced 2025-07-23 19:56:01 +00:00
periodically check if pod can be deleted
This commit is contained in:
parent
9094b57570
commit
b1b9686c91
@ -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,
|
||||
|
Loading…
Reference in New Issue
Block a user