Skip to content

Commit 05e4dc3

Browse files
ZiMengShengwangjianyu.wjy
andauthored
scheduler: fix too many ut log (#2154)
Signed-off-by: wangjianyu.wjy <wangjianyu.wjy@alibaba-inc.com> Co-authored-by: wangjianyu.wjy <wangjianyu.wjy@alibaba-inc.com>
1 parent c08ed75 commit 05e4dc3

File tree

3 files changed

+12
-14
lines changed

3 files changed

+12
-14
lines changed

go.mod

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -131,7 +131,7 @@ require (
131131
github.com/gin-contrib/sse v0.1.0 // indirect
132132
github.com/go-kit/log v0.2.1
133133
github.com/go-logfmt/logfmt v0.5.1 // indirect
134-
github.com/go-logr/logr v1.2.4 // indirect
134+
github.com/go-logr/logr v1.2.4
135135
github.com/go-logr/zapr v1.2.4 // indirect
136136
github.com/go-openapi/jsonpointer v0.19.6 // indirect
137137
github.com/go-openapi/jsonreference v0.20.2 // indirect

pkg/scheduler/plugins/coscheduling/core/core.go

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -216,7 +216,7 @@ func (pgMgr *PodGroupManager) ActivateSiblings(pod *corev1.Pod, state *framework
216216
for _, siblingPod := range toActivePods {
217217
namespacedName := util.GetId(siblingPod.Namespace, siblingPod.Name)
218218
s.Map[namespacedName] = siblingPod
219-
klog.InfoS("ActivateSiblings add pod's key to PodsToActivate map", "pod", namespacedName)
219+
klog.V(4).InfoS("ActivateSiblings add pod's key to PodsToActivate map", "pod", namespacedName)
220220
}
221221
s.Unlock()
222222
}
@@ -507,7 +507,7 @@ func (pgMgr *PodGroupManager) AllowGangGroup(pod *corev1.Pod, handle framework.H
507507
podGangId := util.GetId(waitingPod.GetPod().Namespace, util.GetGangNameByPod(waitingPod.GetPod()))
508508
for _, gangIdTmp := range gangSlices {
509509
if podGangId == gangIdTmp {
510-
klog.InfoS("Permit allows pod from gang", "gang", podGangId, "pod", klog.KObj(waitingPod.GetPod()))
510+
klog.V(4).InfoS("Permit allows pod from gang", "gang", podGangId, "pod", klog.KObj(waitingPod.GetPod()))
511511
waitingPod.Allow(pluginName)
512512
break
513513
}

pkg/scheduler/plugins/coscheduling/coscheduling_test.go

Lines changed: 9 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -27,6 +27,7 @@ import (
2727
"testing"
2828
"time"
2929

30+
"github.com/go-logr/logr"
3031
"github.com/stretchr/testify/assert"
3132
corev1 "k8s.io/api/core/v1"
3233
metav1 "k8s.io/apimachinery/pkg/apis/meta/v1"
@@ -1049,8 +1050,7 @@ func TestFairness(t *testing.T) {
10491050
assert.NoError(t, err)
10501051
eventBroadcaster.StartRecordingToSink(ctx.Done())
10511052
suit.start()
1052-
logger := klog.FromContext(ctx)
1053-
sched.SchedulingQueue.Run(logger)
1053+
sched.SchedulingQueue.Run(logr.Discard())
10541054

10551055
var scheduleOrder []*debugPodScheduleInfo
10561056

@@ -1135,7 +1135,7 @@ func simulateScheduleOne(t *testing.T, ctx context.Context, sched *scheduler.Sch
11351135
}
11361136
*scheduleOrder = append(*scheduleOrder, scheduleInfo)
11371137
fwk := suit.Handle.(framework.Framework)
1138-
klog.InfoS("Attempting to schedule pod", "pod", klog.KObj(pod))
1138+
klog.V(4).InfoS("Attempting to schedule pod", "pod", klog.KObj(pod))
11391139

11401140
// Synchronously attempt to find a fit for the pod.
11411141
state := framework.NewCycleState()
@@ -1155,7 +1155,7 @@ func simulateScheduleOne(t *testing.T, ctx context.Context, sched *scheduler.Sch
11551155
// Run PostFilter plugins to try to make the pod schedulable in a future scheduling cycle.
11561156
_, status := suit.plugin.(*Coscheduling).PostFilter(ctx, state, pod, fitError.Diagnosis.NodeToStatusMap)
11571157
assert.False(t, status.IsSuccess())
1158-
klog.Info("sched.Error:" + podInfo.Pod.Name)
1158+
klog.V(4).Info("sched.Error:" + podInfo.Pod.Name)
11591159
sched.FailureHandler(ctx, fwk, podInfo, status, &framework.NominatingInfo{}, time.Time{})
11601160
}
11611161
return
@@ -1180,7 +1180,7 @@ func simulateScheduleOne(t *testing.T, ctx context.Context, sched *scheduler.Sch
11801180

11811181
// At the end of a successful scheduling cycle, pop and move up Pods if needed.
11821182
if len(podsToActivate.Map) != 0 {
1183-
sched.SchedulingQueue.Activate(klog.FromContext(ctx), podsToActivate.Map)
1183+
sched.SchedulingQueue.Activate(logr.Discard(), podsToActivate.Map)
11841184
// Clear the entries after activation.
11851185
podsToActivate.Map = make(map[string]*corev1.Pod)
11861186
}
@@ -1194,7 +1194,7 @@ func simulateScheduleOne(t *testing.T, ctx context.Context, sched *scheduler.Sch
11941194
if !waitOnPermitStatus.IsSuccess() {
11951195
// trigger un-reserve plugins to clean up state associated with the reserved Pod
11961196
fwk.RunReservePluginsUnreserve(bindingCycleCtx, state, assumedPod, scheduleResult.SuggestedHost)
1197-
klog.Info("sched.Error:" + assumedPodInfo.Pod.Name)
1197+
klog.V(4).Info("sched.Error:" + assumedPodInfo.Pod.Name)
11981198
sched.FailureHandler(ctx, fwk, assumedPodInfo, waitOnPermitStatus, &framework.NominatingInfo{}, time.Time{})
11991199
return
12001200
}
@@ -1204,8 +1204,7 @@ func simulateScheduleOne(t *testing.T, ctx context.Context, sched *scheduler.Sch
12041204

12051205
// At the end of a successful binding cycle, move up Pods if needed.
12061206
if len(podsToActivate.Map) != 0 {
1207-
logger := klog.FromContext(ctx)
1208-
sched.SchedulingQueue.Activate(logger, podsToActivate.Map)
1207+
sched.SchedulingQueue.Activate(logr.Discard(), podsToActivate.Map)
12091208
// Unlike the logic in scheduling cycle, we don't bother deleting the entries
12101209
// as `podsToActivate.Map` is no longer consumed.
12111210
}
@@ -1326,7 +1325,7 @@ func TestDeadLockFree(t *testing.T) {
13261325
assert.NoError(t, err)
13271326
eventBroadcaster.StartRecordingToSink(ctx.Done())
13281327
suit.start()
1329-
sched.SchedulingQueue.Run(klog.FromContext(ctx))
1328+
sched.SchedulingQueue.Run(logr.Discard())
13301329

13311330
var scheduleOrder []*debugPodScheduleInfo
13321331

@@ -1445,8 +1444,7 @@ func TestNoRejectWhenInvalidCycle(t *testing.T) {
14451444
assert.NoError(t, err)
14461445
eventBroadcaster.StartRecordingToSink(ctx.Done())
14471446
suit.start()
1448-
logger := klog.FromContext(ctx)
1449-
sched.SchedulingQueue.Run(logger)
1447+
sched.SchedulingQueue.Run(logr.Discard())
14501448

14511449
var scheduleOrder []*debugPodScheduleInfo
14521450

0 commit comments

Comments
 (0)