Skip to content

Commit bace505

Browse files
authored
Merge pull request kubernetes#77577 from logicalhan/revert-unreserve
Revert "Add Un-reserve extension point for the scheduling framework"
2 parents 91528d6 + 51992d6 commit bace505

File tree

4 files changed

+11
-159
lines changed

4 files changed

+11
-159
lines changed

pkg/scheduler/framework/v1alpha1/framework.go

Lines changed: 0 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -33,7 +33,6 @@ type framework struct {
3333
plugins map[string]Plugin // a map of initialized plugins. Plugin name:plugin instance.
3434
reservePlugins []ReservePlugin
3535
prebindPlugins []PrebindPlugin
36-
unreservePlugins []UnreservePlugin
3736
}
3837

3938
var _ = Framework(&framework{})
@@ -65,9 +64,6 @@ func NewFramework(r Registry, _ *runtime.Unknown) (Framework, error) {
6564
if pp, ok := p.(PrebindPlugin); ok {
6665
f.prebindPlugins = append(f.prebindPlugins, pp)
6766
}
68-
if up, ok := p.(UnreservePlugin); ok {
69-
f.unreservePlugins = append(f.unreservePlugins, up)
70-
}
7167
}
7268
return f, nil
7369
}
@@ -109,14 +105,6 @@ func (f *framework) RunReservePlugins(
109105
return nil
110106
}
111107

112-
// RunUnreservePlugins runs the set of configured unreserve plugins.
113-
func (f *framework) RunUnreservePlugins(
114-
pc *PluginContext, pod *v1.Pod, nodeName string) {
115-
for _, pl := range f.unreservePlugins {
116-
pl.Unreserve(pc, pod, nodeName)
117-
}
118-
}
119-
120108
// NodeInfoSnapshot returns the latest NodeInfo snapshot. The snapshot
121109
// is taken at the beginning of a scheduling cycle and remains unchanged until a
122110
// pod finishes "Reserve". There is no guarantee that the information remains

pkg/scheduler/framework/v1alpha1/interface.go

Lines changed: 0 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -113,17 +113,6 @@ type PrebindPlugin interface {
113113
Prebind(pc *PluginContext, p *v1.Pod, nodeName string) *Status
114114
}
115115

