Skip to content

Commit 78a36a8

Browse files
author
乔普
committed
scheduler: export FindOneNode
Signed-off-by: 乔普 <wangjianyu.wjy@alibaba-inc.com>
1 parent 1399086 commit 78a36a8

File tree

2 files changed

+16
-11
lines changed

2 files changed

+16
-11
lines changed

pkg/scheduler/frameworkext/framework_extender.go

Lines changed: 15 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -295,22 +295,26 @@ func (ext *frameworkExtenderImpl) RunPreFilterPlugins(ctx context.Context, cycle
295295
return nil, status
296296
}
297297
}
298+
nodeName, status := ext.RunFindOneNodePlugin(ctx, cycleState, pod, result)
299+
if status.IsSkip() {
300+
return result, nil
301+
}
302+
if !status.IsSuccess() {
303+
status.SetFailedPlugin(ext.findOneNodePlugin.Name())
304+
klog.ErrorS(status.AsError(), "Failed to run FindOneNodePlugin", "pod", klog.KObj(pod), "plugin", ext.findOneNodePlugin.Name())
305+
return nil, status
306+
}
307+
return &framework.PreFilterResult{NodeNames: sets.New[string](nodeName)}, nil
308+
}
309+
310+
func (ext *frameworkExtenderImpl) RunFindOneNodePlugin(ctx context.Context, cycleState *framework.CycleState, pod *corev1.Pod, result *framework.PreFilterResult) (string, *framework.Status) {
298311
if ext.findOneNodePlugin != nil {
299312
startTime := time.Now()
300313
nodeName, status := ext.findOneNodePlugin.FindOneNode(ctx, cycleState, pod, result)
301314
ext.metricsRecorder.ObservePluginDurationAsync("FindOneNodePlugin", ext.findOneNodePlugin.Name(), status.Code().String(), metrics.SinceInSeconds(startTime))
302-
if status.IsSkip() {
303-
return result, nil
304-
}
305-
if !status.IsSuccess() {
306-
status.SetFailedPlugin(ext.findOneNodePlugin.Name())
307-
klog.ErrorS(status.AsError(), "Failed to run FindOneNodePlugin", "pod", klog.KObj(pod), "plugin", ext.findOneNodePlugin.Name())
308-
return nil, status
309-
}
310-
return &framework.PreFilterResult{NodeNames: sets.New[string](nodeName)}, nil
315+
return nodeName, status
311316
}
312-
313-
return result, nil
317+
return "", framework.NewStatus(framework.Skip)
314318
}
315319

316320
// RunFilterPluginsWithNominatedPods transforms the Filter phase of framework with filter transformers.

pkg/scheduler/frameworkext/interface.go

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -62,6 +62,7 @@ type FrameworkExtender interface {
6262
framework.Framework
6363
ExtendedHandle
6464

65+
RunFindOneNodePlugin(ctx context.Context, cycleState *framework.CycleState, pod *corev1.Pod, result *framework.PreFilterResult) (string, *framework.Status)
6566
SetConfiguredPlugins(plugins *schedconfig.Plugins)
6667

6768
RunReservationExtensionPreRestoreReservation(ctx context.Context, cycleState *framework.CycleState, pod *corev1.Pod) *framework.Status

0 commit comments

Comments
 (0)