mirror of
https://github.com/kubernetes-sigs/descheduler.git
synced 2026-01-26 13:29:11 +01:00
Add an extra parameter ExitCode to RemoveFailedPod
Update README.md Fix README and test files Update README Address a7i's comments Update README
This commit is contained in:
@@ -148,6 +148,17 @@ func validateCanEvict(pod *v1.Pod, failedPodArgs *RemoveFailedPodsArgs) error {
|
||||
}
|
||||
}
|
||||
|
||||
if len(failedPodArgs.ExitCodes) > 0 {
|
||||
exitCodes := getFailedContainerStatusExitCodes(pod.Status.ContainerStatuses)
|
||||
if failedPodArgs.IncludingInitContainers {
|
||||
exitCodes = append(exitCodes, getFailedContainerStatusExitCodes(pod.Status.InitContainerStatuses)...)
|
||||
}
|
||||
|
||||
if !sets.New(failedPodArgs.ExitCodes...).HasAny(exitCodes...) {
|
||||
errs = append(errs, fmt.Errorf("pod does not match any of the exitCodes"))
|
||||
}
|
||||
}
|
||||
|
||||
return utilerrors.NewAggregate(errs)
|
||||
}
|
||||
|
||||
@@ -165,3 +176,15 @@ func getFailedContainerStatusReasons(containerStatuses []v1.ContainerStatus) []s
|
||||
|
||||
return reasons
|
||||
}
|
||||
|
||||
func getFailedContainerStatusExitCodes(containerStatuses []v1.ContainerStatus) []int32 {
|
||||
exitCodes := make([]int32, 0)
|
||||
|
||||
for _, containerStatus := range containerStatuses {
|
||||
if containerStatus.State.Terminated != nil {
|
||||
exitCodes = append(exitCodes, containerStatus.State.Terminated.ExitCode)
|
||||
}
|
||||
}
|
||||
|
||||
return exitCodes
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user