Merge pull request #120933 from mengjiao-liu/contextual-logging-scheduler-remaining-part
kube-scheduler: convert the remaining part to use contextual logging
This commit is contained in:
@@ -1521,8 +1521,8 @@ func initTestPreferNominatedNode(t *testing.T, nsPrefix string, opts ...schedule
|
||||
testutils.SyncSchedulerInformerFactory(testCtx)
|
||||
// wraps the NextPod() method to make it appear the preemption has been done already and the nominated node has been set.
|
||||
f := testCtx.Scheduler.NextPod
|
||||
testCtx.Scheduler.NextPod = func() (*framework.QueuedPodInfo, error) {
|
||||
podInfo, _ := f()
|
||||
testCtx.Scheduler.NextPod = func(logger klog.Logger) (*framework.QueuedPodInfo, error) {
|
||||
podInfo, _ := f(klog.FromContext(testCtx.Ctx))
|
||||
// Scheduler.Next() may return nil when scheduler is shutting down.
|
||||
if podInfo != nil {
|
||||
podInfo.Pod.Status.NominatedNodeName = "node-1"
|
||||
|
@@ -1145,10 +1145,11 @@ func NextPodOrDie(t *testing.T, testCtx *TestContext) *schedulerframework.Queued
|
||||
t.Helper()
|
||||
|
||||
var podInfo *schedulerframework.QueuedPodInfo
|
||||
logger := klog.FromContext(testCtx.Ctx)
|
||||
// NextPod() is a blocking operation. Wrap it in timeout() to avoid relying on
|
||||
// default go testing timeout (10m) to abort.
|
||||
if err := timeout(testCtx.Ctx, time.Second*5, func() {
|
||||
podInfo, _ = testCtx.Scheduler.NextPod()
|
||||
podInfo, _ = testCtx.Scheduler.NextPod(logger)
|
||||
}); err != nil {
|
||||
t.Fatalf("Timed out waiting for the Pod to be popped: %v", err)
|
||||
}
|
||||
@@ -1160,10 +1161,11 @@ func NextPod(t *testing.T, testCtx *TestContext) *schedulerframework.QueuedPodIn
|
||||
t.Helper()
|
||||
|
||||
var podInfo *schedulerframework.QueuedPodInfo
|
||||
logger := klog.FromContext(testCtx.Ctx)
|
||||
// NextPod() is a blocking operation. Wrap it in timeout() to avoid relying on
|
||||
// default go testing timeout (10m) to abort.
|
||||
if err := timeout(testCtx.Ctx, time.Second*5, func() {
|
||||
podInfo, _ = testCtx.Scheduler.NextPod()
|
||||
podInfo, _ = testCtx.Scheduler.NextPod(logger)
|
||||
}); err != nil {
|
||||
return nil
|
||||
}
|
||||
|
Reference in New Issue
Block a user