mirror of
https://github.com/k3s-io/kubernetes.git
synced 2025-11-12 21:40:29 +00:00
scheduler_perf: show name of one pending pod in error message
If pods get stuck, then giving the name of one makes it possible to search for it in the log output. Without the name it's hard to figure out which pods got stuck.
This commit is contained in:
@@ -147,23 +147,28 @@ func mustSetupCluster(ctx context.Context, tb testing.TB, config *config.KubeSch
|
||||
return informerFactory, client, dynClient
|
||||
}
|
||||
|
||||
// Returns the list of scheduled pods in the specified namespaces.
|
||||
// Returns the list of scheduled and unscheduled pods in the specified namespaces.
|
||||
// Note that no namespaces specified matches all namespaces.
|
||||
func getScheduledPods(podInformer coreinformers.PodInformer, namespaces ...string) ([]*v1.Pod, error) {
|
||||
func getScheduledPods(podInformer coreinformers.PodInformer, namespaces ...string) ([]*v1.Pod, []*v1.Pod, error) {
|
||||
pods, err := podInformer.Lister().List(labels.Everything())
|
||||
if err != nil {
|
||||
return nil, err
|
||||
return nil, nil, err
|
||||
}
|
||||
|
||||
s := sets.New(namespaces...)
|
||||
scheduled := make([]*v1.Pod, 0, len(pods))
|
||||
unscheduled := make([]*v1.Pod, 0, len(pods))
|
||||
for i := range pods {
|
||||
pod := pods[i]
|
||||
if len(pod.Spec.NodeName) > 0 && (len(s) == 0 || s.Has(pod.Namespace)) {
|
||||
scheduled = append(scheduled, pod)
|
||||
if len(s) == 0 || s.Has(pod.Namespace) {
|
||||
if len(pod.Spec.NodeName) > 0 {
|
||||
scheduled = append(scheduled, pod)
|
||||
} else {
|
||||
unscheduled = append(unscheduled, pod)
|
||||
}
|
||||
}
|
||||
}
|
||||
return scheduled, nil
|
||||
return scheduled, unscheduled, nil
|
||||
}
|
||||
|
||||
// DataItem is the data point.
|
||||
@@ -355,7 +360,7 @@ func newThroughputCollector(tb testing.TB, podInformer coreinformers.PodInformer
|
||||
}
|
||||
|
||||
func (tc *throughputCollector) run(ctx context.Context) {
|
||||
podsScheduled, err := getScheduledPods(tc.podInformer, tc.namespaces...)
|
||||
podsScheduled, _, err := getScheduledPods(tc.podInformer, tc.namespaces...)
|
||||
if err != nil {
|
||||
klog.Fatalf("%v", err)
|
||||
}
|
||||
@@ -372,7 +377,7 @@ func (tc *throughputCollector) run(ctx context.Context) {
|
||||
return
|
||||
case <-ticker.C:
|
||||
now := time.Now()
|
||||
podsScheduled, err := getScheduledPods(tc.podInformer, tc.namespaces...)
|
||||
podsScheduled, _, err := getScheduledPods(tc.podInformer, tc.namespaces...)
|
||||
if err != nil {
|
||||
klog.Fatalf("%v", err)
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user