Skip to content

Commit c14b749

Browse files
committed
scheduler/volumebinding: move all volume binding logic into VolumeBinding plugin
1 parent ba3bf32 commit c14b749

File tree

17 files changed

+602
-121
lines changed

17 files changed

+602
-121
lines changed

cmd/kube-scheduler/app/server_test.go

Lines changed: 18 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -191,7 +191,11 @@ profiles:
191191
{Name: "TaintToleration", Weight: 1},
192192
{Name: "PodTopologySpread", Weight: 1},
193193
},
194-
"BindPlugin": {{Name: "DefaultBinder"}},
194+
"BindPlugin": {{Name: "DefaultBinder"}},
195+
"ReservePlugin": {{Name: "VolumeBinding"}},
196+
"UnreservePlugin": {{Name: "VolumeBinding"}},
197+
"PreBindPlugin": {{Name: "VolumeBinding"}},
198+
"PostBindPlugin": {{Name: "VolumeBinding"}},
195199
}
196200

197201
testcases := []struct {
@@ -222,6 +226,10 @@ profiles:
222226
"PreScorePlugin": {{Name: "InterPodAffinity"}, {Name: "TaintToleration"}},
223227
"QueueSortPlugin": {{Name: "PrioritySort"}},
224228
"ScorePlugin": {{Name: "InterPodAffinity", Weight: 1}, {Name: "TaintToleration", Weight: 1}},
229+
"ReservePlugin": {{Name: "VolumeBinding"}},
230+
"UnreservePlugin": {{Name: "VolumeBinding"}},
231+
"PreBindPlugin": {{Name: "VolumeBinding"}},
232+
"PostBindPlugin": {{Name: "VolumeBinding"}},
225233
},
226234
},
227235
},
@@ -236,6 +244,10 @@ profiles:
236244
"profile-disable-all-filter-and-score-plugins": {
237245
"BindPlugin": {{Name: "DefaultBinder"}},
238246
"QueueSortPlugin": {{Name: "PrioritySort"}},
247+
"ReservePlugin": {{Name: "VolumeBinding"}},
248+
"UnreservePlugin": {{Name: "VolumeBinding"}},
249+
"PreBindPlugin": {{Name: "VolumeBinding"}},
250+
"PostBindPlugin": {{Name: "VolumeBinding"}},
239251
},
240252
},
241253
},
@@ -310,7 +322,11 @@ profiles:
310322
{Name: "TaintToleration", Weight: 1},
311323
{Name: "PodTopologySpread", Weight: 1},
312324
},
313-
"BindPlugin": {{Name: "DefaultBinder"}},
325+
"BindPlugin": {{Name: "DefaultBinder"}},
326+
"ReservePlugin": {{Name: "VolumeBinding"}},
327+
"UnreservePlugin": {{Name: "VolumeBinding"}},
328+
"PreBindPlugin": {{Name: "VolumeBinding"}},
329+
"PostBindPlugin": {{Name: "VolumeBinding"}},
314330
},
315331
},
316332
},

pkg/scheduler/algorithmprovider/registry.go

Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -125,11 +125,31 @@ func getDefaultConfig() *schedulerapi.Plugins {
125125
{Name: tainttoleration.Name, Weight: 1},
126126
},
127127
},
128+
Reserve: &schedulerapi.PluginSet{
129+
Enabled: []schedulerapi.Plugin{
130+
{Name: volumebinding.Name},
131+
},
132+
},
133+
Unreserve: &schedulerapi.PluginSet{
134+
Enabled: []schedulerapi.Plugin{
135+
{Name: volumebinding.Name},
136+
},
137+
},
138+
PreBind: &schedulerapi.PluginSet{
139+
Enabled: []schedulerapi.Plugin{
140+
{Name: volumebinding.Name},
141+
},
142+
},
128143
Bind: &schedulerapi.PluginSet{
129144
Enabled: []schedulerapi.Plugin{
130145
{Name: defaultbinder.Name},
131146
},
132147
},
148+
PostBind: &schedulerapi.PluginSet{
149+
Enabled: []schedulerapi.Plugin{
150+
{Name: volumebinding.Name},
151+
},
152+
},
133153
}
134154
}
135155

