Skip to content

Commit 67afc8e

Browse files
authored
Merge pull request kubernetes#91625 from pancernik/v1beta1-extender-encoding
Fix API encoding inconsistencies in KubeSchedulerConfig
2 parents ef8380e + d7c84e1 commit 67afc8e

File tree

18 files changed

+722
-222
lines changed

18 files changed

+722
-222
lines changed

api/api-rules/violation_exceptions.list

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -375,11 +375,11 @@ API rule violation: list_type_missing,k8s.io/kube-controller-manager/config/v1al
375375
API rule violation: list_type_missing,k8s.io/kube-controller-manager/config/v1alpha1,GenericControllerManagerConfiguration,Controllers
376376
API rule violation: list_type_missing,k8s.io/kube-proxy/config/v1alpha1,KubeProxyConfiguration,NodePortAddresses
377377
API rule violation: list_type_missing,k8s.io/kube-proxy/config/v1alpha1,KubeProxyIPVSConfiguration,ExcludeCIDRs
378-
API rule violation: list_type_missing,k8s.io/kube-scheduler/config/v1,Extender,ManagedResources
379378
API rule violation: list_type_missing,k8s.io/kube-scheduler/config/v1,ExtenderTLSConfig,CAData
380379
API rule violation: list_type_missing,k8s.io/kube-scheduler/config/v1,ExtenderTLSConfig,CertData
381380
API rule violation: list_type_missing,k8s.io/kube-scheduler/config/v1,ExtenderTLSConfig,KeyData
382381
API rule violation: list_type_missing,k8s.io/kube-scheduler/config/v1,LabelsPresence,Labels
382+
API rule violation: list_type_missing,k8s.io/kube-scheduler/config/v1,LegacyExtender,ManagedResources
383383
API rule violation: list_type_missing,k8s.io/kube-scheduler/config/v1,Policy,Extenders
384384
API rule violation: list_type_missing,k8s.io/kube-scheduler/config/v1,Policy,Predicates
385385
API rule violation: list_type_missing,k8s.io/kube-scheduler/config/v1,Policy,Priorities
@@ -585,7 +585,7 @@ API rule violation: names_match,k8s.io/kube-controller-manager/config/v1alpha1,V
585585
API rule violation: names_match,k8s.io/kube-controller-manager/config/v1alpha1,VolumeConfiguration,FlexVolumePluginDir
586586
API rule violation: names_match,k8s.io/kube-controller-manager/config/v1alpha1,VolumeConfiguration,PersistentVolumeRecyclerConfiguration
587587
API rule violation: names_match,k8s.io/kube-proxy/config/v1alpha1,KubeProxyConfiguration,IPTables
588-
API rule violation: names_match,k8s.io/kube-scheduler/config/v1,Extender,EnableHTTPS
588+
API rule violation: names_match,k8s.io/kube-scheduler/config/v1,LegacyExtender,EnableHTTPS
589589
API rule violation: names_match,k8s.io/kubelet/config/v1beta1,KubeletConfiguration,IPTablesDropBit
590590
API rule violation: names_match,k8s.io/kubelet/config/v1beta1,KubeletConfiguration,IPTablesMasqueradeBit
591591
API rule violation: names_match,k8s.io/kubelet/config/v1beta1,KubeletConfiguration,ResolverConfig

hack/.golint_failures

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -172,6 +172,7 @@ pkg/registry/scheduling/rest
172172
pkg/registry/settings/rest
173173
pkg/registry/storage/rest
174174
pkg/registry/storage/storageclass
175+
pkg/scheduler/apis/config/v1
175176
pkg/scheduler/apis/config/v1beta1
176177
pkg/security/podsecuritypolicy
177178
pkg/security/podsecuritypolicy/group

pkg/scheduler/apis/config/legacy_types.go

Lines changed: 0 additions & 83 deletions
Original file line numberDiff line numberDiff line change
@@ -17,8 +17,6 @@ limitations under the License.
1717
package config
1818