116-
// UnreservePlugin is an interface for Unreserve plugins. This is an informational
117-
// extension point. If a pod was reserved and then rejected in a later phase, then
118-
// un-reserve plugins will be notified. Un-reserve plugins should clean up state
119-
// associated with the reserved Pod.
120-
type UnreservePlugin interface {
121-
Plugin
122-
// Unreserve is called by the scheduling framework when a reserved pod was
123-
// rejected in a later phase.
124-
Unreserve(pc *PluginContext, p *v1.Pod, nodeName string)
125-
}
126-
127116
// Framework manages the set of plugins in use by the scheduling framework.
128117
// Configured plugins are called at specified points in a scheduling context.
129118
type Framework interface {
@@ -139,9 +128,6 @@ type Framework interface {
139128
// plugins returns an error, it does not continue running the remaining ones and
140129
// returns the error. In such case, pod will not be scheduled.
141130
RunReservePlugins(pc *PluginContext, pod *v1.Pod, nodeName string) *Status
142-
143-
// RunUnreservePlugins runs the set of configured unreserve plugins.
144-
RunUnreservePlugins(pc *PluginContext, pod *v1.Pod, nodeName string)
145131
}
146132

147133
// FrameworkHandle provides data and some tools that plugins can use. It is

pkg/scheduler/scheduler.go

Lines changed: 0 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -515,8 +515,6 @@ func (sched *Scheduler) scheduleOne() {
515515
if err != nil {
516516
klog.Errorf("error assuming pod: %v", err)
517517
metrics.PodScheduleErrors.Inc()
518-
// trigger un-reserve plugins to clean up state associated with the reserved Pod
519-
fwk.RunUnreservePlugins(pluginContext, assumedPod, scheduleResult.SuggestedHost)
520518
return
521519
}
522520
// bind the pod to its host asynchronously (we can do this b/c of the assumption step above).
@@ -527,8 +525,6 @@ func (sched *Scheduler) scheduleOne() {
527525
if err != nil {
528526
klog.Errorf("error binding volumes: %v", err)
529527
metrics.PodScheduleErrors.Inc()
530-
// trigger un-reserve plugins to clean up state associated with the reserved Pod
531-
fwk.RunUnreservePlugins(pluginContext, assumedPod, scheduleResult.SuggestedHost)
532528
return
533529
}
534530
}
@@ -547,8 +543,6 @@ func (sched *Scheduler) scheduleOne() {
547543
klog.Errorf("scheduler cache ForgetPod failed: %v", forgetErr)
548544
}
549545
sched.recordSchedulingFailure(assumedPod, prebindStatus.AsError(), reason, prebindStatus.Message())
550-
// trigger un-reserve plugins to clean up state associated with the reserved Pod
551-
fwk.RunUnreservePlugins(pluginContext, assumedPod, scheduleResult.SuggestedHost)
552546
return
553547
}
554548

@@ -564,8 +558,6 @@ func (sched *Scheduler) scheduleOne() {
564558
if err != nil {
565559
klog.Errorf("error binding pod: %v", err)
566560
metrics.PodScheduleErrors.Inc()
567-
// trigger un-reserve plugins to clean up state associated with the reserved Pod
568-
fwk.RunUnreservePlugins(pluginContext, assumedPod, scheduleResult.SuggestedHost)
569561
} else {
570562
klog.V(2).Infof("pod %v/%v is bound successfully on node %v, %d nodes evaluated, %d nodes were found feasible", assumedPod.Namespace, assumedPod.Name, scheduleResult.SuggestedHost, scheduleResult.EvaluatedNodes, scheduleResult.FeasibleNodes)
571563
metrics.PodScheduleSuccesses.Inc()

test/integration/scheduler/framework_test.go

Lines changed: 11 additions & 125 deletions
Original file line numberDiff line numberDiff line change
@@ -18,24 +18,23 @@ package scheduler
1818

1919
import (
2020
"fmt"
21+
"k8s.io/apimachinery/pkg/runtime"
2122
"testing"
2223
"time"
2324

2425
"k8s.io/api/core/v1"
25-
"k8s.io/apimachinery/pkg/runtime"
2626
"k8s.io/apimachinery/pkg/util/wait"
2727
framework "k8s.io/kubernetes/pkg/scheduler/framework/v1alpha1"
2828
)
2929

3030
// TesterPlugin is common ancestor for a test plugin that allows injection of
3131
// failures and some other test functionalities.
3232
type TesterPlugin struct {
33-
numReserveCalled int
34-
numPrebindCalled int
35-
numUnreserveCalled int
36-
failReserve bool
37-
failPrebind bool
38-
rejectPrebind bool
33+
numReserveCalled int
34+
numPrebindCalled int
35+
failReserve bool
36+
failPrebind bool
37+
rejectPrebind bool
3938
}
4039

4140
type ReservePlugin struct {
@@ -46,27 +45,19 @@ type PrebindPlugin struct {
4645
TesterPlugin
4746
}
4847

49-
type UnreservePlugin struct {
50-
TesterPlugin
51-
}
52-
5348
const (
54-
reservePluginName = "reserve-plugin"
55-
prebindPluginName = "prebind-plugin"
56-
unreservePluginName = "unreserve-plugin"
49+
reservePluginName = "reserve-plugin"
50+
prebindPluginName = "prebind-plugin"
5751
)
5852

5953
var _ = framework.ReservePlugin(&ReservePlugin{})
6054
var _ = framework.PrebindPlugin(&PrebindPlugin{})
61-
var _ = framework.UnreservePlugin(&UnreservePlugin{})
6255

6356
// Name returns name of the plugin.
6457
func (rp *ReservePlugin) Name() string {
6558
return reservePluginName
6659
}
6760

68-
var resPlugin = &ReservePlugin{}
69-
7061
// Reserve is a test function that returns an error or nil, depending on the
7162
// value of "failReserve".
7263
func (rp *ReservePlugin) Reserve(pc *framework.PluginContext, pod *v1.Pod, nodeName string) *framework.Status {
@@ -77,13 +68,14 @@ func (rp *ReservePlugin) Reserve(pc *framework.PluginContext, pod *v1.Pod, nodeN
7768
return nil
7869
}
7970

71+
var resPlugin = &ReservePlugin{}
72+
var pbdPlugin = &PrebindPlugin{}
73+
8074
// NewReservePlugin is the factory for reserve plugin.
8175
func NewReservePlugin(_ *runtime.Unknown, _ framework.FrameworkHandle) (framework.Plugin, error) {
8276
return resPlugin, nil
8377
}
8478

85-
var pbdPlugin = &PrebindPlugin{}
86-
8779
// Name returns name of the plugin.
8880
func (pp *PrebindPlugin) Name() string {
8981
return prebindPluginName
@@ -106,29 +98,6 @@ func NewPrebindPlugin(_ *runtime.Unknown, _ framework.FrameworkHandle) (framewor
10698
return pbdPlugin, nil
10799
}
108100

109-
var unresPlugin = &UnreservePlugin{}
110-
111-
// Name returns name of the plugin.
112-
func (up *UnreservePlugin) Name() string {
113-
return unreservePluginName
114-
}
115-
116-
// Unreserve is a test function that returns an error or nil, depending on the
117-
// value of "failUnreserve".
118-
func (up *UnreservePlugin) Unreserve(pc *framework.PluginContext, pod *v1.Pod, nodeName string) {
119-
up.numUnreserveCalled++
120-
}
121-
122-
// reset used to reset numUnreserveCalled.
123-
func (up *UnreservePlugin) reset() {
124-
up.numUnreserveCalled = 0
125-
}
126-
127-
// NewUnreservePlugin is the factory for unreserve plugin.
128-
func NewUnreservePlugin(_ *runtime.Unknown, _ framework.FrameworkHandle) (framework.Plugin, error) {
129-
return unresPlugin, nil
130-
}
131-
132101
// TestReservePlugin tests invocation of reserve plugins.
133102
func TestReservePlugin(t *testing.T) {
134103
// Create a plugin registry for testing. Register only a reserve plugin.
@@ -247,86 +216,3 @@ func TestPrebindPlugin(t *testing.T) {
247216
cleanupPods(cs, t, []*v1.Pod{pod})
248217
}
249218
}
250-
251-
// TestUnreservePlugin tests invocation of un-reserve plugin
252-
func TestUnreservePlugin(t *testing.T) {
253-
// TODO: register more plugin which would trigger un-reserve plugin
254-
registry := framework.Registry{
255-
unreservePluginName: NewUnreservePlugin,
256-
prebindPluginName: NewPrebindPlugin,
257-
}
258-
259-
// Create the master and the scheduler with the test plugin set.
260-
context := initTestSchedulerWithOptions(t,
261-
initTestMaster(t, "unreserve-plugin", nil),
262-
false, nil, registry, false, time.Second)
263-
defer cleanupTest(t, context)
264-
265-
cs := context.clientSet
266-
// Add a few nodes.
267-
_, err := createNodes(cs, "test-node", nil, 2)
268-
if err != nil {
269-
t.Fatalf("Cannot create nodes: %v", err)
270-
}
271-
272-
tests := []struct {
273-
prebindFail bool
274-
prebindReject bool
275-
}{
276-
{
277-
prebindFail: false,
278-
prebindReject: false,
279-
},
280-
{
281-
prebindFail: true,
282-
prebindReject: false,
283-
},
284-
{
285-
prebindFail: false,
286-
prebindReject: true,
287-
},
288-
{
289-
prebindFail: true,
290-
prebindReject: true,
291-
},
292-
}
293-
294-
for i, test := range tests {
295-
pbdPlugin.failPrebind = test.prebindFail
296-
pbdPlugin.rejectPrebind = test.prebindReject
297-
298-
// Create a best effort pod.
299-
pod, err := createPausePod(cs,
300-
initPausePod(cs, &pausePodConfig{Name: "test-pod", Namespace: context.ns.Name}))
301-
if err != nil {
302-
t.Errorf("Error while creating a test pod: %v", err)
303-
}
304-
305-
if test.prebindFail {
306-
if err = wait.Poll(10*time.Millisecond, 30*time.Second, podSchedulingError(cs, pod.Namespace, pod.Name)); err != nil {
307-
t.Errorf("test #%v: Expected a scheduling error, but didn't get it. error: %v", i, err)
308-
}
309-
if unresPlugin.numUnreserveCalled != 1 {
310-
t.Errorf("test #%v: Expected the unreserve plugin to be called only once.", i)
311-
}
312-
} else {
313-
if test.prebindReject {
314-
if err = waitForPodUnschedulable(cs, pod); err != nil {
315-
t.Errorf("test #%v: Didn't expected the pod to be scheduled. error: %v", i, err)
316-
}
317-
if unresPlugin.numUnreserveCalled != 1 {
318-
t.Errorf("test #%v: Expected the unreserve plugin to be called only once.", i)
319-
}
320-
} else {
321-
if err = waitForPodToSchedule(cs, pod); err != nil {
322-
t.Errorf("test #%v: Expected the pod to be scheduled. error: %v", i, err)
323-
}
324-
if unresPlugin.numUnreserveCalled > 0 {
325-
t.Errorf("test #%v: Didn't expected the unreserve plugin to be called.", i)
326-
}
327-
}
328-
}
329-
unresPlugin.reset()
330-
cleanupPods(cs, t, []*v1.Pod{pod})
331-
}
332-
}

0 commit comments

Comments
 (0)