pkg/scheduler/algorithmprovider/registry_test.go

Lines changed: 60 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -99,11 +99,31 @@ func TestClusterAutoscalerProvider(t *testing.T) {
9999
{Name: podtopologyspread.Name, Weight: 1},
100100
},
101101
},
102+
Reserve: &schedulerapi.PluginSet{
103+
Enabled: []schedulerapi.Plugin{
104+
{Name: volumebinding.Name},
105+
},
106+
},
107+
Unreserve: &schedulerapi.PluginSet{
108+
Enabled: []schedulerapi.Plugin{
109+
{Name: volumebinding.Name},
110+
},
111+
},
112+
PreBind: &schedulerapi.PluginSet{
113+
Enabled: []schedulerapi.Plugin{
114+
{Name: volumebinding.Name},
115+
},
116+
},
102117
Bind: &schedulerapi.PluginSet{
103118
Enabled: []schedulerapi.Plugin{
104119
{Name: defaultbinder.Name},
105120
},
106121
},
122+
PostBind: &schedulerapi.PluginSet{
123+
Enabled: []schedulerapi.Plugin{
124+
{Name: volumebinding.Name},
125+
},
126+
},
107127
}
108128

109129
r := NewRegistry()
@@ -172,11 +192,31 @@ func TestApplyFeatureGates(t *testing.T) {
172192
{Name: tainttoleration.Name, Weight: 1},
173193
},
174194
},
195+
Reserve: &schedulerapi.PluginSet{
196+
Enabled: []schedulerapi.Plugin{
197+
{Name: volumebinding.Name},
198+
},
199+
},
200+
Unreserve: &schedulerapi.PluginSet{
201+
Enabled: []schedulerapi.Plugin{
202+
{Name: volumebinding.Name},
203+
},
204+
},
205+
PreBind: &schedulerapi.PluginSet{
206+
Enabled: []schedulerapi.Plugin{
207+
{Name: volumebinding.Name},
208+
},
209+
},
175210
Bind: &schedulerapi.PluginSet{
176211
Enabled: []schedulerapi.Plugin{
177212
{Name: defaultbinder.Name},
178213
},
179214
},
215+
PostBind: &schedulerapi.PluginSet{
216+
Enabled: []schedulerapi.Plugin{
217+
{Name: volumebinding.Name},
218+
},
219+
},
180220
},
181221
},
182222
{
@@ -238,11 +278,31 @@ func TestApplyFeatureGates(t *testing.T) {
238278
{Name: noderesources.ResourceLimitsName, Weight: 1},
239279
},
240280
},
281+
Reserve: &schedulerapi.PluginSet{
282+
Enabled: []schedulerapi.Plugin{
283+
{Name: volumebinding.Name},
284+
},
285+
},
286+
Unreserve: &schedulerapi.PluginSet{
287+
Enabled: []schedulerapi.Plugin{
288+
{Name: volumebinding.Name},
289+
},
290+
},
291+
PreBind: &schedulerapi.PluginSet{
292+
Enabled: []schedulerapi.Plugin{
293+
{Name: volumebinding.Name},
294+
},
295+
},
241296
Bind: &schedulerapi.PluginSet{
242297
Enabled: []schedulerapi.Plugin{
243298
{Name: defaultbinder.Name},
244299
},
245300
},
301+
PostBind: &schedulerapi.PluginSet{
302+
Enabled: []schedulerapi.Plugin{
303+
{Name: volumebinding.Name},
304+
},
305+
},
246306
},
247307
},
248308
}

pkg/scheduler/apis/config/register.go

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -45,6 +45,7 @@ func addKnownTypes(scheme *runtime.Scheme) error {
4545
&PodTopologySpreadArgs{},
4646
&RequestedToCapacityRatioArgs{},
4747
&ServiceAffinityArgs{},
48+
&VolumeBindingArgs{},
4849
)
4950
scheme.AddKnownTypes(schema.GroupVersion{Group: "", Version: runtime.APIVersionInternal}, &Policy{})
5051
return nil

0 commit comments

Comments
 (0)