1919
import (
20-
"time"
21-
2220
metav1 "k8s.io/apimachinery/pkg/apis/meta/v1"
2321
)
2422

@@ -135,84 +133,3 @@ type RequestedToCapacityRatioArguments struct {
135133
Shape []UtilizationShapePoint `json:"shape"`
136134
Resources []ResourceSpec `json:"resources,omitempty"`
137135
}
138-
139-
// ExtenderManagedResource describes the arguments of extended resources
140-
// managed by an extender.
141-
type ExtenderManagedResource struct {
142-
// Name is the extended resource name.
143-
Name string
144-
// IgnoredByScheduler indicates whether kube-scheduler should ignore this
145-
// resource when applying predicates.
146-
IgnoredByScheduler bool
147-
}
148-
149-
// ExtenderTLSConfig contains settings to enable TLS with extender
150-
type ExtenderTLSConfig struct {
151-
// Server should be accessed without verifying the TLS certificate. For testing only.
152-
Insecure bool
153-
// ServerName is passed to the server for SNI and is used in the client to check server
154-
// certificates against. If ServerName is empty, the hostname used to contact the
155-
// server is used.
156-
ServerName string
157-
158-
// Server requires TLS client certificate authentication
159-
CertFile string
160-
// Server requires TLS client certificate authentication
161-
KeyFile string
162-
// Trusted root certificates for server
163-
CAFile string
164-
165-
// CertData holds PEM-encoded bytes (typically read from a client certificate file).
166-
// CertData takes precedence over CertFile
167-
CertData []byte
168-
// KeyData holds PEM-encoded bytes (typically read from a client certificate key file).
169-
// KeyData takes precedence over KeyFile
170-
KeyData []byte
171-
// CAData holds PEM-encoded bytes (typically read from a root certificates bundle).
172-
// CAData takes precedence over CAFile
173-
CAData []byte
174-
}
175-
176-
// Extender holds the parameters used to communicate with the extender. If a verb is unspecified/empty,
177-
// it is assumed that the extender chose not to provide that extension.
178-
type Extender struct {
179-
// URLPrefix at which the extender is available
180-
URLPrefix string
181-
// Verb for the filter call, empty if not supported. This verb is appended to the URLPrefix when issuing the filter call to extender.
182-
FilterVerb string
183-
// Verb for the preempt call, empty if not supported. This verb is appended to the URLPrefix when issuing the preempt call to extender.
184-
PreemptVerb string
185-
// Verb for the prioritize call, empty if not supported. This verb is appended to the URLPrefix when issuing the prioritize call to extender.
186-
PrioritizeVerb string
187-
// The numeric multiplier for the node scores that the prioritize call generates.
188-
// The weight should be a positive integer
189-
Weight int64
190-
// Verb for the bind call, empty if not supported. This verb is appended to the URLPrefix when issuing the bind call to extender.
191-
// If this method is implemented by the extender, it is the extender's responsibility to bind the pod to apiserver. Only one extender
192-
// can implement this function.
193-
BindVerb string
194-
// EnableHTTPS specifies whether https should be used to communicate with the extender
195-
EnableHTTPS bool
196-
// TLSConfig specifies the transport layer security config
197-
TLSConfig *ExtenderTLSConfig
198-
// HTTPTimeout specifies the timeout duration for a call to the extender. Filter timeout fails the scheduling of the pod. Prioritize
199-
// timeout is ignored, k8s/other extenders priorities are used to select the node.
200-
HTTPTimeout time.Duration
201-
// NodeCacheCapable specifies that the extender is capable of caching node information,
202-
// so the scheduler should only send minimal information about the eligible nodes
203-
// assuming that the extender already cached full details of all nodes in the cluster
204-
NodeCacheCapable bool
205-
// ManagedResources is a list of extended resources that are managed by
206-
// this extender.
207-
// - A pod will be sent to the extender on the Filter, Prioritize and Bind
208-
// (if the extender is the binder) phases iff the pod requests at least
209-
// one of the extended resources in this list. If empty or unspecified,
210-
// all pods will be sent to this extender.
211-
// - If IgnoredByScheduler is set to true for a resource, kube-scheduler
212-
// will skip checking the resource in predicates.
213-
// +optional
214-
ManagedResources []ExtenderManagedResource
215-
// Ignorable specifies if the extender is ignorable, i.e. scheduling should not
216-
// fail when the extender returns an error or is not reachable.
217-
Ignorable bool
218-
}

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

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -513,7 +513,7 @@ func TestCompatibility_v1_Scheduler(t *testing.T) {
513513
BindVerb: "bind", // 1.7 was missing json tags on the BindVerb field and required "BindVerb"
514514
EnableHTTPS: true,
515515
TLSConfig: &config.ExtenderTLSConfig{Insecure: true},
516-
HTTPTimeout: 1,
516+
HTTPTimeout: metav1.Duration{Duration: 1},
517517
NodeCacheCapable: true,
518518
}},
519519
},
@@ -611,7 +611,7 @@ func TestCompatibility_v1_Scheduler(t *testing.T) {
611611
BindVerb: "bind", // 1.8 became case-insensitive and tolerated "bindVerb"
612612
EnableHTTPS: true,
613613
TLSConfig: &config.ExtenderTLSConfig{Insecure: true},
614-
HTTPTimeout: 1,
614+
HTTPTimeout: metav1.Duration{Duration: 1},
615615
NodeCacheCapable: true,
616616
}},
617617
},
@@ -716,7 +716,7 @@ func TestCompatibility_v1_Scheduler(t *testing.T) {
716716
BindVerb: "bind", // 1.9 was case-insensitive and tolerated "bindVerb"
717717
EnableHTTPS: true,
718718
TLSConfig: &config.ExtenderTLSConfig{Insecure: true},
719-
HTTPTimeout: 1,
719+
HTTPTimeout: metav1.Duration{Duration: 1},
720720
NodeCacheCapable: true,
721721
}},
722722
},
@@ -824,7 +824,7 @@ func TestCompatibility_v1_Scheduler(t *testing.T) {
824824
BindVerb: "bind", // 1.10 was case-insensitive and tolerated "bindVerb"
825825
EnableHTTPS: true,
826826
TLSConfig: &config.ExtenderTLSConfig{Insecure: true},
827-
HTTPTimeout: 1,
827+
HTTPTimeout: metav1.Duration{Duration: 1},
828828
NodeCacheCapable: true,
829829
ManagedResources: []config.ExtenderManagedResource{{Name: "example.com/foo", IgnoredByScheduler: true}},
830830
Ignorable: true,
@@ -945,7 +945,7 @@ func TestCompatibility_v1_Scheduler(t *testing.T) {
945945
BindVerb: "bind", // 1.11 restored case-sensitivity, but allowed either "BindVerb" or "bindVerb"
946946
EnableHTTPS: true,
947947
TLSConfig: &config.ExtenderTLSConfig{Insecure: true},
948-
HTTPTimeout: 1,
948+
HTTPTimeout: metav1.Duration{Duration: 1},
949949
NodeCacheCapable: true,
950950
ManagedResources: []config.ExtenderManagedResource{{Name: "example.com/foo", IgnoredByScheduler: true}},
951951
Ignorable: true,
@@ -1068,7 +1068,7 @@ func TestCompatibility_v1_Scheduler(t *testing.T) {
10681068
BindVerb: "bind", // 1.11 restored case-sensitivity, but allowed either "BindVerb" or "bindVerb"
10691069
EnableHTTPS: true,
10701070
TLSConfig: &config.ExtenderTLSConfig{Insecure: true},
1071-
HTTPTimeout: 1,
1071+
HTTPTimeout: metav1.Duration{Duration: 1},
10721072
NodeCacheCapable: true,
10731073
ManagedResources: []config.ExtenderManagedResource{{Name: "example.com/foo", IgnoredByScheduler: true}},
10741074
Ignorable: true,
@@ -1191,7 +1191,7 @@ func TestCompatibility_v1_Scheduler(t *testing.T) {
11911191
BindVerb: "bind", // 1.11 restored case-sensitivity, but allowed either "BindVerb" or "bindVerb"
11921192
EnableHTTPS: true,
11931193
TLSConfig: &config.ExtenderTLSConfig{Insecure: true},
1194-
HTTPTimeout: 1,
1194+
HTTPTimeout: metav1.Duration{Duration: 1},
11951195
NodeCacheCapable: true,
11961196
ManagedResources: []config.ExtenderManagedResource{{Name: "example.com/foo", IgnoredByScheduler: true}},
11971197
Ignorable: true,
@@ -1318,7 +1318,7 @@ func TestCompatibility_v1_Scheduler(t *testing.T) {
13181318
BindVerb: "bind", // 1.11 restored case-sensitivity, but allowed either "BindVerb" or "bindVerb"
13191319
EnableHTTPS: true,
13201320
TLSConfig: &config.ExtenderTLSConfig{Insecure: true},
1321-
HTTPTimeout: 1,
1321+
HTTPTimeout: metav1.Duration{Duration: 1},
13221322
NodeCacheCapable: true,
13231323
ManagedResources: []config.ExtenderManagedResource{{Name: "example.com/foo", IgnoredByScheduler: true}},
13241324
Ignorable: true,

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

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -36,7 +36,7 @@ extenders:
3636
filterVerb: filter
3737
prioritizeVerb: prioritize
3838
weight: 1
39-
enableHttps: false
39+
enableHttps: true
4040
`
4141
)
4242

@@ -48,7 +48,7 @@ func TestSchedulerPolicy(t *testing.T) {
4848
FilterVerb: "filter",
4949
PrioritizeVerb: "prioritize",
5050
Weight: 1,
51-
EnableHTTPS: false,
51+
EnableHTTPS: true,
5252
},
5353
},
5454
}

pkg/scheduler/apis/config/types.go

Lines changed: 81 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -340,3 +340,84 @@ func mergePluginSets(defaultPluginSet, customPluginSet *PluginSet) *PluginSet {
340340

341341
return &PluginSet{Enabled: enabledPlugins}
342342
}
343+
344+
// Extender holds the parameters used to communicate with the extender. If a verb is unspecified/empty,
345+
// it is assumed that the extender chose not to provide that extension.
346+
type Extender struct {
347+
// URLPrefix at which the extender is available
348+
URLPrefix string
349+
// Verb for the filter call, empty if not supported. This verb is appended to the URLPrefix when issuing the filter call to extender.
350+
FilterVerb string
351+
// Verb for the preempt call, empty if not supported. This verb is appended to the URLPrefix when issuing the preempt call to extender.
352+
PreemptVerb string
353+
// Verb for the prioritize call, empty if not supported. This verb is appended to the URLPrefix when issuing the prioritize call to extender.
354+
PrioritizeVerb string
355+
// The numeric multiplier for the node scores that the prioritize call generates.
356+
// The weight should be a positive integer
357+
Weight int64
358+
// Verb for the bind call, empty if not supported. This verb is appended to the URLPrefix when issuing the bind call to extender.
359+
// If this method is implemented by the extender, it is the extender's responsibility to bind the pod to apiserver. Only one extender
360+
// can implement this function.
361+
BindVerb string
362+
// EnableHTTPS specifies whether https should be used to communicate with the extender
363+
EnableHTTPS bool
364+
// TLSConfig specifies the transport layer security config
365+
TLSConfig *ExtenderTLSConfig
366+
// HTTPTimeout specifies the timeout duration for a call to the extender. Filter timeout fails the scheduling of the pod. Prioritize
367+
// timeout is ignored, k8s/other extenders priorities are used to select the node.
368+
HTTPTimeout metav1.Duration
369+
// NodeCacheCapable specifies that the extender is capable of caching node information,
370+
// so the scheduler should only send minimal information about the eligible nodes
371+
// assuming that the extender already cached full details of all nodes in the cluster
372+
NodeCacheCapable bool
373+
// ManagedResources is a list of extended resources that are managed by
374+
// this extender.
375+
// - A pod will be sent to the extender on the Filter, Prioritize and Bind
376+
// (if the extender is the binder) phases iff the pod requests at least
377+
// one of the extended resources in this list. If empty or unspecified,
378+
// all pods will be sent to this extender.
379+
// - If IgnoredByScheduler is set to true for a resource, kube-scheduler
380+
// will skip checking the resource in predicates.
381+
// +optional
382+
ManagedResources []ExtenderManagedResource
383+
// Ignorable specifies if the extender is ignorable, i.e. scheduling should not
384+
// fail when the extender returns an error or is not reachable.
385+
Ignorable bool
386+
}
387+
388+
// ExtenderManagedResource describes the arguments of extended resources
389+
// managed by an extender.
390+
type ExtenderManagedResource struct {
391+
// Name is the extended resource name.
392+
Name string
393+
// IgnoredByScheduler indicates whether kube-scheduler should ignore this
394+
// resource when applying predicates.
395+
IgnoredByScheduler bool
396+
}
397+
398+
// ExtenderTLSConfig contains settings to enable TLS with extender
399+
type ExtenderTLSConfig struct {
400+
// Server should be accessed without verifying the TLS certificate. For testing only.
401+
Insecure bool
402+
// ServerName is passed to the server for SNI and is used in the client to check server
403+
// certificates against. If ServerName is empty, the hostname used to contact the
404+
// server is used.
405+
ServerName string
406+
407+
// Server requires TLS client certificate authentication
408+
CertFile string
409+
// Server requires TLS client certificate authentication
410+
KeyFile string
411+
// Trusted root certificates for server
412+
CAFile string
413+
414+
// CertData holds PEM-encoded bytes (typically read from a client certificate file).
415+
// CertData takes precedence over CertFile
416+
CertData []byte
417+
// KeyData holds PEM-encoded bytes (typically read from a client certificate key file).
418+
// KeyData takes precedence over KeyFile
419+
KeyData []byte
420+
// CAData holds PEM-encoded bytes (typically read from a root certificates bundle).
421+
// CAData takes precedence over CAFile
422+
CAData []byte
423+
}

pkg/scheduler/apis/config/v1/BUILD

Lines changed: 14 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,9 @@
1-
load("@io_bazel_rules_go//go:def.bzl", "go_library")
1+
load("@io_bazel_rules_go//go:def.bzl", "go_library", "go_test")
22

33
go_library(
44
name = "go_default_library",
55
srcs = [
6+
"conversion.go",
67
"doc.go",
78
"register.go",
89
"zz_generated.conversion.go",
@@ -33,3 +34,15 @@ filegroup(
3334
tags = ["automanaged"],
3435
visibility = ["//visibility:public"],
3536
)
37+
38+
go_test(
39+
name = "go_default_test",
40+
srcs = ["conversion_test.go"],
41+
embed = [":go_default_library"],
42+
deps = [
43+
"//pkg/scheduler/apis/config:go_default_library",
44+
"//staging/src/k8s.io/apimachinery/pkg/apis/meta/v1:go_default_library",
45+
"//staging/src/k8s.io/kube-scheduler/config/v1:go_default_library",
46+
"//vendor/github.com/google/go-cmp/cmp:go_default_library",
47+
],
48+
)

0 commit comments

Comments
 (0)