diff --git a/hack/.golint_failures b/hack/.golint_failures index 4ed6cb6cece08..fe910069ffd8c 100644 --- a/hack/.golint_failures +++ b/hack/.golint_failures @@ -35,6 +35,7 @@ pkg/apis/discovery/v1alpha1 pkg/apis/events/v1beta1 pkg/apis/extensions pkg/apis/extensions/v1beta1 +pkg/apis/flowcontrol/v1alpha1 pkg/apis/networking/v1 pkg/apis/node/v1alpha1 pkg/apis/policy diff --git a/hack/lib/init.sh b/hack/lib/init.sh index 0d3fbd4c5bec2..4822dfe3745f1 100755 --- a/hack/lib/init.sh +++ b/hack/lib/init.sh @@ -103,6 +103,7 @@ settings.k8s.io/v1alpha1 \ storage.k8s.io/v1beta1 \ storage.k8s.io/v1 \ storage.k8s.io/v1alpha1 \ +flowcontrol.apiserver.k8s.io/v1alpha1 \ }" # not all group versions are exposed by the server. This list contains those diff --git a/pkg/apis/flowcontrol/doc.go b/pkg/apis/flowcontrol/doc.go new file mode 100644 index 0000000000000..33730efe58cd5 --- /dev/null +++ b/pkg/apis/flowcontrol/doc.go @@ -0,0 +1,21 @@ +/* +Copyright 2019 The Kubernetes Authors. + +Licensed under the Apache License, Version 2.0 (the "License"); +you may not use this file except in compliance with the License. +You may obtain a copy of the License at + + http://www.apache.org/licenses/LICENSE-2.0 + +Unless required by applicable law or agreed to in writing, software +distributed under the License is distributed on an "AS IS" BASIS, +WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +See the License for the specific language governing permissions and +limitations under the License. +*/ + +// +k8s:deepcopy-gen=package +// +groupName=flowcontrol.apiserver.k8s.io + +// Package flowcontrol provides api definitions for the "flowcontrol.apiserver.k8s.io" api group. +package flowcontrol // import "k8s.io/kubernetes/pkg/apis/flowcontrol" diff --git a/pkg/apis/flowcontrol/install/BUILD b/pkg/apis/flowcontrol/install/BUILD new file mode 100644 index 0000000000000..7fe00779c1e38 --- /dev/null +++ b/pkg/apis/flowcontrol/install/BUILD @@ -0,0 +1,32 @@ +package(default_visibility = ["//visibility:public"]) + +load( + "@io_bazel_rules_go//go:def.bzl", + "go_library", +) + +go_library( + name = "go_default_library", + srcs = ["install.go"], + importpath = "k8s.io/kubernetes/pkg/apis/flowcontrol/install", + deps = [ + "//pkg/api/legacyscheme:go_default_library", + "//pkg/apis/flowcontrol:go_default_library", + "//pkg/apis/flowcontrol/v1alpha1:go_default_library", + "//staging/src/k8s.io/apimachinery/pkg/runtime:go_default_library", + "//staging/src/k8s.io/apimachinery/pkg/util/runtime:go_default_library", + ], +) + +filegroup( + name = "package-srcs", + srcs = glob(["**"]), + tags = ["automanaged"], + visibility = ["//visibility:private"], +) + +filegroup( + name = "all-srcs", + srcs = [":package-srcs"], + tags = ["automanaged"], +) diff --git a/pkg/apis/flowcontrol/install/install.go b/pkg/apis/flowcontrol/install/install.go new file mode 100644 index 0000000000000..825091e114abb --- /dev/null +++ b/pkg/apis/flowcontrol/install/install.go @@ -0,0 +1,38 @@ +/* +Copyright 2015 The Kubernetes Authors. + +Licensed under the Apache License, Version 2.0 (the "License"); +you may not use this file except in compliance with the License. +You may obtain a copy of the License at + + http://www.apache.org/licenses/LICENSE-2.0 + +Unless required by applicable law or agreed to in writing, software +distributed under the License is distributed on an "AS IS" BASIS, +WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +See the License for the specific language governing permissions and +limitations under the License. +*/ + +// Package install installs the experimental API group, making it available as +// an option to all of the API encoding/decoding machinery. +package install + +import ( + "k8s.io/apimachinery/pkg/runtime" + utilruntime "k8s.io/apimachinery/pkg/util/runtime" + "k8s.io/kubernetes/pkg/api/legacyscheme" + "k8s.io/kubernetes/pkg/apis/flowcontrol" + flowcontrolv1alpha1 "k8s.io/kubernetes/pkg/apis/flowcontrol/v1alpha1" +) + +func init() { + Install(legacyscheme.Scheme) +} + +// Install registers the API group and adds types to a scheme +func Install(scheme *runtime.Scheme) { + utilruntime.Must(flowcontrol.AddToScheme(scheme)) + utilruntime.Must(flowcontrolv1alpha1.AddToScheme(scheme)) + utilruntime.Must(scheme.SetVersionPriority(flowcontrolv1alpha1.SchemeGroupVersion)) +} diff --git a/pkg/apis/flowcontrol/register.go b/pkg/apis/flowcontrol/register.go new file mode 100644 index 0000000000000..7419c39a7a5d3 --- /dev/null +++ b/pkg/apis/flowcontrol/register.go @@ -0,0 +1,56 @@ +/* +Copyright 2016 The Kubernetes Authors. + +Licensed under the Apache License, Version 2.0 (the "License"); +you may not use this file except in compliance with the License. +You may obtain a copy of the License at + + http://www.apache.org/licenses/LICENSE-2.0 + +Unless required by applicable law or agreed to in writing, software +distributed under the License is distributed on an "AS IS" BASIS, +WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +See the License for the specific language governing permissions and +limitations under the License. +*/ + +package flowcontrol + +import ( + "k8s.io/apimachinery/pkg/runtime" + "k8s.io/apimachinery/pkg/runtime/schema" +) + +// GroupName is the name of api group +const GroupName = "flowcontrol.apiserver.k8s.io" + +// SchemeGroupVersion is group version used to register these objects +var SchemeGroupVersion = schema.GroupVersion{Group: GroupName, Version: runtime.APIVersionInternal} + +// Kind takes an unqualified kind and returns a Group qualified GroupKind +func Kind(kind string) schema.GroupKind { + return SchemeGroupVersion.WithKind(kind).GroupKind() +} + +// Resource takes an unqualified resource and returns a Group qualified GroupResource +func Resource(resource string) schema.GroupResource { + return SchemeGroupVersion.WithResource(resource).GroupResource() +} + +var ( + // SchemeBuilder installs the api group to a scheme + SchemeBuilder = runtime.NewSchemeBuilder(addKnownTypes) + // AddToScheme adds api to a scheme + AddToScheme = SchemeBuilder.AddToScheme +) + +// Adds the list of known types to the given scheme. +func addKnownTypes(scheme *runtime.Scheme) error { + scheme.AddKnownTypes(SchemeGroupVersion, + &FlowSchema{}, + &FlowSchemaList{}, + &PriorityLevelConfiguration{}, + &PriorityLevelConfigurationList{}, + ) + return nil +} diff --git a/pkg/apis/flowcontrol/util/BUILD b/pkg/apis/flowcontrol/util/BUILD new file mode 100644 index 0000000000000..fcf7c6e89e22d --- /dev/null +++ b/pkg/apis/flowcontrol/util/BUILD @@ -0,0 +1,23 @@ +load("@io_bazel_rules_go//go:def.bzl", "go_library") + +go_library( + name = "go_default_library", + srcs = ["helpers.go"], + importpath = "k8s.io/kubernetes/pkg/apis/flowcontrol/util", + visibility = ["//visibility:public"], + deps = ["//pkg/apis/flowcontrol:go_default_library"], +) + +filegroup( + name = "package-srcs", + srcs = glob(["**"]), + tags = ["automanaged"], + visibility = ["//visibility:private"], +) + +filegroup( + name = "all-srcs", + srcs = [":package-srcs"], + tags = ["automanaged"], + visibility = ["//visibility:public"], +) diff --git a/pkg/apis/flowcontrol/util/helpers.go b/pkg/apis/flowcontrol/util/helpers.go new file mode 100644 index 0000000000000..2122cdd97802b --- /dev/null +++ b/pkg/apis/flowcontrol/util/helpers.go @@ -0,0 +1,46 @@ +/* +Copyright 2016 The Kubernetes Authors. + +Licensed under the Apache License, Version 2.0 (the "License"); +you may not use this file except in compliance with the License. +You may obtain a copy of the License at + + http://www.apache.org/licenses/LICENSE-2.0 + +Unless required by applicable law or agreed to in writing, software +distributed under the License is distributed on an "AS IS" BASIS, +WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +See the License for the specific language governing permissions and +limitations under the License. +*/ + +package util + +import ( + "sort" + + "k8s.io/kubernetes/pkg/apis/flowcontrol" +) + +var _ sort.Interface = FlowSchemaSequence{} + +// FlowSchemaSequence holds sorted set of pointers to FlowSchema objects. +// FlowSchemaSequence implements `sort.Interface` +type FlowSchemaSequence []*flowcontrol.FlowSchema + +func (s FlowSchemaSequence) Len() int { + return len(s) +} + +func (s FlowSchemaSequence) Less(i, j int) bool { + // the flow-schema w/ lower matching-precedence is prior + if ip, jp := s[i].Spec.MatchingPrecedence, s[j].Spec.MatchingPrecedence; ip != jp { + return ip < jp + } + // sort alphabetically + return s[i].Name < s[j].Name +} + +func (s FlowSchemaSequence) Swap(i, j int) { + s[i], s[j] = s[j], s[i] +} diff --git a/pkg/apis/flowcontrol/v1alpha1/defaults.go b/pkg/apis/flowcontrol/v1alpha1/defaults.go new file mode 100644 index 0000000000000..a86695929c215 --- /dev/null +++ b/pkg/apis/flowcontrol/v1alpha1/defaults.go @@ -0,0 +1,58 @@ +/* +Copyright 2019 The Kubernetes Authors. + +Licensed under the Apache License, Version 2.0 (the "License"); +you may not use this file except in compliance with the License. +You may obtain a copy of the License at + + http://www.apache.org/licenses/LICENSE-2.0 + +Unless required by applicable law or agreed to in writing, software +distributed under the License is distributed on an "AS IS" BASIS, +WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +See the License for the specific language governing permissions and +limitations under the License. +*/ + +package v1alpha1 + +import ( + "k8s.io/api/flowcontrol/v1alpha1" +) + +// Default settings for flow-schema +const ( + FlowSchemaDefaultMatchingPrecedence int32 = 1000 +) + +// Default settings for priority-level-configuration +const ( + PriorityLevelConfigurationDefaultHandSize int32 = 8 + PriorityLevelConfigurationDefaultQueues int32 = 64 + PriorityLevelConfigurationDefaultQueueLengthLimit int32 = 50 + PriorityLevelConfigurationDefaultAssuredConcurrencyShares int32 = 30 +) + +// SetDefaults_FlowSchema sets default values for flow schema +func SetDefaults_FlowSchemaSpec(spec *v1alpha1.FlowSchemaSpec) { + if spec.MatchingPrecedence == 0 { + spec.MatchingPrecedence = FlowSchemaDefaultMatchingPrecedence + } +} + +// SetDefaults_FlowSchema sets default values for flow schema +func SetDefaults_QueuingConfiguration(cfg *v1alpha1.QueuingConfiguration) { + if cfg.HandSize == 0 { + cfg.HandSize = PriorityLevelConfigurationDefaultHandSize + } + if cfg.Queues == 0 { + cfg.Queues = PriorityLevelConfigurationDefaultQueues + } + if cfg.QueueLengthLimit == 0 { + cfg.QueueLengthLimit = PriorityLevelConfigurationDefaultQueueLengthLimit + } + if cfg.AssuredConcurrencyShares == 0 { + cfg.AssuredConcurrencyShares = PriorityLevelConfigurationDefaultAssuredConcurrencyShares + } + +} diff --git a/pkg/apis/flowcontrol/v1alpha1/doc.go b/pkg/apis/flowcontrol/v1alpha1/doc.go new file mode 100644 index 0000000000000..6fe8760ff4e9e --- /dev/null +++ b/pkg/apis/flowcontrol/v1alpha1/doc.go @@ -0,0 +1,24 @@ +/* +Copyright 2019 The Kubernetes Authors. + +Licensed under the Apache License, Version 2.0 (the "License"); +you may not use this file except in compliance with the License. +You may obtain a copy of the License at + + http://www.apache.org/licenses/LICENSE-2.0 + +Unless required by applicable law or agreed to in writing, software +distributed under the License is distributed on an "AS IS" BASIS, +WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +See the License for the specific language governing permissions and +limitations under the License. +*/ + +// +k8s:conversion-gen=k8s.io/kubernetes/pkg/apis/flowcontrol +// +k8s:conversion-gen-external-types=k8s.io/api/flowcontrol/v1alpha1 +// +k8s:defaulter-gen=TypeMeta +// +k8s:defaulter-gen-input=../../../../vendor/k8s.io/api/flowcontrol/v1alpha1 + +// +groupName=flowcontrol.apiserver.k8s.io + +package v1alpha1 // import "k8s.io/kubernetes/pkg/apis/flowcontrol/v1alpha1" diff --git a/pkg/apis/flowcontrol/v1alpha1/register.go b/pkg/apis/flowcontrol/v1alpha1/register.go new file mode 100644 index 0000000000000..6708038b40297 --- /dev/null +++ b/pkg/apis/flowcontrol/v1alpha1/register.go @@ -0,0 +1,46 @@ +/* +Copyright 2015 The Kubernetes Authors. + +Licensed under the Apache License, Version 2.0 (the "License"); +you may not use this file except in compliance with the License. +You may obtain a copy of the License at + + http://www.apache.org/licenses/LICENSE-2.0 + +Unless required by applicable law or agreed to in writing, software +distributed under the License is distributed on an "AS IS" BASIS, +WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +See the License for the specific language governing permissions and +limitations under the License. +*/ + +package v1alpha1 + +import ( + flowcontrolv1alpha1 "k8s.io/api/flowcontrol/v1alpha1" + "k8s.io/apimachinery/pkg/runtime/schema" +) + +// GroupName is the group name use in this package +const GroupName = "flowcontrol.apiserver.k8s.io" + +// SchemeGroupVersion is group version used to register these objects +var SchemeGroupVersion = schema.GroupVersion{Group: GroupName, Version: "v1alpha1"} + +// Resource takes an unqualified resource and returns a Group qualified GroupResource +func Resource(resource string) schema.GroupResource { + return SchemeGroupVersion.WithResource(resource).GroupResource() +} + +var ( + localSchemeBuilder = &flowcontrolv1alpha1.SchemeBuilder + // AddToScheme adds api to a scheme + AddToScheme = localSchemeBuilder.AddToScheme +) + +func init() { + // We only register manually written functions here. The registration of the + // generated functions takes place in the generated files. The separation + // makes the code compile even when the generated files are missing. + localSchemeBuilder.Register(RegisterDefaults) +} diff --git a/pkg/master/import_known_versions.go b/pkg/master/import_known_versions.go index d97aca13d79ad..b7b01e4bdc6f5 100644 --- a/pkg/master/import_known_versions.go +++ b/pkg/master/import_known_versions.go @@ -32,6 +32,7 @@ import ( _ "k8s.io/kubernetes/pkg/apis/discovery/install" _ "k8s.io/kubernetes/pkg/apis/events/install" _ "k8s.io/kubernetes/pkg/apis/extensions/install" + _ "k8s.io/kubernetes/pkg/apis/flowcontrol/install" _ "k8s.io/kubernetes/pkg/apis/imagepolicy/install" _ "k8s.io/kubernetes/pkg/apis/networking/install" _ "k8s.io/kubernetes/pkg/apis/node/install" diff --git a/staging/src/k8s.io/api/flowcontrol/v1alpha1/doc.go b/staging/src/k8s.io/api/flowcontrol/v1alpha1/doc.go new file mode 100644 index 0000000000000..31b8b5d535323 --- /dev/null +++ b/staging/src/k8s.io/api/flowcontrol/v1alpha1/doc.go @@ -0,0 +1,24 @@ +/* +Copyright 2019 The Kubernetes Authors. + +Licensed under the Apache License, Version 2.0 (the "License"); +you may not use this file except in compliance with the License. +You may obtain a copy of the License at + + http://www.apache.org/licenses/LICENSE-2.0 + +Unless required by applicable law or agreed to in writing, software +distributed under the License is distributed on an "AS IS" BASIS, +WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +See the License for the specific language governing permissions and +limitations under the License. +*/ + +// +k8s:deepcopy-gen=package +// +k8s:protobuf-gen=package +// +k8s:openapi-gen=true + +// +groupName=flowcontrol.apiserver.k8s.io + +// Package v1alpha1 holds api types of version v1alpha1 for group "flowcontrol.apiserver.k8s.io". +package v1alpha1 // import "k8s.io/api/flowcontrol/v1alpha1" diff --git a/staging/src/k8s.io/api/flowcontrol/v1alpha1/register.go b/staging/src/k8s.io/api/flowcontrol/v1alpha1/register.go new file mode 100644 index 0000000000000..0c8a9cc5657b1 --- /dev/null +++ b/staging/src/k8s.io/api/flowcontrol/v1alpha1/register.go @@ -0,0 +1,58 @@ +/* +Copyright 2019 The Kubernetes Authors. + +Licensed under the Apache License, Version 2.0 (the "License"); +you may not use this file except in compliance with the License. +You may obtain a copy of the License at + + http://www.apache.org/licenses/LICENSE-2.0 + +Unless required by applicable law or agreed to in writing, software +distributed under the License is distributed on an "AS IS" BASIS, +WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +See the License for the specific language governing permissions and +limitations under the License. +*/ + +package v1alpha1 + +import ( + metav1 "k8s.io/apimachinery/pkg/apis/meta/v1" + "k8s.io/apimachinery/pkg/runtime" + "k8s.io/apimachinery/pkg/runtime/schema" +) + +// GroupName is the name of api group +const GroupName = "flowcontrol.apiserver.k8s.io" + +// SchemeGroupVersion is group version used to register these objects +var SchemeGroupVersion = schema.GroupVersion{Group: GroupName, Version: "v1alpha1"} + +// Kind takes an unqualified kind and returns a Group qualified GroupKind +func Kind(kind string) schema.GroupKind { + return SchemeGroupVersion.WithKind(kind).GroupKind() +} + +// Resource takes an unqualified resource and returns a Group qualified GroupResource +func Resource(resource string) schema.GroupResource { + return SchemeGroupVersion.WithResource(resource).GroupResource() +} + +var ( + // SchemeBuilder installs the api group to a scheme + SchemeBuilder = runtime.NewSchemeBuilder(addKnownTypes) + // AddToScheme adds api to a scheme + AddToScheme = SchemeBuilder.AddToScheme +) + +// Adds the list of known types to the given scheme. +func addKnownTypes(scheme *runtime.Scheme) error { + scheme.AddKnownTypes(SchemeGroupVersion, + &FlowSchema{}, + &FlowSchemaList{}, + &PriorityLevelConfiguration{}, + &PriorityLevelConfigurationList{}, + ) + metav1.AddToGroupVersion(scheme, SchemeGroupVersion) + return nil +} diff --git a/staging/src/k8s.io/apiserver/pkg/util/apihelpers/BUILD b/staging/src/k8s.io/apiserver/pkg/util/apihelpers/BUILD new file mode 100644 index 0000000000000..47d9b11568912 --- /dev/null +++ b/staging/src/k8s.io/apiserver/pkg/util/apihelpers/BUILD @@ -0,0 +1,24 @@ +load("@io_bazel_rules_go//go:def.bzl", "go_library") + +go_library( + name = "go_default_library", + srcs = ["helpers.go"], + importmap = "k8s.io/kubernetes/vendor/k8s.io/apiserver/pkg/util/apihelpers", + importpath = "k8s.io/apiserver/pkg/util/apihelpers", + visibility = ["//visibility:public"], + deps = ["//staging/src/k8s.io/api/flowcontrol/v1alpha1:go_default_library"], +) + +filegroup( + name = "package-srcs", + srcs = glob(["**"]), + tags = ["automanaged"], + visibility = ["//visibility:private"], +) + +filegroup( + name = "all-srcs", + srcs = [":package-srcs"], + tags = ["automanaged"], + visibility = ["//visibility:public"], +) diff --git a/staging/src/k8s.io/apiserver/pkg/util/apihelpers/helpers.go b/staging/src/k8s.io/apiserver/pkg/util/apihelpers/helpers.go new file mode 100644 index 0000000000000..be44b445c0cbf --- /dev/null +++ b/staging/src/k8s.io/apiserver/pkg/util/apihelpers/helpers.go @@ -0,0 +1,100 @@ +/* +Copyright 2019 The Kubernetes Authors. + +Licensed under the Apache License, Version 2.0 (the "License"); +you may not use this file except in compliance with the License. +You may obtain a copy of the License at + + http://www.apache.org/licenses/LICENSE-2.0 + +Unless required by applicable law or agreed to in writing, software +distributed under the License is distributed on an "AS IS" BASIS, +WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +See the License for the specific language governing permissions and +limitations under the License. +*/ + +package apihelpers + +import ( + "sort" + + flowcontrol "k8s.io/api/flowcontrol/v1alpha1" +) + +// SetFlowSchemaCondition sets conditions. +func SetFlowSchemaCondition(flowSchema *flowcontrol.FlowSchema, newCondition flowcontrol.FlowSchemaCondition) { + existingCondition := GetFlowSchemaConditionByType(flowSchema, newCondition.Type) + if existingCondition == nil { + flowSchema.Status.Conditions = append(flowSchema.Status.Conditions, newCondition) + return + } + + if existingCondition.Status != newCondition.Status { + existingCondition.Status = newCondition.Status + existingCondition.LastTransitionTime = newCondition.LastTransitionTime + } + + existingCondition.Reason = newCondition.Reason + existingCondition.Message = newCondition.Message +} + +// GetFlowSchemaConditionByType gets conditions. +func GetFlowSchemaConditionByType(flowSchema *flowcontrol.FlowSchema, conditionType flowcontrol.FlowSchemaConditionType) *flowcontrol.FlowSchemaCondition { + for i := range flowSchema.Status.Conditions { + if flowSchema.Status.Conditions[i].Type == conditionType { + return &flowSchema.Status.Conditions[i] + } + } + return nil +} + +// SetPriorityLevelConfigurationCondition sets conditions. +func SetPriorityLevelConfigurationCondition(priorityLevel *flowcontrol.PriorityLevelConfiguration, newCondition flowcontrol.PriorityLevelConfigurationCondition) { + existingCondition := GetPriorityLevelConfigurationConditionByType(priorityLevel, newCondition.Type) + if existingCondition == nil { + priorityLevel.Status.Conditions = append(priorityLevel.Status.Conditions, newCondition) + return + } + + if existingCondition.Status != newCondition.Status { + existingCondition.Status = newCondition.Status + existingCondition.LastTransitionTime = newCondition.LastTransitionTime + } + + existingCondition.Reason = newCondition.Reason + existingCondition.Message = newCondition.Message +} + +// GetPriorityLevelConfigurationConditionByType gets conditions. +func GetPriorityLevelConfigurationConditionByType(priorityLevel *flowcontrol.PriorityLevelConfiguration, conditionType flowcontrol.PriorityLevelConfigurationConditionType) *flowcontrol.PriorityLevelConfigurationCondition { + for i := range priorityLevel.Status.Conditions { + if priorityLevel.Status.Conditions[i].Type == conditionType { + return &priorityLevel.Status.Conditions[i] + } + } + return nil +} + +var _ sort.Interface = FlowSchemaSequence{} + +// FlowSchemaSequence holds sorted set of pointers to FlowSchema objects. +// FlowSchemaSequence implements `sort.Interface` +type FlowSchemaSequence []*flowcontrol.FlowSchema + +func (s FlowSchemaSequence) Len() int { + return len(s) +} + +func (s FlowSchemaSequence) Less(i, j int) bool { + // the flow-schema w/ lower matching-precedence is prior + if ip, jp := s[i].Spec.MatchingPrecedence, s[j].Spec.MatchingPrecedence; ip != jp { + return ip < jp + } + // sort alphabetically + return s[i].Name < s[j].Name +} + +func (s FlowSchemaSequence) Swap(i, j int) { + s[i], s[j] = s[j], s[i] +} diff --git a/test/integration/apiserver/print_test.go b/test/integration/apiserver/print_test.go index 2936688cf318a..343d4ab9b896b 100644 --- a/test/integration/apiserver/print_test.go +++ b/test/integration/apiserver/print_test.go @@ -32,6 +32,7 @@ import ( batchv2alpha1 "k8s.io/api/batch/v2alpha1" discoveryv1alpha1 "k8s.io/api/discovery/v1alpha1" extensionsv1beta1 "k8s.io/api/extensions/v1beta1" + flowcontrolv1alpha1 "k8s.io/api/flowcontrol/v1alpha1" nodev1alpha1 "k8s.io/api/node/v1alpha1" rbacv1alpha1 "k8s.io/api/rbac/v1alpha1" schedulerapi "k8s.io/api/scheduling/v1" @@ -138,6 +139,8 @@ var missingHanlders = sets.NewString( "AuditSink", "CSINode", "CSIDriver", + "FlowSchema", // TODO(yue9944882): remove this comment by merging print-handler for flow-control API + "PriorityLevelConfiguration", // TODO(yue9944882): remove this comment by merging print-handler for flow-control API ) func TestServerSidePrint(t *testing.T) { @@ -155,6 +158,7 @@ func TestServerSidePrint(t *testing.T) { appsv1beta2.SchemeGroupVersion, extensionsv1beta1.SchemeGroupVersion, nodev1alpha1.SchemeGroupVersion, + flowcontrolv1alpha1.SchemeGroupVersion, }, []schema.GroupVersionResource{ extensionsv1beta1.SchemeGroupVersion.WithResource("daemonsets"),