kubelet status manager: short-circut the evaluation if possible

This avoids redundant checks in the `PodResourcesAreReclaimed`, which
also logs misleading "Pod is terminated" messages on every check.
pull/6/head
Yu-Ju Hong 2017-05-30 15:58:40 -07:00
parent 017e61c76f
commit ccfecb1ebd
1 changed files with 4 additions and 1 deletions

View File

@ -483,7 +483,10 @@ func (m *manager) needsUpdate(uid types.UID, status versionedPodStatus) bool {
}
func (m *manager) canBeDeleted(pod *v1.Pod, status v1.PodStatus) bool {
return !kubepod.IsMirrorPod(pod) && m.podDeletionSafety.PodResourcesAreReclaimed(pod, status) && pod.DeletionTimestamp != nil
if pod.DeletionTimestamp == nil || kubepod.IsMirrorPod(pod) {
return false
}
return m.podDeletionSafety.PodResourcesAreReclaimed(pod, status)
}
// needsReconcile compares the given status with the status in the pod manager (which