ReplicaSet controller should count terminating pods in the status

This commit is contained in:
Filip Křepinský
2024-02-29 19:00:53 +01:00
parent 28437797b5
commit dc1914c61c
6 changed files with 375 additions and 32 deletions

View File

@@ -973,6 +973,21 @@ func compareMaxContainerRestarts(pi *v1.Pod, pj *v1.Pod) *bool {
return nil
}
// FilterClaimedPods returns pods that are controlled by the controller and match the selector.
func FilterClaimedPods(controller metav1.Object, selector labels.Selector, pods []*v1.Pod) []*v1.Pod {
var result []*v1.Pod
for _, pod := range pods {
if !metav1.IsControlledBy(pod, controller) {
// It's an orphan or owned by someone else.
continue
}
if selector.Matches(labels.Set(pod.Labels)) {
result = append(result, pod)
}
}
return result
}
// FilterActivePods returns pods that have not terminated.
func FilterActivePods(logger klog.Logger, pods []*v1.Pod) []*v1.Pod {
var result []*v1.Pod