@@ -85,6 +85,7 @@ type frameworkImpl struct {
85
85
informerFactory informers.SharedInformerFactory
86
86
87
87
metricsRecorder * metricsRecorder
88
+ profileName string
88
89
89
90
preemptHandle framework.PreemptHandle
90
91
@@ -127,6 +128,7 @@ type frameworkOptions struct {
127
128
informerFactory informers.SharedInformerFactory
128
129
snapshotSharedLister framework.SharedLister
129
130
metricsRecorder * metricsRecorder
131
+ profileName string
130
132
podNominator framework.PodNominator
131
133
extenders []framework.Extender
132
134
runAllFilters bool
@@ -171,6 +173,13 @@ func WithRunAllFilters(runAllFilters bool) Option {
171
173
}
172
174
}
173
175
176
+ // WithProfileName sets the profile name.
177
+ func WithProfileName (name string ) Option {
178
+ return func (o * frameworkOptions ) {
179
+ o .profileName = name
180
+ }
181
+ }
182
+
174
183
// withMetricsRecorder is only used in tests.
175
184
func withMetricsRecorder (recorder * metricsRecorder ) Option {
176
185
return func (o * frameworkOptions ) {
@@ -228,6 +237,7 @@ func NewFramework(r Registry, plugins *config.Plugins, args []config.PluginConfi
228
237
eventRecorder : options .eventRecorder ,
229
238
informerFactory : options .informerFactory ,
230
239
metricsRecorder : options .metricsRecorder ,
240
+ profileName : options .profileName ,
231
241
runAllFilters : options .runAllFilters ,
232
242
}
233
243
f .preemptHandle = & preemptHandle {
@@ -381,7 +391,7 @@ func (f *frameworkImpl) QueueSortFunc() framework.LessFunc {
381
391
func (f * frameworkImpl ) RunPreFilterPlugins (ctx context.Context , state * framework.CycleState , pod * v1.Pod ) (status * framework.Status ) {
382
392
startTime := time .Now ()
383
393
defer func () {
384
- metrics .FrameworkExtensionPointDuration .WithLabelValues (preFilter , status .Code ().String ()).Observe (metrics .SinceInSeconds (startTime ))
394
+ metrics .FrameworkExtensionPointDuration .WithLabelValues (preFilter , status .Code ().String (), f . profileName ).Observe (metrics .SinceInSeconds (startTime ))
385
395
}()
386
396
for _ , pl := range f .preFilterPlugins {
387
397
status = f .runPreFilterPlugin (ctx , pl , state , pod )
@@ -528,7 +538,7 @@ func (f *frameworkImpl) runFilterPlugin(ctx context.Context, pl framework.Filter
528
538
func (f * frameworkImpl ) RunPostFilterPlugins (ctx context.Context , state * framework.CycleState , pod * v1.Pod , filteredNodeStatusMap framework.NodeToStatusMap ) (_ * framework.PostFilterResult , status * framework.Status ) {
529
539
startTime := time .Now ()
530
540
defer func () {
531
- metrics .FrameworkExtensionPointDuration .WithLabelValues (postFilter , status .Code ().String ()).Observe (metrics .SinceInSeconds (startTime ))
541
+ metrics .FrameworkExtensionPointDuration .WithLabelValues (postFilter , status .Code ().String (), f . profileName ).Observe (metrics .SinceInSeconds (startTime ))
532
542
}()
533
543
534
544
statuses := make (framework.PluginToStatus )
@@ -566,7 +576,7 @@ func (f *frameworkImpl) RunPreScorePlugins(
566
576
) (status * framework.Status ) {
567
577
startTime := time .Now ()
568
578
defer func () {
569
- metrics .FrameworkExtensionPointDuration .WithLabelValues (preScore , status .Code ().String ()).Observe (metrics .SinceInSeconds (startTime ))
579
+ metrics .FrameworkExtensionPointDuration .WithLabelValues (preScore , status .Code ().String (), f . profileName ).Observe (metrics .SinceInSeconds (startTime ))
570
580
}()
571
581
for _ , pl := range f .preScorePlugins {
572
582
status = f .runPreScorePlugin (ctx , pl , state , pod , nodes )
@@ -597,7 +607,7 @@ func (f *frameworkImpl) runPreScorePlugin(ctx context.Context, pl framework.PreS
597
607
func (f * frameworkImpl ) RunScorePlugins (ctx context.Context , state * framework.CycleState , pod * v1.Pod , nodes []* v1.Node ) (ps framework.PluginToNodeScores , status * framework.Status ) {
598
608
startTime := time .Now ()
599
609
defer func () {
600
- metrics .FrameworkExtensionPointDuration .WithLabelValues (score , status .Code ().String ()).Observe (metrics .SinceInSeconds (startTime ))
610
+ metrics .FrameworkExtensionPointDuration .WithLabelValues (score , status .Code ().String (), f . profileName ).Observe (metrics .SinceInSeconds (startTime ))
601
611
}()
602
612
pluginToNodeScores := make (framework.PluginToNodeScores , len (f .scorePlugins ))
603
613
for _ , pl := range f .scorePlugins {
@@ -699,7 +709,7 @@ func (f *frameworkImpl) runScoreExtension(ctx context.Context, pl framework.Scor
699
709
func (f * frameworkImpl ) RunPreBindPlugins (ctx context.Context , state * framework.CycleState , pod * v1.Pod , nodeName string ) (status * framework.Status ) {
700
710
startTime := time .Now ()
701
711
defer func () {
702
- metrics .FrameworkExtensionPointDuration .WithLabelValues (preBind , status .Code ().String ()).Observe (metrics .SinceInSeconds (startTime ))
712
+ metrics .FrameworkExtensionPointDuration .WithLabelValues (preBind , status .Code ().String (), f . profileName ).Observe (metrics .SinceInSeconds (startTime ))
703
713
}()
704
714
for _ , pl := range f .preBindPlugins {
705
715
status = f .runPreBindPlugin (ctx , pl , state , pod , nodeName )
@@ -726,7 +736,7 @@ func (f *frameworkImpl) runPreBindPlugin(ctx context.Context, pl framework.PreBi
726
736
func (f * frameworkImpl ) RunBindPlugins (ctx context.Context , state * framework.CycleState , pod * v1.Pod , nodeName string ) (status * framework.Status ) {
727
737
startTime := time .Now ()
728
738
defer func () {
729
- metrics .FrameworkExtensionPointDuration .WithLabelValues (bind , status .Code ().String ()).Observe (metrics .SinceInSeconds (startTime ))
739
+ metrics .FrameworkExtensionPointDuration .WithLabelValues (bind , status .Code ().String (), f . profileName ).Observe (metrics .SinceInSeconds (startTime ))
730
740
}()
731
741
if len (f .bindPlugins ) == 0 {
732
742
return framework .NewStatus (framework .Skip , "" )
@@ -760,7 +770,7 @@ func (f *frameworkImpl) runBindPlugin(ctx context.Context, bp framework.BindPlug
760
770
func (f * frameworkImpl ) RunPostBindPlugins (ctx context.Context , state * framework.CycleState , pod * v1.Pod , nodeName string ) {
761
771
startTime := time .Now ()
762
772
defer func () {
763
- metrics .FrameworkExtensionPointDuration .WithLabelValues (postBind , framework .Success .String ()).Observe (metrics .SinceInSeconds (startTime ))
773
+ metrics .FrameworkExtensionPointDuration .WithLabelValues (postBind , framework .Success .String (), f . profileName ).Observe (metrics .SinceInSeconds (startTime ))
764
774
}()
765
775
for _ , pl := range f .postBindPlugins {
766
776
f .runPostBindPlugin (ctx , pl , state , pod , nodeName )
@@ -783,7 +793,7 @@ func (f *frameworkImpl) runPostBindPlugin(ctx context.Context, pl framework.Post
783
793
func (f * frameworkImpl ) RunReservePlugins (ctx context.Context , state * framework.CycleState , pod * v1.Pod , nodeName string ) (status * framework.Status ) {
784
794
startTime := time .Now ()
785
795
defer func () {
786
- metrics .FrameworkExtensionPointDuration .WithLabelValues (reserve , status .Code ().String ()).Observe (metrics .SinceInSeconds (startTime ))
796
+ metrics .FrameworkExtensionPointDuration .WithLabelValues (reserve , status .Code ().String (), f . profileName ).Observe (metrics .SinceInSeconds (startTime ))
787
797
}()
788
798
for _ , pl := range f .reservePlugins {
789
799
status = f .runReservePlugin (ctx , pl , state , pod , nodeName )
@@ -810,7 +820,7 @@ func (f *frameworkImpl) runReservePlugin(ctx context.Context, pl framework.Reser
810
820
func (f * frameworkImpl ) RunUnreservePlugins (ctx context.Context , state * framework.CycleState , pod * v1.Pod , nodeName string ) {
811
821
startTime := time .Now ()
812
822
defer func () {
813
- metrics .FrameworkExtensionPointDuration .WithLabelValues (unreserve , framework .Success .String ()).Observe (metrics .SinceInSeconds (startTime ))
823
+ metrics .FrameworkExtensionPointDuration .WithLabelValues (unreserve , framework .Success .String (), f . profileName ).Observe (metrics .SinceInSeconds (startTime ))
814
824
}()
815
825
for _ , pl := range f .unreservePlugins {
816
826
f .runUnreservePlugin (ctx , pl , state , pod , nodeName )
@@ -836,7 +846,7 @@ func (f *frameworkImpl) runUnreservePlugin(ctx context.Context, pl framework.Unr
836
846
func (f * frameworkImpl ) RunPermitPlugins (ctx context.Context , state * framework.CycleState , pod * v1.Pod , nodeName string ) (status * framework.Status ) {
837
847
startTime := time .Now ()
838
848
defer func () {
839
- metrics .FrameworkExtensionPointDuration .WithLabelValues (permit , status .Code ().String ()).Observe (metrics .SinceInSeconds (startTime ))
849
+ metrics .FrameworkExtensionPointDuration .WithLabelValues (permit , status .Code ().String (), f . profileName ).Observe (metrics .SinceInSeconds (startTime ))
840
850
}()
841
851
pluginsWaitTime := make (map [string ]time.Duration )
842
852
statusCode := framework .Success
0 commit comments