Skip to content

Commit b35fdbc

Browse files
authored
Merge pull request kubernetes#89904 from alculquicondor/raw-extension-plugin-args
Use RawExtension and Object for external and internal, respectively, scheduling plugin args
2 parents 1df63e7 + ce05382 commit b35fdbc

File tree

45 files changed

+148
-111
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

45 files changed

+148
-111
lines changed

cmd/kube-scheduler/app/options/options_test.go

Lines changed: 8 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -204,6 +204,8 @@ profiles:
204204
- name: baz
205205
pluginConfig:
206206
- name: foo
207+
args:
208+
bar: baz
207209
`, configKubeconfig)), os.FileMode(0600)); err != nil {
208210
t.Fatal(err)
209211
}
@@ -543,7 +545,10 @@ profiles:
543545
PluginConfig: []kubeschedulerconfig.PluginConfig{
544546
{
545547
Name: "foo",
546-
Args: runtime.Unknown{},
548+
Args: &runtime.Unknown{
549+
Raw: []byte(`{"bar":"baz"}`),
550+
ContentType: "application/json",
551+
},
547552
},
548553
},
549554
},
@@ -608,7 +613,6 @@ profiles:
608613
PluginConfig: []kubeschedulerconfig.PluginConfig{
609614
{
610615
Name: "foo",
611-
Args: runtime.Unknown{},
612616
},
613617
},
614618
},
@@ -666,7 +670,7 @@ profiles:
666670
PluginConfig: []kubeschedulerconfig.PluginConfig{
667671
{
668672
Name: "InterPodAffinity",
669-
Args: runtime.Unknown{
673+
Args: &runtime.Unknown{
670674
Raw: []byte(`{"hardPodAffinityWeight":5}`),
671675
},
672676
},
@@ -760,7 +764,7 @@ profiles:
760764
}
761765

762766
if diff := cmp.Diff(tc.expectedConfig, config.ComponentConfig); diff != "" {
763-
t.Errorf("incorrect config (-want, +got):\n%s", diff)
767+
t.Errorf("incorrect config (-want,+got):\n%s", diff)
764768
}
765769

766770
// ensure we have a client

pkg/scheduler/apis/config/testing/compatibility_test.go

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1598,7 +1598,7 @@ func TestPluginsConfigurationCompatibility(t *testing.T) {
15981598
pluginConfig: []config.PluginConfig{
15991599
{
16001600
Name: "NodeResourcesFit",
1601-
Args: runtime.Unknown{
1601+
Args: &runtime.Unknown{
16021602
Raw: []byte(`{
16031603
"ignoredResources": [
16041604
"foo",
@@ -1609,7 +1609,7 @@ func TestPluginsConfigurationCompatibility(t *testing.T) {
16091609
},
16101610
{
16111611
Name: "PodTopologySpread",
1612-
Args: runtime.Unknown{
1612+
Args: &runtime.Unknown{
16131613
Raw: []byte(`{
16141614
"defaultConstraints": [
16151615
{
@@ -1628,7 +1628,7 @@ func TestPluginsConfigurationCompatibility(t *testing.T) {
16281628
},
16291629
{
16301630
Name: "RequestedToCapacityRatio",
1631-
Args: runtime.Unknown{
1631+
Args: &runtime.Unknown{
16321632
Raw: []byte(`{
16331633
"shape":[
16341634
"Utilization": 5,
@@ -1643,15 +1643,15 @@ func TestPluginsConfigurationCompatibility(t *testing.T) {
16431643
},
16441644
{
16451645
Name: "InterPodAffinity",
1646-
Args: runtime.Unknown{
1646+
Args: &runtime.Unknown{
16471647
Raw: []byte(`{
16481648
"HardPodAffinityWeight": 100
16491649
}`),
16501650
},
16511651
},
16521652
{
16531653
Name: "NodeLabel",
1654-
Args: runtime.Unknown{
1654+
Args: &runtime.Unknown{
16551655
Raw: []byte(`{
16561656
"presentLabels": [
16571657
"foo",
@@ -1671,7 +1671,7 @@ func TestPluginsConfigurationCompatibility(t *testing.T) {
16711671
},
16721672
{
16731673
Name: "ServiceAffinity",
1674-
Args: runtime.Unknown{
1674+
Args: &runtime.Unknown{
16751675
Raw: []byte(`{
16761676
affinityLabels: [
16771677
"foo",

pkg/scheduler/apis/config/types.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -246,7 +246,7 @@ type PluginConfig struct {
246246
// Name defines the name of plugin being configured
247247
Name string
248248
// Args defines the arguments passed to the plugins at the time of initialization. Args can have arbitrary structure.
249-
Args runtime.Unknown
249+
Args runtime.Object
250250
}
251251

252252
/*

pkg/scheduler/apis/config/v1alpha2/zz_generated.conversion.go

Lines changed: 28 additions & 4 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

pkg/scheduler/apis/config/zz_generated.deepcopy.go

Lines changed: 3 additions & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

pkg/scheduler/core/extender_test.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -110,7 +110,7 @@ func machine2PrioritizerExtender(pod *v1.Pod, nodes []*v1.Node) (*framework.Node
110110
type machine2PrioritizerPlugin struct{}
111111

112112
func newMachine2PrioritizerPlugin() framework.PluginFactory {
113-
return func(_ *runtime.Unknown, _ framework.FrameworkHandle) (framework.Plugin, error) {
113+
return func(_ runtime.Object, _ framework.FrameworkHandle) (framework.Plugin, error) {
114114
return &machine2PrioritizerPlugin{}, nil
115115
}
116116
}

pkg/scheduler/core/generic_scheduler_test.go

Lines changed: 11 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -81,7 +81,7 @@ func (pl *trueFilterPlugin) Filter(_ context.Context, _ *framework.CycleState, p
8181
}
8282

8383
// NewTrueFilterPlugin initializes a trueFilterPlugin and returns it.
84-
func NewTrueFilterPlugin(_ *runtime.Unknown, _ framework.FrameworkHandle) (framework.Plugin, error) {
84+
func NewTrueFilterPlugin(_ runtime.Object, _ framework.FrameworkHandle) (framework.Plugin, error) {
8585
return &trueFilterPlugin{}, nil
8686
}
8787

@@ -98,7 +98,7 @@ func (pl *falseFilterPlugin) Filter(_ context.Context, _ *framework.CycleState,
9898
}
9999

100100
// NewFalseFilterPlugin initializes a falseFilterPlugin and returns it.
101-
func NewFalseFilterPlugin(_ *runtime.Unknown, _ framework.FrameworkHandle) (framework.Plugin, error) {
101+
func NewFalseFilterPlugin(_ runtime.Object, _ framework.FrameworkHandle) (framework.Plugin, error) {
102102
return &falseFilterPlugin{}, nil
103103
}
104104

@@ -122,7 +122,7 @@ func (pl *matchFilterPlugin) Filter(_ context.Context, _ *framework.CycleState,
122122
}
123123

124124
// NewMatchFilterPlugin initializes a matchFilterPlugin and returns it.
125-
func NewMatchFilterPlugin(_ *runtime.Unknown, _ framework.FrameworkHandle) (framework.Plugin, error) {
125+
func NewMatchFilterPlugin(_ runtime.Object, _ framework.FrameworkHandle) (framework.Plugin, error) {
126126
return &matchFilterPlugin{}, nil
127127
}
128128

@@ -142,7 +142,7 @@ func (pl *noPodsFilterPlugin) Filter(_ context.Context, _ *framework.CycleState,
142142
}
143143

144144
// NewNoPodsFilterPlugin initializes a noPodsFilterPlugin and returns it.
145-
func NewNoPodsFilterPlugin(_ *runtime.Unknown, _ framework.FrameworkHandle) (framework.Plugin, error) {
145+
func NewNoPodsFilterPlugin(_ runtime.Object, _ framework.FrameworkHandle) (framework.Plugin, error) {
146146
return &noPodsFilterPlugin{}, nil
147147
}
148148

@@ -171,7 +171,7 @@ func (pl *fakeFilterPlugin) Filter(_ context.Context, _ *framework.CycleState, p
171171

172172
// NewFakeFilterPlugin initializes a fakeFilterPlugin and returns it.
173173
func NewFakeFilterPlugin(failedNodeReturnCodeMap map[string]framework.Code) framework.PluginFactory {
174-
return func(_ *runtime.Unknown, _ framework.FrameworkHandle) (framework.Plugin, error) {
174+
return func(_ runtime.Object, _ framework.FrameworkHandle) (framework.Plugin, error) {
175175
return &fakeFilterPlugin{
176176
failedNodeReturnCodeMap: failedNodeReturnCodeMap,
177177
}, nil
@@ -181,7 +181,7 @@ func NewFakeFilterPlugin(failedNodeReturnCodeMap map[string]framework.Code) fram
181181
type numericMapPlugin struct{}
182182

183183
func newNumericMapPlugin() framework.PluginFactory {
184-
return func(_ *runtime.Unknown, _ framework.FrameworkHandle) (framework.Plugin, error) {
184+
return func(_ runtime.Object, _ framework.FrameworkHandle) (framework.Plugin, error) {
185185
return &numericMapPlugin{}, nil
186186
}
187187
}
@@ -205,7 +205,7 @@ func (pl *numericMapPlugin) ScoreExtensions() framework.ScoreExtensions {
205205
type reverseNumericMapPlugin struct{}
206206

207207
func newReverseNumericMapPlugin() framework.PluginFactory {
208-
return func(_ *runtime.Unknown, _ framework.FrameworkHandle) (framework.Plugin, error) {
208+
return func(_ runtime.Object, _ framework.FrameworkHandle) (framework.Plugin, error) {
209209
return &reverseNumericMapPlugin{}, nil
210210
}
211211
}
@@ -246,7 +246,7 @@ func (pl *reverseNumericMapPlugin) NormalizeScore(_ context.Context, _ *framewor
246246
type trueMapPlugin struct{}
247247

248248
func newTrueMapPlugin() framework.PluginFactory {
249-
return func(_ *runtime.Unknown, _ framework.FrameworkHandle) (framework.Plugin, error) {
249+
return func(_ runtime.Object, _ framework.FrameworkHandle) (framework.Plugin, error) {
250250
return &trueMapPlugin{}, nil
251251
}
252252
}
@@ -275,7 +275,7 @@ func (pl *trueMapPlugin) NormalizeScore(_ context.Context, _ *framework.CycleSta
275275
type falseMapPlugin struct{}
276276

277277
func newFalseMapPlugin() framework.PluginFactory {
278-
return func(_ *runtime.Unknown, _ framework.FrameworkHandle) (framework.Plugin, error) {
278+
return func(_ runtime.Object, _ framework.FrameworkHandle) (framework.Plugin, error) {
279279
return &falseMapPlugin{}, nil
280280
}
281281
}
@@ -962,7 +962,7 @@ func TestFindFitPredicateCallCounts(t *testing.T) {
962962
plugin := fakeFilterPlugin{}
963963
registerFakeFilterFunc := st.RegisterFilterPlugin(
964964
"FakeFilter",
965-
func(_ *runtime.Unknown, fh framework.FrameworkHandle) (framework.Plugin, error) {
965+
func(_ runtime.Object, fh framework.FrameworkHandle) (framework.Plugin, error) {
966966
return &plugin, nil
967967
},
968968
)
@@ -1598,7 +1598,7 @@ func TestSelectNodesForPreemption(t *testing.T) {
15981598
fakePlugin.failedNodeReturnCodeMap = filterFailedNodeReturnCodeMap
15991599
registerFakeFilterFunc := st.RegisterFilterPlugin(
16001600
"FakeFilter",
1601-
func(_ *runtime.Unknown, fh framework.FrameworkHandle) (framework.Plugin, error) {
1601+
func(_ runtime.Object, fh framework.FrameworkHandle) (framework.Plugin, error) {
16021602
return &fakePlugin, nil
16031603
},
16041604
)

pkg/scheduler/factory.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -342,7 +342,7 @@ func (c *Configurator) createFromConfig(policy schedulerapi.Policy) (*Scheduler,
342342
// mergePluginConfigsFromPolicy merges the giving plugin configs ensuring that,
343343
// if a plugin name is repeated, the arguments are the same.
344344
func mergePluginConfigsFromPolicy(pc1, pc2 []schedulerapi.PluginConfig) ([]schedulerapi.PluginConfig, error) {
345-
args := make(map[string]runtime.Unknown)
345+
args := make(map[string]runtime.Object)
346346
for _, c := range pc1 {
347347
args[c.Name] = c.Args
348348
}

pkg/scheduler/factory_test.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -250,7 +250,7 @@ func TestCreateFromConfigWithHardPodAffinitySymmetricWeight(t *testing.T) {
250250
for _, cfg := range factory.profiles[0].PluginConfig {
251251
if cfg.Name == interpodaffinity.Name {
252252
foundAffinityCfg = true
253-
wantArgs := runtime.Unknown{Raw: []byte(`{"hardPodAffinityWeight":10}`)}
253+
wantArgs := &runtime.Unknown{Raw: []byte(`{"hardPodAffinityWeight":10}`)}
254254

255255
if diff := cmp.Diff(wantArgs, cfg.Args); diff != "" {
256256
t.Errorf("wrong InterPodAffinity args (-want, +got): %s", diff)

pkg/scheduler/framework/plugins/defaultbinder/default_binder.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -37,7 +37,7 @@ type DefaultBinder struct {
3737
var _ framework.BindPlugin = &DefaultBinder{}
3838

3939
// New creates a DefaultBinder.
40-
func New(_ *runtime.Unknown, handle framework.FrameworkHandle) (framework.Plugin, error) {
40+
func New(_ runtime.Object, handle framework.FrameworkHandle) (framework.Plugin, error) {
4141
return &DefaultBinder{handle: handle}, nil
4242
}
4343

0 commit comments

Comments
 (0)