Skip to content

Commit 3ede020

Browse files
authored
Merge pull request kubernetes#81800 from draveness/feature/update-post-filter-plugin-name
feat: update scheduling framework interface with camelcase
2 parents 61aa39a + af2e042 commit 3ede020

File tree

9 files changed

+195
-195
lines changed

9 files changed

+195
-195
lines changed

pkg/scheduler/core/generic_scheduler.go

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -195,9 +195,9 @@ func (g *genericScheduler) Schedule(pod *v1.Pod, pluginContext *framework.Plugin
195195
}
196196

197197
// Run "prefilter" plugins.
198-
prefilterStatus := g.framework.RunPrefilterPlugins(pluginContext, pod)
199-
if !prefilterStatus.IsSuccess() {
200-
return result, prefilterStatus.AsError()
198+
preFilterStatus := g.framework.RunPreFilterPlugins(pluginContext, pod)
199+
if !preFilterStatus.IsSuccess() {
200+
return result, preFilterStatus.AsError()
201201
}
202202

203203
numNodes := g.cache.NodeTree().NumNodes()

pkg/scheduler/framework/plugins/examples/multipoint/multipoint.go

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,7 @@ limitations under the License.
1717
package multipoint
1818

1919
import (
20-
"k8s.io/api/core/v1"
20+
v1 "k8s.io/api/core/v1"
2121
"k8s.io/apimachinery/pkg/runtime"
2222
framework "k8s.io/kubernetes/pkg/scheduler/framework/v1alpha1"
2323
)
@@ -27,7 +27,7 @@ import (
2727
type CommunicatingPlugin struct{}
2828

2929
var _ = framework.ReservePlugin(CommunicatingPlugin{})
30-
var _ = framework.PrebindPlugin(CommunicatingPlugin{})
30+
var _ = framework.PreBindPlugin(CommunicatingPlugin{})
3131

3232
// Name is the name of the plug used in Registry and configurations.
3333
const Name = "multipoint-communicating-plugin"
@@ -50,8 +50,8 @@ func (mc CommunicatingPlugin) Reserve(pc *framework.PluginContext, pod *v1.Pod,
5050
return nil
5151
}
5252

53-
// Prebind is the functions invoked by the framework at "prebind" extension point.
54-
func (mc CommunicatingPlugin) Prebind(pc *framework.PluginContext, pod *v1.Pod, nodeName string) *framework.Status {
53+
// PreBind is the functions invoked by the framework at "prebind" extension point.
54+
func (mc CommunicatingPlugin) PreBind(pc *framework.PluginContext, pod *v1.Pod, nodeName string) *framework.Status {
5555
if pod == nil {
5656
return framework.NewStatus(framework.Error, "pod cannot be nil")
5757
}

pkg/scheduler/framework/plugins/examples/prebind/prebind.go

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -19,27 +19,27 @@ package prebind
1919
import (
2020
"fmt"
2121

22-
"k8s.io/api/core/v1"
22+
v1 "k8s.io/api/core/v1"
2323
"k8s.io/apimachinery/pkg/runtime"
2424
framework "k8s.io/kubernetes/pkg/scheduler/framework/v1alpha1"
2525
)
2626

27-
// StatelessPrebindExample is an example of a simple plugin that has no state
27+
// StatelessPreBindExample is an example of a simple plugin that has no state
2828
// and implements only one hook for prebind.
29-
type StatelessPrebindExample struct{}
29+
type StatelessPreBindExample struct{}
3030

31-
var _ = framework.PrebindPlugin(StatelessPrebindExample{})
31+
var _ = framework.PreBindPlugin(StatelessPreBindExample{})
3232

3333
// Name is the name of the plugin used in Registry and configurations.
3434
const Name = "stateless-prebind-plugin-example"
3535

3636
// Name returns name of the plugin. It is used in logs, etc.
37-
func (sr StatelessPrebindExample) Name() string {
37+
func (sr StatelessPreBindExample) Name() string {
3838
return Name
3939
}
4040

41-
// Prebind is the functions invoked by the framework at "prebind" extension point.
42-
func (sr StatelessPrebindExample) Prebind(pc *framework.PluginContext, pod *v1.Pod, nodeName string) *framework.Status {
41+
// PreBind is the functions invoked by the framework at "prebind" extension point.
42+
func (sr StatelessPreBindExample) PreBind(pc *framework.PluginContext, pod *v1.Pod, nodeName string) *framework.Status {
4343
if pod == nil {
4444
return framework.NewStatus(framework.Error, fmt.Sprintf("pod cannot be nil"))
4545
}
@@ -51,5 +51,5 @@ func (sr StatelessPrebindExample) Prebind(pc *framework.PluginContext, pod *v1.P
5151

5252
// New initializes a new plugin and returns it.
5353
func New(_ *runtime.Unknown, _ framework.FrameworkHandle) (framework.Plugin, error) {
54-
return &StatelessPrebindExample{}, nil
54+
return &StatelessPreBindExample{}, nil
5555
}

pkg/scheduler/framework/plugins/examples/stateful/stateful.go

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,7 @@ import (
2020
"fmt"
2121
"sync"
2222

23-
"k8s.io/api/core/v1"
23+
v1 "k8s.io/api/core/v1"
2424
"k8s.io/apimachinery/pkg/runtime"
2525
"k8s.io/klog"
2626
framework "k8s.io/kubernetes/pkg/scheduler/framework/v1alpha1"
@@ -36,7 +36,7 @@ type MultipointExample struct {
3636
}
3737

3838
var _ = framework.ReservePlugin(&MultipointExample{})
39-
var _ = framework.PrebindPlugin(&MultipointExample{})
39+
var _ = framework.PreBindPlugin(&MultipointExample{})
4040

4141
// Name is the name of the plug used in Registry and configurations.
4242
const Name = "multipoint-plugin-example"
@@ -53,9 +53,9 @@ func (mp *MultipointExample) Reserve(pc *framework.PluginContext, pod *v1.Pod, n
5353
return nil
5454
}
5555

56-
// Prebind is the functions invoked by the framework at "prebind" extension point.
57-
func (mp *MultipointExample) Prebind(pc *framework.PluginContext, pod *v1.Pod, nodeName string) *framework.Status {
58-
// Prebind could be called concurrently for different pods.
56+
// PreBind is the functions invoked by the framework at "prebind" extension point.
57+
func (mp *MultipointExample) PreBind(pc *framework.PluginContext, pod *v1.Pod, nodeName string) *framework.Status {
58+
// PreBind could be called concurrently for different pods.
5959
mp.mu.Lock()
6060
defer mp.mu.Unlock()
6161
mp.numRuns++

pkg/scheduler/framework/v1alpha1/framework.go

Lines changed: 21 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -39,15 +39,15 @@ type framework struct {
3939
waitingPods *waitingPodsMap
4040
pluginNameToWeightMap map[string]int
4141
queueSortPlugins []QueueSortPlugin
42-
prefilterPlugins []PrefilterPlugin
42+
preFilterPlugins []PreFilterPlugin
4343
filterPlugins []FilterPlugin
4444
postFilterPlugins []PostFilterPlugin
4545
scorePlugins []ScorePlugin
4646
scoreWithNormalizePlugins []ScoreWithNormalizePlugin
4747
reservePlugins []ReservePlugin
48-
prebindPlugins []PrebindPlugin
48+
preBindPlugins []PreBindPlugin
4949
bindPlugins []BindPlugin
50-
postbindPlugins []PostbindPlugin
50+
postBindPlugins []PostBindPlugin
5151
unreservePlugins []UnreservePlugin
5252
permitPlugins []PermitPlugin
5353
}
@@ -105,11 +105,11 @@ func NewFramework(r Registry, plugins *config.Plugins, args []config.PluginConfi
105105
if plugins.PreFilter != nil {
106106
for _, pf := range plugins.PreFilter.Enabled {
107107
if pg, ok := pluginsMap[pf.Name]; ok {
108-
p, ok := pg.(PrefilterPlugin)
108+
p, ok := pg.(PreFilterPlugin)
109109
if !ok {
110110
return nil, fmt.Errorf("plugin %q does not extend prefilter plugin", pf.Name)
111111
}
112-
f.prefilterPlugins = append(f.prefilterPlugins, p)
112+
f.preFilterPlugins = append(f.preFilterPlugins, p)
113113
} else {
114114
return nil, fmt.Errorf("prefilter plugin %q does not exist", pf.Name)
115115
}
@@ -186,11 +186,11 @@ func NewFramework(r Registry, plugins *config.Plugins, args []config.PluginConfi
186186
if plugins.PreBind != nil {
187187
for _, pb := range plugins.PreBind.Enabled {
188188
if pg, ok := pluginsMap[pb.Name]; ok {
189-
p, ok := pg.(PrebindPlugin)
189+
p, ok := pg.(PreBindPlugin)
190190
if !ok {
191191
return nil, fmt.Errorf("plugin %q does not extend prebind plugin", pb.Name)
192192
}
193-
f.prebindPlugins = append(f.prebindPlugins, p)
193+
f.preBindPlugins = append(f.preBindPlugins, p)
194194
} else {
195195
return nil, fmt.Errorf("prebind plugin %q does not exist", pb.Name)
196196
}
@@ -214,11 +214,11 @@ func NewFramework(r Registry, plugins *config.Plugins, args []config.PluginConfi
214214
if plugins.PostBind != nil {
215215
for _, pb := range plugins.PostBind.Enabled {
216216
if pg, ok := pluginsMap[pb.Name]; ok {
217-
p, ok := pg.(PostbindPlugin)
217+
p, ok := pg.(PostBindPlugin)
218218
if !ok {
219219
return nil, fmt.Errorf("plugin %q does not extend postbind plugin", pb.Name)
220220
}
221-
f.postbindPlugins = append(f.postbindPlugins, p)
221+
f.postBindPlugins = append(f.postBindPlugins, p)
222222
} else {
223223
return nil, fmt.Errorf("postbind plugin %q does not exist", pb.Name)
224224
}
@@ -283,14 +283,14 @@ func (f *framework) QueueSortFunc() LessFunc {
283283
return f.queueSortPlugins[0].Less
284284
}
285285

286-
// RunPrefilterPlugins runs the set of configured prefilter plugins. It returns
286+
// RunPreFilterPlugins runs the set of configured PreFilter plugins. It returns
287287
// *Status and its code is set to non-success if any of the plugins returns
288288
// anything but Success. If a non-success status is returned, then the scheduling
289289
// cycle is aborted.
290-
func (f *framework) RunPrefilterPlugins(
290+
func (f *framework) RunPreFilterPlugins(
291291
pc *PluginContext, pod *v1.Pod) *Status {
292-
for _, pl := range f.prefilterPlugins {
293-
status := pl.Prefilter(pc, pod)
292+
for _, pl := range f.preFilterPlugins {
293+
status := pl.PreFilter(pc, pod)
294294
if !status.IsSuccess() {
295295
if status.Code() == Unschedulable {
296296
msg := fmt.Sprintf("rejected by %q at prefilter: %v", pl.Name(), status.Message())
@@ -425,13 +425,13 @@ func (f *framework) RunScorePlugins(pc *PluginContext, pod *v1.Pod, nodes []*v1.
425425
return pluginToNodeScores, nil
426426
}
427427

428-
// RunPrebindPlugins runs the set of configured prebind plugins. It returns a
428+
// RunPreBindPlugins runs the set of configured prebind plugins. It returns a
429429
// failure (bool) if any of the plugins returns an error. It also returns an
430430
// error containing the rejection message or the error occurred in the plugin.
431-
func (f *framework) RunPrebindPlugins(
431+
func (f *framework) RunPreBindPlugins(
432432
pc *PluginContext, pod *v1.Pod, nodeName string) *Status {
433-
for _, pl := range f.prebindPlugins {
434-
status := pl.Prebind(pc, pod, nodeName)
433+
for _, pl := range f.preBindPlugins {
434+
status := pl.PreBind(pc, pod, nodeName)
435435
if !status.IsSuccess() {
436436
if status.Code() == Unschedulable {
437437
msg := fmt.Sprintf("rejected by %q at prebind: %v", pl.Name(), status.Message())
@@ -467,11 +467,11 @@ func (f *framework) RunBindPlugins(pc *PluginContext, pod *v1.Pod, nodeName stri
467467
return status
468468
}
469469

470-
// RunPostbindPlugins runs the set of configured postbind plugins.
471-
func (f *framework) RunPostbindPlugins(
470+
// RunPostBindPlugins runs the set of configured postbind plugins.
471+
func (f *framework) RunPostBindPlugins(
472472
pc *PluginContext, pod *v1.Pod, nodeName string) {
473-
for _, pl := range f.postbindPlugins {
474-
pl.Postbind(pc, pod, nodeName)
473+
for _, pl := range f.postBindPlugins {
474+
pl.PostBind(pc, pod, nodeName)
475475
}
476476
}
477477

pkg/scheduler/framework/v1alpha1/interface.go

Lines changed: 19 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -152,13 +152,13 @@ type QueueSortPlugin interface {
152152
Less(*PodInfo, *PodInfo) bool
153153
}
154154

155-
// PrefilterPlugin is an interface that must be implemented by "prefilter" plugins.
155+
// PreFilterPlugin is an interface that must be implemented by "prefilter" plugins.
156156
// These plugins are called at the beginning of the scheduling cycle.
157-
type PrefilterPlugin interface {
157+
type PreFilterPlugin interface {
158158
Plugin
159-
// Prefilter is called at the beginning of the scheduling cycle. All prefilter
159+
// PreFilter is called at the beginning of the scheduling cycle. All PreFilter
160160
// plugins must return success or the pod will be rejected.
161-
Prefilter(pc *PluginContext, p *v1.Pod) *Status
161+
PreFilter(pc *PluginContext, p *v1.Pod) *Status
162162
}
163163

164164
// FilterPlugin is an interface for Filter plugins. These plugins are called at the
@@ -225,24 +225,24 @@ type ReservePlugin interface {
225225
Reserve(pc *PluginContext, p *v1.Pod, nodeName string) *Status
226226
}
227227

228-
// PrebindPlugin is an interface that must be implemented by "prebind" plugins.
228+
// PreBindPlugin is an interface that must be implemented by "prebind" plugins.
229229
// These plugins are called before a pod being scheduled.
230-
type PrebindPlugin interface {
230+
type PreBindPlugin interface {
231231
Plugin
232-
// Prebind is called before binding a pod. All prebind plugins must return
232+
// PreBind is called before binding a pod. All prebind plugins must return
233233
// success or the pod will be rejected and won't be sent for binding.
234-
Prebind(pc *PluginContext, p *v1.Pod, nodeName string) *Status
234+
PreBind(pc *PluginContext, p *v1.Pod, nodeName string) *Status
235235
}
236236

237-
// PostbindPlugin is an interface that must be implemented by "postbind" plugins.
237+
// PostBindPlugin is an interface that must be implemented by "postbind" plugins.
238238
// These plugins are called after a pod is successfully bound to a node.
239-
type PostbindPlugin interface {
239+
type PostBindPlugin interface {
240240
Plugin
241-
// Postbind is called after a pod is successfully bound. These plugins are
241+
// PostBind is called after a pod is successfully bound. These plugins are
242242
// informational. A common application of this extension point is for cleaning
243243
// up. If a plugin needs to clean-up its state after a pod is scheduled and
244-
// bound, Postbind is the extension point that it should register.
245-
Postbind(pc *PluginContext, p *v1.Pod, nodeName string)
244+
// bound, PostBind is the extension point that it should register.
245+
PostBind(pc *PluginContext, p *v1.Pod, nodeName string)
246246
}
247247

248248
// UnreservePlugin is an interface for Unreserve plugins. This is an informational
@@ -289,11 +289,11 @@ type Framework interface {
289289
// QueueSortFunc returns the function to sort pods in scheduling queue
290290
QueueSortFunc() LessFunc
291291

292-
// RunPrefilterPlugins runs the set of configured prefilter plugins. It returns
292+
// RunPreFilterPlugins runs the set of configured prefilter plugins. It returns
293293
// *Status and its code is set to non-success if any of the plugins returns
294294
// anything but Success. If a non-success status is returned, then the scheduling
295295
// cycle is aborted.
296-
RunPrefilterPlugins(pc *PluginContext, pod *v1.Pod) *Status
296+
RunPreFilterPlugins(pc *PluginContext, pod *v1.Pod) *Status
297297

298298
// RunFilterPlugins runs the set of configured filter plugins for pod on the
299299
// given host. If any of these plugins returns any status other than "Success",
@@ -311,15 +311,15 @@ type Framework interface {
311311
// a non-success status.
312312
RunScorePlugins(pc *PluginContext, pod *v1.Pod, nodes []*v1.Node) (PluginToNodeScores, *Status)
313313

314-
// RunPrebindPlugins runs the set of configured prebind plugins. It returns
314+
// RunPreBindPlugins runs the set of configured prebind plugins. It returns
315315
// *Status and its code is set to non-success if any of the plugins returns
316316
// anything but Success. If the Status code is "Unschedulable", it is
317317
// considered as a scheduling check failure, otherwise, it is considered as an
318318
// internal error. In either case the pod is not going to be bound.
319-
RunPrebindPlugins(pc *PluginContext, pod *v1.Pod, nodeName string) *Status
319+
RunPreBindPlugins(pc *PluginContext, pod *v1.Pod, nodeName string) *Status
320320

321-
// RunPostbindPlugins runs the set of configured postbind plugins.
322-
RunPostbindPlugins(pc *PluginContext, pod *v1.Pod, nodeName string)
321+
// RunPostBindPlugins runs the set of configured postbind plugins.
322+
RunPostBindPlugins(pc *PluginContext, pod *v1.Pod, nodeName string)
323323

324324
// RunReservePlugins runs the set of configured reserve plugins. If any of these
325325
// plugins returns an error, it does not continue running the remaining ones and

pkg/scheduler/internal/queue/scheduling_queue_test.go

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -167,7 +167,7 @@ func (*fakeFramework) NodeInfoSnapshot() *internalcache.NodeInfoSnapshot {
167167
return nil
168168
}
169169

170-
func (*fakeFramework) RunPrefilterPlugins(pc *framework.PluginContext, pod *v1.Pod) *framework.Status {
170+
func (*fakeFramework) RunPreFilterPlugins(pc *framework.PluginContext, pod *v1.Pod) *framework.Status {
171171
return nil
172172
}
173173

@@ -179,15 +179,15 @@ func (*fakeFramework) RunScorePlugins(pc *framework.PluginContext, pod *v1.Pod,
179179
return nil, nil
180180
}
181181

182-
func (*fakeFramework) RunPrebindPlugins(pc *framework.PluginContext, pod *v1.Pod, nodeName string) *framework.Status {
182+
func (*fakeFramework) RunPreBindPlugins(pc *framework.PluginContext, pod *v1.Pod, nodeName string) *framework.Status {
183183
return nil
184184
}
185185

186186
func (*fakeFramework) RunBindPlugins(pc *framework.PluginContext, pod *v1.Pod, nodeName string) *framework.Status {
187187
return nil
188188
}
189189

190-
func (*fakeFramework) RunPostbindPlugins(pc *framework.PluginContext, pod *v1.Pod, nodeName string) {}
190+
func (*fakeFramework) RunPostBindPlugins(pc *framework.PluginContext, pod *v1.Pod, nodeName string) {}
191191

192192
func (*fakeFramework) RunPostFilterPlugins(pc *framework.PluginContext, pod *v1.Pod, nodes []*v1.Node, filteredNodesStatuses framework.NodeToStatusMap) *framework.Status {
193193
return nil

pkg/scheduler/scheduler.go

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -632,10 +632,10 @@ func (sched *Scheduler) scheduleOne() {
632632
}
633633

634634
// Run "prebind" plugins.
635-
prebindStatus := fwk.RunPrebindPlugins(pluginContext, assumedPod, scheduleResult.SuggestedHost)
636-
if !prebindStatus.IsSuccess() {
635+
preBindStatus := fwk.RunPreBindPlugins(pluginContext, assumedPod, scheduleResult.SuggestedHost)
636+
if !preBindStatus.IsSuccess() {
637637
var reason string
638-
if prebindStatus.Code() == framework.Unschedulable {
638+
if preBindStatus.Code() == framework.Unschedulable {
639639
metrics.PodScheduleFailures.Inc()
640640
reason = v1.PodReasonUnschedulable
641641
} else {
@@ -647,7 +647,7 @@ func (sched *Scheduler) scheduleOne() {
647647
}
648648
// trigger un-reserve plugins to clean up state associated with the reserved Pod
649649
fwk.RunUnreservePlugins(pluginContext, assumedPod, scheduleResult.SuggestedHost)
650-
sched.recordSchedulingFailure(assumedPod, prebindStatus.AsError(), reason, prebindStatus.Message())
650+
sched.recordSchedulingFailure(assumedPod, preBindStatus.AsError(), reason, preBindStatus.Message())
651651
return
652652
}
653653

@@ -670,7 +670,7 @@ func (sched *Scheduler) scheduleOne() {
670670
metrics.PodScheduleSuccesses.Inc()
671671

672672
// Run "postbind" plugins.
673-
fwk.RunPostbindPlugins(pluginContext, assumedPod, scheduleResult.SuggestedHost)
673+
fwk.RunPostBindPlugins(pluginContext, assumedPod, scheduleResult.SuggestedHost)
674674
}
675675
}()
676676
}

0 commit comments

Comments
 (0)