From 09598d48f65562be27573a560daf5d86dd5b7bcc Mon Sep 17 00:00:00 2001 From: Rafal Wicha Date: Mon, 2 Mar 2020 15:20:44 +0000 Subject: [PATCH] Improve plugin args JSON tags --- pkg/scheduler/apis/config/legacy_types.go | 6 +++--- pkg/scheduler/factory_test.go | 2 +- .../framework/plugins/serviceaffinity/service_affinity.go | 2 +- 3 files changed, 5 insertions(+), 5 deletions(-) diff --git a/pkg/scheduler/apis/config/legacy_types.go b/pkg/scheduler/apis/config/legacy_types.go index 4e5ffa1ee21..79eb0daed7e 100644 --- a/pkg/scheduler/apis/config/legacy_types.go +++ b/pkg/scheduler/apis/config/legacy_types.go @@ -131,9 +131,9 @@ type LabelPreference struct { // RequestedToCapacityRatioArguments holds arguments specific to RequestedToCapacityRatio priority function. type RequestedToCapacityRatioArguments struct { - // Array of point defining priority function shape - Shape []UtilizationShapePoint - Resources []ResourceSpec + // Array of point defining priority function shape. + Shape []UtilizationShapePoint `json:"shape"` + Resources []ResourceSpec `json:"resources,omitempty"` } // UtilizationShapePoint represents single point of priority function shape diff --git a/pkg/scheduler/factory_test.go b/pkg/scheduler/factory_test.go index 1c6498a8f51..900773c0a1e 100644 --- a/pkg/scheduler/factory_test.go +++ b/pkg/scheduler/factory_test.go @@ -128,7 +128,7 @@ func TestCreateFromConfig(t *testing.T) { wantArgs := `{"Name":"NodeLabel","Args":{"presentLabels":["zone"],"absentLabels":["foo"],"presentLabelsPreference":["l1"],"absentLabelsPreference":["l2"]}}` verifyPluginConvertion(t, nodelabel.Name, []string{"FilterPlugin", "ScorePlugin"}, prof, &factory.profiles[0], 6, wantArgs) // Verify that service affinity custom predicate/priority is converted to framework plugin. - wantArgs = `{"Name":"ServiceAffinity","Args":{"labels":["zone","foo"],"antiAffinityLabelsPreference":["rack","zone"]}}` + wantArgs = `{"Name":"ServiceAffinity","Args":{"affinityLabels":["zone","foo"],"antiAffinityLabelsPreference":["rack","zone"]}}` verifyPluginConvertion(t, serviceaffinity.Name, []string{"FilterPlugin", "ScorePlugin"}, prof, &factory.profiles[0], 6, wantArgs) // TODO(#87703): Verify all plugin configs. } diff --git a/pkg/scheduler/framework/plugins/serviceaffinity/service_affinity.go b/pkg/scheduler/framework/plugins/serviceaffinity/service_affinity.go index 1edc43bf3fa..296af14f9c0 100644 --- a/pkg/scheduler/framework/plugins/serviceaffinity/service_affinity.go +++ b/pkg/scheduler/framework/plugins/serviceaffinity/service_affinity.go @@ -46,7 +46,7 @@ type Args struct { // Labels are homogeneous for pods that are scheduled to a node. // (i.e. it returns true IFF this pod can be added to this node such that all other pods in // the same service are running on nodes with the exact same values for Labels). - AffinityLabels []string `json:"labels,omitempty"` + AffinityLabels []string `json:"affinityLabels,omitempty"` // AntiAffinityLabelsPreference are the labels to consider for service anti affinity scoring. AntiAffinityLabelsPreference []string `json:"antiAffinityLabelsPreference,omitempty"` }