kubelet: perform the admission checks that preemption will not help first to avoid meaningless pod eviction
This commit is contained in:
parent
d2be69ac11
commit
18c86efeea
@ -69,6 +69,23 @@ func (w *predicateAdmitHandler) Admit(attrs *PodAdmitAttributes) PodAdmitResult
|
||||
}
|
||||
}
|
||||
admitPod := attrs.Pod
|
||||
|
||||
// perform the checks that preemption will not help first to avoid meaningless pod eviction
|
||||
if rejectPodAdmissionBasedOnOSSelector(admitPod, node) {
|
||||
return PodAdmitResult{
|
||||
Admit: false,
|
||||
Reason: "PodOSSelectorNodeLabelDoesNotMatch",
|
||||
Message: "Failed to admit pod as the `kubernetes.io/os` label doesn't match node label",
|
||||
}
|
||||
}
|
||||
if rejectPodAdmissionBasedOnOSField(admitPod) {
|
||||
return PodAdmitResult{
|
||||
Admit: false,
|
||||
Reason: "PodOSNotSupported",
|
||||
Message: "Failed to admit pod as the OS field doesn't match node OS",
|
||||
}
|
||||
}
|
||||
|
||||
pods := attrs.OtherPods
|
||||
nodeInfo := schedulerframework.NewNodeInfo(pods...)
|
||||
nodeInfo.SetNode(node)
|
||||
@ -142,21 +159,6 @@ func (w *predicateAdmitHandler) Admit(attrs *PodAdmitAttributes) PodAdmitResult
|
||||
Message: message,
|
||||
}
|
||||
}
|
||||
if rejectPodAdmissionBasedOnOSSelector(admitPod, node) {
|
||||
return PodAdmitResult{
|
||||
Admit: false,
|
||||
Reason: "PodOSSelectorNodeLabelDoesNotMatch",
|
||||
Message: "Failed to admit pod as the `kubernetes.io/os` label doesn't match node label",
|
||||
}
|
||||
}
|
||||
// By this time, node labels should have been synced, this helps in identifying the pod with the usage.
|
||||
if rejectPodAdmissionBasedOnOSField(admitPod) {
|
||||
return PodAdmitResult{
|
||||
Admit: false,
|
||||
Reason: "PodOSNotSupported",
|
||||
Message: "Failed to admit pod as the OS field doesn't match node OS",
|
||||
}
|
||||
}
|
||||
return PodAdmitResult{
|
||||
Admit: true,
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user