|
|
@@ -85,6 +85,7 @@ type frameworkImpl struct {
|
|
|
|
informerFactory informers.SharedInformerFactory
|
|
|
|
informerFactory informers.SharedInformerFactory
|
|
|
|
|
|
|
|
|
|
|
|
metricsRecorder *metricsRecorder
|
|
|
|
metricsRecorder *metricsRecorder
|
|
|
|
|
|
|
|
profileName string
|
|
|
|
|
|
|
|
|
|
|
|
preemptHandle framework.PreemptHandle
|
|
|
|
preemptHandle framework.PreemptHandle
|
|
|
|
|
|
|
|
|
|
|
@@ -127,6 +128,7 @@ type frameworkOptions struct {
|
|
|
|
informerFactory informers.SharedInformerFactory
|
|
|
|
informerFactory informers.SharedInformerFactory
|
|
|
|
snapshotSharedLister framework.SharedLister
|
|
|
|
snapshotSharedLister framework.SharedLister
|
|
|
|
metricsRecorder *metricsRecorder
|
|
|
|
metricsRecorder *metricsRecorder
|
|
|
|
|
|
|
|
profileName string
|
|
|
|
podNominator framework.PodNominator
|
|
|
|
podNominator framework.PodNominator
|
|
|
|
extenders []framework.Extender
|
|
|
|
extenders []framework.Extender
|
|
|
|
runAllFilters bool
|
|
|
|
runAllFilters bool
|
|
|
@@ -171,6 +173,13 @@ func WithRunAllFilters(runAllFilters bool) Option {
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
// WithProfileName sets the profile name.
|
|
|
|
|
|
|
|
func WithProfileName(name string) Option {
|
|
|
|
|
|
|
|
return func(o *frameworkOptions) {
|
|
|
|
|
|
|
|
o.profileName = name
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
// withMetricsRecorder is only used in tests.
|
|
|
|
// withMetricsRecorder is only used in tests.
|
|
|
|
func withMetricsRecorder(recorder *metricsRecorder) Option {
|
|
|
|
func withMetricsRecorder(recorder *metricsRecorder) Option {
|
|
|
|
return func(o *frameworkOptions) {
|
|
|
|
return func(o *frameworkOptions) {
|
|
|
@@ -228,6 +237,7 @@ func NewFramework(r Registry, plugins *config.Plugins, args []config.PluginConfi
|
|
|
|
eventRecorder: options.eventRecorder,
|
|
|
|
eventRecorder: options.eventRecorder,
|
|
|
|
informerFactory: options.informerFactory,
|
|
|
|
informerFactory: options.informerFactory,
|
|
|
|
metricsRecorder: options.metricsRecorder,
|
|
|
|
metricsRecorder: options.metricsRecorder,
|
|
|
|
|
|
|
|
profileName: options.profileName,
|
|
|
|
runAllFilters: options.runAllFilters,
|
|
|
|
runAllFilters: options.runAllFilters,
|
|
|
|
}
|
|
|
|
}
|
|
|
|
f.preemptHandle = &preemptHandle{
|
|
|
|
f.preemptHandle = &preemptHandle{
|
|
|
@@ -381,7 +391,7 @@ func (f *frameworkImpl) QueueSortFunc() framework.LessFunc {
|
|
|
|
func (f *frameworkImpl) RunPreFilterPlugins(ctx context.Context, state *framework.CycleState, pod *v1.Pod) (status *framework.Status) {
|
|
|
|
func (f *frameworkImpl) RunPreFilterPlugins(ctx context.Context, state *framework.CycleState, pod *v1.Pod) (status *framework.Status) {
|
|
|
|
startTime := time.Now()
|
|
|
|
startTime := time.Now()
|
|
|
|
defer func() {
|
|
|
|
defer func() {
|
|
|
|
metrics.FrameworkExtensionPointDuration.WithLabelValues(preFilter, status.Code().String()).Observe(metrics.SinceInSeconds(startTime))
|
|
|
|
metrics.FrameworkExtensionPointDuration.WithLabelValues(preFilter, status.Code().String(), f.profileName).Observe(metrics.SinceInSeconds(startTime))
|
|
|
|
}()
|
|
|
|
}()
|
|
|
|
for _, pl := range f.preFilterPlugins {
|
|
|
|
for _, pl := range f.preFilterPlugins {
|
|
|
|
status = f.runPreFilterPlugin(ctx, pl, state, pod)
|
|
|
|
status = f.runPreFilterPlugin(ctx, pl, state, pod)
|
|
|
@@ -528,7 +538,7 @@ func (f *frameworkImpl) runFilterPlugin(ctx context.Context, pl framework.Filter
|
|
|
|
func (f *frameworkImpl) RunPostFilterPlugins(ctx context.Context, state *framework.CycleState, pod *v1.Pod, filteredNodeStatusMap framework.NodeToStatusMap) (_ *framework.PostFilterResult, status *framework.Status) {
|
|
|
|
func (f *frameworkImpl) RunPostFilterPlugins(ctx context.Context, state *framework.CycleState, pod *v1.Pod, filteredNodeStatusMap framework.NodeToStatusMap) (_ *framework.PostFilterResult, status *framework.Status) {
|
|
|
|
startTime := time.Now()
|
|
|
|
startTime := time.Now()
|
|
|
|
defer func() {
|
|
|
|
defer func() {
|
|
|
|
metrics.FrameworkExtensionPointDuration.WithLabelValues(postFilter, status.Code().String()).Observe(metrics.SinceInSeconds(startTime))
|
|
|
|
metrics.FrameworkExtensionPointDuration.WithLabelValues(postFilter, status.Code().String(), f.profileName).Observe(metrics.SinceInSeconds(startTime))
|
|
|
|
}()
|
|
|
|
}()
|
|
|
|
|
|
|
|
|
|
|
|
statuses := make(framework.PluginToStatus)
|
|
|
|
statuses := make(framework.PluginToStatus)
|
|
|
@@ -566,7 +576,7 @@ func (f *frameworkImpl) RunPreScorePlugins(
|
|
|
|
) (status *framework.Status) {
|
|
|
|
) (status *framework.Status) {
|
|
|
|
startTime := time.Now()
|
|
|
|
startTime := time.Now()
|
|
|
|
defer func() {
|
|
|
|
defer func() {
|
|
|
|
metrics.FrameworkExtensionPointDuration.WithLabelValues(preScore, status.Code().String()).Observe(metrics.SinceInSeconds(startTime))
|
|
|
|
metrics.FrameworkExtensionPointDuration.WithLabelValues(preScore, status.Code().String(), f.profileName).Observe(metrics.SinceInSeconds(startTime))
|
|
|
|
}()
|
|
|
|
}()
|
|
|
|
for _, pl := range f.preScorePlugins {
|
|
|
|
for _, pl := range f.preScorePlugins {
|
|
|
|
status = f.runPreScorePlugin(ctx, pl, state, pod, nodes)
|
|
|
|
status = f.runPreScorePlugin(ctx, pl, state, pod, nodes)
|
|
|
@@ -597,7 +607,7 @@ func (f *frameworkImpl) runPreScorePlugin(ctx context.Context, pl framework.PreS
|
|
|
|
func (f *frameworkImpl) RunScorePlugins(ctx context.Context, state *framework.CycleState, pod *v1.Pod, nodes []*v1.Node) (ps framework.PluginToNodeScores, status *framework.Status) {
|
|
|
|
func (f *frameworkImpl) RunScorePlugins(ctx context.Context, state *framework.CycleState, pod *v1.Pod, nodes []*v1.Node) (ps framework.PluginToNodeScores, status *framework.Status) {
|
|
|
|
startTime := time.Now()
|
|
|
|
startTime := time.Now()
|
|
|
|
defer func() {
|
|
|
|
defer func() {
|
|
|
|
metrics.FrameworkExtensionPointDuration.WithLabelValues(score, status.Code().String()).Observe(metrics.SinceInSeconds(startTime))
|
|
|
|
metrics.FrameworkExtensionPointDuration.WithLabelValues(score, status.Code().String(), f.profileName).Observe(metrics.SinceInSeconds(startTime))
|
|
|
|
}()
|
|
|
|
}()
|
|
|
|
pluginToNodeScores := make(framework.PluginToNodeScores, len(f.scorePlugins))
|
|
|
|
pluginToNodeScores := make(framework.PluginToNodeScores, len(f.scorePlugins))
|
|
|
|
for _, pl := range f.scorePlugins {
|
|
|
|
for _, pl := range f.scorePlugins {
|
|
|
@@ -699,7 +709,7 @@ func (f *frameworkImpl) runScoreExtension(ctx context.Context, pl framework.Scor
|
|
|
|
func (f *frameworkImpl) RunPreBindPlugins(ctx context.Context, state *framework.CycleState, pod *v1.Pod, nodeName string) (status *framework.Status) {
|
|
|
|
func (f *frameworkImpl) RunPreBindPlugins(ctx context.Context, state *framework.CycleState, pod *v1.Pod, nodeName string) (status *framework.Status) {
|
|
|
|
startTime := time.Now()
|
|
|
|
startTime := time.Now()
|
|
|
|
defer func() {
|
|
|
|
defer func() {
|
|
|
|
metrics.FrameworkExtensionPointDuration.WithLabelValues(preBind, status.Code().String()).Observe(metrics.SinceInSeconds(startTime))
|
|
|
|
metrics.FrameworkExtensionPointDuration.WithLabelValues(preBind, status.Code().String(), f.profileName).Observe(metrics.SinceInSeconds(startTime))
|
|
|
|
}()
|
|
|
|
}()
|
|
|
|
for _, pl := range f.preBindPlugins {
|
|
|
|
for _, pl := range f.preBindPlugins {
|
|
|
|
status = f.runPreBindPlugin(ctx, pl, state, pod, nodeName)
|
|
|
|
status = f.runPreBindPlugin(ctx, pl, state, pod, nodeName)
|
|
|
@@ -726,7 +736,7 @@ func (f *frameworkImpl) runPreBindPlugin(ctx context.Context, pl framework.PreBi
|
|
|
|
func (f *frameworkImpl) RunBindPlugins(ctx context.Context, state *framework.CycleState, pod *v1.Pod, nodeName string) (status *framework.Status) {
|
|
|
|
func (f *frameworkImpl) RunBindPlugins(ctx context.Context, state *framework.CycleState, pod *v1.Pod, nodeName string) (status *framework.Status) {
|
|
|
|
startTime := time.Now()
|
|
|
|
startTime := time.Now()
|
|
|
|
defer func() {
|
|
|
|
defer func() {
|
|
|
|
metrics.FrameworkExtensionPointDuration.WithLabelValues(bind, status.Code().String()).Observe(metrics.SinceInSeconds(startTime))
|
|
|
|
metrics.FrameworkExtensionPointDuration.WithLabelValues(bind, status.Code().String(), f.profileName).Observe(metrics.SinceInSeconds(startTime))
|
|
|
|
}()
|
|
|
|
}()
|
|
|
|
if len(f.bindPlugins) == 0 {
|
|
|
|
if len(f.bindPlugins) == 0 {
|
|
|
|
return framework.NewStatus(framework.Skip, "")
|
|
|
|
return framework.NewStatus(framework.Skip, "")
|
|
|
@@ -760,7 +770,7 @@ func (f *frameworkImpl) runBindPlugin(ctx context.Context, bp framework.BindPlug
|
|
|
|
func (f *frameworkImpl) RunPostBindPlugins(ctx context.Context, state *framework.CycleState, pod *v1.Pod, nodeName string) {
|
|
|
|
func (f *frameworkImpl) RunPostBindPlugins(ctx context.Context, state *framework.CycleState, pod *v1.Pod, nodeName string) {
|
|
|
|
startTime := time.Now()
|
|
|
|
startTime := time.Now()
|
|
|
|
defer func() {
|
|
|
|
defer func() {
|
|
|
|
metrics.FrameworkExtensionPointDuration.WithLabelValues(postBind, framework.Success.String()).Observe(metrics.SinceInSeconds(startTime))
|
|
|
|
metrics.FrameworkExtensionPointDuration.WithLabelValues(postBind, framework.Success.String(), f.profileName).Observe(metrics.SinceInSeconds(startTime))
|
|
|
|
}()
|
|
|
|
}()
|
|
|
|
for _, pl := range f.postBindPlugins {
|
|
|
|
for _, pl := range f.postBindPlugins {
|
|
|
|
f.runPostBindPlugin(ctx, pl, state, pod, nodeName)
|
|
|
|
f.runPostBindPlugin(ctx, pl, state, pod, nodeName)
|
|
|
@@ -783,7 +793,7 @@ func (f *frameworkImpl) runPostBindPlugin(ctx context.Context, pl framework.Post
|
|
|
|
func (f *frameworkImpl) RunReservePlugins(ctx context.Context, state *framework.CycleState, pod *v1.Pod, nodeName string) (status *framework.Status) {
|
|
|
|
func (f *frameworkImpl) RunReservePlugins(ctx context.Context, state *framework.CycleState, pod *v1.Pod, nodeName string) (status *framework.Status) {
|
|
|
|
startTime := time.Now()
|
|
|
|
startTime := time.Now()
|
|
|
|
defer func() {
|
|
|
|
defer func() {
|
|
|
|
metrics.FrameworkExtensionPointDuration.WithLabelValues(reserve, status.Code().String()).Observe(metrics.SinceInSeconds(startTime))
|
|
|
|
metrics.FrameworkExtensionPointDuration.WithLabelValues(reserve, status.Code().String(), f.profileName).Observe(metrics.SinceInSeconds(startTime))
|
|
|
|
}()
|
|
|
|
}()
|
|
|
|
for _, pl := range f.reservePlugins {
|
|
|
|
for _, pl := range f.reservePlugins {
|
|
|
|
status = f.runReservePlugin(ctx, pl, state, pod, nodeName)
|
|
|
|
status = f.runReservePlugin(ctx, pl, state, pod, nodeName)
|
|
|
@@ -810,7 +820,7 @@ func (f *frameworkImpl) runReservePlugin(ctx context.Context, pl framework.Reser
|
|
|
|
func (f *frameworkImpl) RunUnreservePlugins(ctx context.Context, state *framework.CycleState, pod *v1.Pod, nodeName string) {
|
|
|
|
func (f *frameworkImpl) RunUnreservePlugins(ctx context.Context, state *framework.CycleState, pod *v1.Pod, nodeName string) {
|
|
|
|
startTime := time.Now()
|
|
|
|
startTime := time.Now()
|
|
|
|
defer func() {
|
|
|
|
defer func() {
|
|
|
|
metrics.FrameworkExtensionPointDuration.WithLabelValues(unreserve, framework.Success.String()).Observe(metrics.SinceInSeconds(startTime))
|
|
|
|
metrics.FrameworkExtensionPointDuration.WithLabelValues(unreserve, framework.Success.String(), f.profileName).Observe(metrics.SinceInSeconds(startTime))
|
|
|
|
}()
|
|
|
|
}()
|
|
|
|
for _, pl := range f.unreservePlugins {
|
|
|
|
for _, pl := range f.unreservePlugins {
|
|
|
|
f.runUnreservePlugin(ctx, pl, state, pod, nodeName)
|
|
|
|
f.runUnreservePlugin(ctx, pl, state, pod, nodeName)
|
|
|
@@ -836,7 +846,7 @@ func (f *frameworkImpl) runUnreservePlugin(ctx context.Context, pl framework.Unr
|
|
|
|
func (f *frameworkImpl) RunPermitPlugins(ctx context.Context, state *framework.CycleState, pod *v1.Pod, nodeName string) (status *framework.Status) {
|
|
|
|
func (f *frameworkImpl) RunPermitPlugins(ctx context.Context, state *framework.CycleState, pod *v1.Pod, nodeName string) (status *framework.Status) {
|
|
|
|
startTime := time.Now()
|
|
|
|
startTime := time.Now()
|
|
|
|
defer func() {
|
|
|
|
defer func() {
|
|
|
|
metrics.FrameworkExtensionPointDuration.WithLabelValues(permit, status.Code().String()).Observe(metrics.SinceInSeconds(startTime))
|
|
|
|
metrics.FrameworkExtensionPointDuration.WithLabelValues(permit, status.Code().String(), f.profileName).Observe(metrics.SinceInSeconds(startTime))
|
|
|
|
}()
|
|
|
|
}()
|
|
|
|
pluginsWaitTime := make(map[string]time.Duration)
|
|
|
|
pluginsWaitTime := make(map[string]time.Duration)
|
|
|
|
statusCode := framework.Success
|
|
|
|
statusCode := framework.Success
|
|
|
|