@@ -58,6 +58,13 @@ type listerRegistryImpl struct {
5858 statefulSetLister v1appslister.StatefulSetLister
5959}
6060
61+ // PodsBySchedulability is a struct that holds pods classified by their schedulability status.
62+ type PodsBySchedulability struct {
63+ Scheduled []* apiv1.Pod
64+ Unschedulable []* apiv1.Pod
65+ Unprocessed []* apiv1.Pod
66+ }
67+
6168// NewListerRegistry returns a registry providing various listers to list pods or nodes matching conditions
6269func NewListerRegistry (allNode NodeLister , readyNode NodeLister , allPodLister PodLister , podDisruptionBudgetLister PodDisruptionBudgetLister ,
6370 daemonSetLister v1appslister.DaemonSetLister , replicationControllerLister v1lister.ReplicationControllerLister ,
@@ -139,7 +146,7 @@ func (r listerRegistryImpl) StatefulSetLister() v1appslister.StatefulSetLister {
139146}
140147
141148// PodLister lists all pods.
142- // To filter out scheduled, unschedulable, or unprocessed pods the helper method FilterPodsBySchedulability should be used.
149+ // To filter out scheduled, unschedulable, or unprocessed pods the helper method ArrangePodsBySchedulability should be used.
143150type PodLister interface {
144151 List () ([]* apiv1.Pod , error )
145152}
@@ -168,28 +175,30 @@ func ScheduledPods(allPods []*apiv1.Pod) []*apiv1.Pod {
168175 return scheduledPods
169176}
170177
171- // FilterPodsBySchedulability is a helper method that returns all scheduled and unschedulable pods from given pod list.
172- func FilterPodsBySchedulability (allPods []* apiv1.Pod , bypassedSchedulers map [string ]bool ) (scheduled , unschedulable , unprocessed []* apiv1.Pod ) {
178+ // ArrangePodsBySchedulability is a helper method that classifies pods by scheduled, unschedulable,
179+ // and not processed by a scheduler from given pod list.
180+ func ArrangePodsBySchedulability (allPods []* apiv1.Pod , bypassedSchedulers map [string ]bool ) PodsBySchedulability {
181+ var arranged PodsBySchedulability
173182 for _ , pod := range allPods {
174183 if isScheduled (pod ) {
175- scheduled = append (scheduled , pod )
184+ arranged . Scheduled = append (arranged . Scheduled , pod )
176185 continue
177186 } else if isDeleted (pod ) {
178187 continue
179188 } else {
180189 _ , condition := podv1 .GetPodCondition (& pod .Status , apiv1 .PodScheduled )
181190 if ! (condition == nil || condition .Status != apiv1 .ConditionFalse || condition .Reason != apiv1 .PodReasonUnschedulable ) {
182- unschedulable = append (unschedulable , pod )
191+ arranged . Unschedulable = append (arranged . Unschedulable , pod )
183192 } else {
184193 if canBypass := bypassedSchedulers [pod .Spec .SchedulerName ]; canBypass {
185194 if condition == nil || (condition .Status == apiv1 .ConditionFalse && condition .Reason == "" ) {
186- unprocessed = append (unprocessed , pod )
195+ arranged . Unprocessed = append (arranged . Unprocessed , pod )
187196 }
188197 }
189198 }
190199 }
191200 }
192- return scheduled , unschedulable , unprocessed
201+ return arranged
193202}
194203
195204// SchedulingGatedPods is a helper method that returns all pods which has scheduling gate
0 commit comments