From e39d18f0c06e1d483b0a075146c561bee1f7c16c Mon Sep 17 00:00:00 2001 From: Yassine TIJANI Date: Tue, 26 Mar 2019 21:41:12 +0100 Subject: [PATCH 1/9] introduce topology into the runtimeClass API --- api/openapi-spec/swagger.json | 42 +++++++++++++++++++ pkg/apis/node/BUILD | 1 + pkg/apis/node/types.go | 20 +++++++++ pkg/apis/node/v1alpha1/BUILD | 2 + pkg/apis/node/v1alpha1/conversion.go | 3 ++ .../node/v1alpha1/zz_generated.conversion.go | 37 ++++++++++++++++ pkg/apis/node/v1beta1/BUILD | 3 ++ pkg/apis/node/v1beta1/conversion.go | 25 +++++++++++ pkg/apis/node/v1beta1/register.go | 7 ++++ .../node/v1beta1/zz_generated.conversion.go | 36 ++++++++++++++++ pkg/apis/node/zz_generated.deepcopy.go | 34 +++++++++++++++ staging/src/k8s.io/api/node/v1alpha1/BUILD | 1 + staging/src/k8s.io/api/node/v1alpha1/types.go | 20 +++++++++ .../v1alpha1/types_swagger_doc_generated.go | 11 +++++ .../node/v1alpha1/zz_generated.deepcopy.go | 36 +++++++++++++++- staging/src/k8s.io/api/node/v1beta1/BUILD | 1 + staging/src/k8s.io/api/node/v1beta1/types.go | 22 ++++++++++ .../v1beta1/types_swagger_doc_generated.go | 11 +++++ .../api/node/v1beta1/zz_generated.deepcopy.go | 34 +++++++++++++++ 19 files changed, 345 insertions(+), 1 deletion(-) create mode 100644 pkg/apis/node/v1beta1/conversion.go diff --git a/api/openapi-spec/swagger.json b/api/openapi-spec/swagger.json index ec0639d0f8..ccaae47b8d 100644 --- a/api/openapi-spec/swagger.json +++ b/api/openapi-spec/swagger.json @@ -13280,6 +13280,10 @@ "runtimeHandler": { "description": "RuntimeHandler specifies the underlying runtime and configuration that the CRI implementation will use to handle pods of this class. The possible values are specific to the node & CRI configuration. It is assumed that all handlers are available on every node, and handlers of the same name are equivalent on every node. For example, a handler called \"runc\" might specify that the runc OCI runtime (using native Linux containers) will be used to run the containers in a pod. The RuntimeHandler must conform to the DNS Label (RFC 1123) requirements and is immutable.", "type": "string" + }, + "topology": { + "$ref": "#/definitions/io.k8s.api.node.v1alpha1.Topology", + "description": "Topology specifies the scheduling constrains that are necessary to assign pods to the right node" } }, "required": [ @@ -13287,6 +13291,23 @@ ], "type": "object" }, + "io.k8s.api.node.v1alpha1.Topology": { + "description": "Topology specifies the structure of scheduling constrains for the runtime class", + "properties": { + "nodeSelector": { + "$ref": "#/definitions/io.k8s.api.core.v1.NodeSelector", + "description": "nodeSelector selects the set of nodes that support this RuntimeClass. Pods using this RuntimeClass can only be scheduled to a node matched by this selector. The nodeSelector is intersected (AND) with a pod's other node affinity or node selector requirements." + }, + "tolerations": { + "description": "tolerations adds tolerations to pods running with this RuntimeClass.", + "items": { + "$ref": "#/definitions/io.k8s.api.core.v1.Toleration" + }, + "type": "array" + } + }, + "type": "object" + }, "io.k8s.api.node.v1beta1.RuntimeClass": { "description": "RuntimeClass defines a class of container runtime supported in the cluster. The RuntimeClass is used to determine which container runtime is used to run all containers in a pod. RuntimeClasses are (currently) manually defined by a user or cluster provisioner, and referenced in the PodSpec. The Kubelet is responsible for resolving the RuntimeClassName reference before running the pod. For more details, see https://git.k8s.io/enhancements/keps/sig-node/runtime-class.md", "properties": { @@ -13305,6 +13326,10 @@ "metadata": { "$ref": "#/definitions/io.k8s.apimachinery.pkg.apis.meta.v1.ObjectMeta", "description": "More info: https://git.k8s.io/community/contributors/devel/api-conventions.md#metadata" + }, + "topology": { + "$ref": "#/definitions/io.k8s.api.node.v1beta1.Topology", + "description": "Topology describes the set of nodes in the cluster that support this RuntimeClass. The rules are applied to the pod during scheduling time. If topology is nil, this RuntimeClass is assumed to be supported by all nodes. pods to the right node" } }, "required": [ @@ -13354,6 +13379,23 @@ } ] }, + "io.k8s.api.node.v1beta1.Topology": { + "description": "Topology specifies the scheduling constraints for nodes supporting a RuntimeClass.", + "properties": { + "nodeSelector": { + "$ref": "#/definitions/io.k8s.api.core.v1.NodeSelector", + "description": "nodeSelector selects the set of nodes that support this RuntimeClass. Pods using this RuntimeClass can only be scheduled to a node matched by this selector. The nodeSelector is intersected (AND) with a pod's other node affinity or node selector requirements. A nil nodeSelector selects all nodes." + }, + "tolerations": { + "description": "tolerations adds tolerations to pods running with this RuntimeClass. the tolerations are appended (excluding duplicates) to the pod's tolerations during admission.", + "items": { + "$ref": "#/definitions/io.k8s.api.core.v1.Toleration" + }, + "type": "array" + } + }, + "type": "object" + }, "io.k8s.api.policy.v1beta1.AllowedCSIDriver": { "description": "AllowedCSIDriver represents a single inline CSI Driver that is allowed to be used.", "properties": { diff --git a/pkg/apis/node/BUILD b/pkg/apis/node/BUILD index c5f4063c12..ea6be581f4 100644 --- a/pkg/apis/node/BUILD +++ b/pkg/apis/node/BUILD @@ -11,6 +11,7 @@ go_library( importpath = "k8s.io/kubernetes/pkg/apis/node", visibility = ["//visibility:public"], deps = [ + "//pkg/apis/core:go_default_library", "//staging/src/k8s.io/apimachinery/pkg/apis/meta/v1:go_default_library", "//staging/src/k8s.io/apimachinery/pkg/runtime:go_default_library", "//staging/src/k8s.io/apimachinery/pkg/runtime/schema:go_default_library", diff --git a/pkg/apis/node/types.go b/pkg/apis/node/types.go index a10648f384..5db5600f9b 100644 --- a/pkg/apis/node/types.go +++ b/pkg/apis/node/types.go @@ -17,6 +17,7 @@ limitations under the License. package node import ( + v1 "k8s.io/kubernetes/pkg/apis/core" metav1 "k8s.io/apimachinery/pkg/apis/meta/v1" ) @@ -45,6 +46,25 @@ type RuntimeClass struct { // The Handler must conform to the DNS Label (RFC 1123) requirements, and is // immutable. Handler string + + // Topology specifies the scheduling constrains that are necessary to assign + // pods to the right node + // +optional + Topology *Topology +} + +// Topology specifies the structure of scheduling constrains for the runtime class +type Topology struct { + // nodeSelector selects the set of nodes that support this RuntimeClass. + // Pods using this RuntimeClass can only be scheduled to a node matched by + // this selector. The nodeSelector is intersected (AND) with a pod's other + // node affinity or node selector requirements. + // +optional + NodeSelector *v1.NodeSelector + + // tolerations adds tolerations to pods running with this RuntimeClass. + // +optional + Tolerations []v1.Toleration } // +k8s:deepcopy-gen:interfaces=k8s.io/apimachinery/pkg/runtime.Object diff --git a/pkg/apis/node/v1alpha1/BUILD b/pkg/apis/node/v1alpha1/BUILD index 3e817dcbc8..061c744953 100644 --- a/pkg/apis/node/v1alpha1/BUILD +++ b/pkg/apis/node/v1alpha1/BUILD @@ -11,7 +11,9 @@ go_library( importpath = "k8s.io/kubernetes/pkg/apis/node/v1alpha1", visibility = ["//visibility:public"], deps = [ + "//pkg/apis/core:go_default_library", "//pkg/apis/node:go_default_library", + "//staging/src/k8s.io/api/core/v1:go_default_library", "//staging/src/k8s.io/api/node/v1alpha1:go_default_library", "//staging/src/k8s.io/apimachinery/pkg/conversion:go_default_library", "//staging/src/k8s.io/apimachinery/pkg/runtime:go_default_library", diff --git a/pkg/apis/node/v1alpha1/conversion.go b/pkg/apis/node/v1alpha1/conversion.go index f1e96ea31a..d9da7f6cde 100644 --- a/pkg/apis/node/v1alpha1/conversion.go +++ b/pkg/apis/node/v1alpha1/conversion.go @@ -21,6 +21,7 @@ import ( conversion "k8s.io/apimachinery/pkg/conversion" runtime "k8s.io/apimachinery/pkg/runtime" node "k8s.io/kubernetes/pkg/apis/node" + "unsafe" ) func addConversionFuncs(s *runtime.Scheme) error { @@ -33,11 +34,13 @@ func addConversionFuncs(s *runtime.Scheme) error { func Convert_v1alpha1_RuntimeClass_To_node_RuntimeClass(in *v1alpha1.RuntimeClass, out *node.RuntimeClass, s conversion.Scope) error { out.ObjectMeta = in.ObjectMeta out.Handler = in.Spec.RuntimeHandler + out.Topology = (*node.Topology)(unsafe.Pointer(in.Spec.Topology)) return nil } func Convert_node_RuntimeClass_To_v1alpha1_RuntimeClass(in *node.RuntimeClass, out *v1alpha1.RuntimeClass, s conversion.Scope) error { out.ObjectMeta = in.ObjectMeta out.Spec.RuntimeHandler = in.Handler + out.Spec.Topology = (*v1alpha1.Topology)(unsafe.Pointer(in.Topology)) return nil } diff --git a/pkg/apis/node/v1alpha1/zz_generated.conversion.go b/pkg/apis/node/v1alpha1/zz_generated.conversion.go index dcb097f842..c7c602f990 100644 --- a/pkg/apis/node/v1alpha1/zz_generated.conversion.go +++ b/pkg/apis/node/v1alpha1/zz_generated.conversion.go @@ -21,9 +21,13 @@ limitations under the License. package v1alpha1 import ( + unsafe "unsafe" + + v1 "k8s.io/api/core/v1" v1alpha1 "k8s.io/api/node/v1alpha1" conversion "k8s.io/apimachinery/pkg/conversion" runtime "k8s.io/apimachinery/pkg/runtime" + core "k8s.io/kubernetes/pkg/apis/core" node "k8s.io/kubernetes/pkg/apis/node" ) @@ -54,6 +58,16 @@ func RegisterConversions(s *runtime.Scheme) error { }); err != nil { return err } + if err := s.AddGeneratedConversionFunc((*v1alpha1.Topology)(nil), (*node.Topology)(nil), func(a, b interface{}, scope conversion.Scope) error { + return Convert_v1alpha1_Topology_To_node_Topology(a.(*v1alpha1.Topology), b.(*node.Topology), scope) + }); err != nil { + return err + } + if err := s.AddGeneratedConversionFunc((*node.Topology)(nil), (*v1alpha1.Topology)(nil), func(a, b interface{}, scope conversion.Scope) error { + return Convert_node_Topology_To_v1alpha1_Topology(a.(*node.Topology), b.(*v1alpha1.Topology), scope) + }); err != nil { + return err + } if err := s.AddConversionFunc((*node.RuntimeClass)(nil), (*v1alpha1.RuntimeClass)(nil), func(a, b interface{}, scope conversion.Scope) error { return Convert_node_RuntimeClass_To_v1alpha1_RuntimeClass(a.(*node.RuntimeClass), b.(*v1alpha1.RuntimeClass), scope) }); err != nil { @@ -76,6 +90,7 @@ func autoConvert_v1alpha1_RuntimeClass_To_node_RuntimeClass(in *v1alpha1.Runtime func autoConvert_node_RuntimeClass_To_v1alpha1_RuntimeClass(in *node.RuntimeClass, out *v1alpha1.RuntimeClass, s conversion.Scope) error { out.ObjectMeta = in.ObjectMeta // WARNING: in.Handler requires manual conversion: does not exist in peer-type + // WARNING: in.Topology requires manual conversion: does not exist in peer-type return nil } @@ -120,3 +135,25 @@ func autoConvert_node_RuntimeClassList_To_v1alpha1_RuntimeClassList(in *node.Run func Convert_node_RuntimeClassList_To_v1alpha1_RuntimeClassList(in *node.RuntimeClassList, out *v1alpha1.RuntimeClassList, s conversion.Scope) error { return autoConvert_node_RuntimeClassList_To_v1alpha1_RuntimeClassList(in, out, s) } + +func autoConvert_v1alpha1_Topology_To_node_Topology(in *v1alpha1.Topology, out *node.Topology, s conversion.Scope) error { + out.NodeSelector = (*core.NodeSelector)(unsafe.Pointer(in.NodeSelector)) + out.Tolerations = *(*[]core.Toleration)(unsafe.Pointer(&in.Tolerations)) + return nil +} + +// Convert_v1alpha1_Topology_To_node_Topology is an autogenerated conversion function. +func Convert_v1alpha1_Topology_To_node_Topology(in *v1alpha1.Topology, out *node.Topology, s conversion.Scope) error { + return autoConvert_v1alpha1_Topology_To_node_Topology(in, out, s) +} + +func autoConvert_node_Topology_To_v1alpha1_Topology(in *node.Topology, out *v1alpha1.Topology, s conversion.Scope) error { + out.NodeSelector = (*v1.NodeSelector)(unsafe.Pointer(in.NodeSelector)) + out.Tolerations = *(*[]v1.Toleration)(unsafe.Pointer(&in.Tolerations)) + return nil +} + +// Convert_node_Topology_To_v1alpha1_Topology is an autogenerated conversion function. +func Convert_node_Topology_To_v1alpha1_Topology(in *node.Topology, out *v1alpha1.Topology, s conversion.Scope) error { + return autoConvert_node_Topology_To_v1alpha1_Topology(in, out, s) +} diff --git a/pkg/apis/node/v1beta1/BUILD b/pkg/apis/node/v1beta1/BUILD index 692be926ae..53b756e3a7 100644 --- a/pkg/apis/node/v1beta1/BUILD +++ b/pkg/apis/node/v1beta1/BUILD @@ -3,6 +3,7 @@ load("@io_bazel_rules_go//go:def.bzl", "go_library") go_library( name = "go_default_library", srcs = [ + "conversion.go", "doc.go", "register.go", "zz_generated.conversion.go", @@ -10,7 +11,9 @@ go_library( importpath = "k8s.io/kubernetes/pkg/apis/node/v1beta1", visibility = ["//visibility:public"], deps = [ + "//pkg/apis/core:go_default_library", "//pkg/apis/node:go_default_library", + "//staging/src/k8s.io/api/core/v1:go_default_library", "//staging/src/k8s.io/api/node/v1beta1:go_default_library", "//staging/src/k8s.io/apimachinery/pkg/conversion:go_default_library", "//staging/src/k8s.io/apimachinery/pkg/runtime:go_default_library", diff --git a/pkg/apis/node/v1beta1/conversion.go b/pkg/apis/node/v1beta1/conversion.go new file mode 100644 index 0000000000..b7d88363d2 --- /dev/null +++ b/pkg/apis/node/v1beta1/conversion.go @@ -0,0 +1,25 @@ +/* +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 v1beta1 + +import ( + "k8s.io/apimachinery/pkg/runtime" +) + +func addConversionFuncs(s *runtime.Scheme) error { + return s.AddConversionFuncs() +} diff --git a/pkg/apis/node/v1beta1/register.go b/pkg/apis/node/v1beta1/register.go index e018e3b70e..19250848d0 100644 --- a/pkg/apis/node/v1beta1/register.go +++ b/pkg/apis/node/v1beta1/register.go @@ -37,3 +37,10 @@ var ( // AddToScheme node API registration 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(addConversionFuncs) +} diff --git a/pkg/apis/node/v1beta1/zz_generated.conversion.go b/pkg/apis/node/v1beta1/zz_generated.conversion.go index ebe97f937c..8ab2ab3be6 100644 --- a/pkg/apis/node/v1beta1/zz_generated.conversion.go +++ b/pkg/apis/node/v1beta1/zz_generated.conversion.go @@ -23,9 +23,11 @@ package v1beta1 import ( unsafe "unsafe" + v1 "k8s.io/api/core/v1" v1beta1 "k8s.io/api/node/v1beta1" conversion "k8s.io/apimachinery/pkg/conversion" runtime "k8s.io/apimachinery/pkg/runtime" + core "k8s.io/kubernetes/pkg/apis/core" node "k8s.io/kubernetes/pkg/apis/node" ) @@ -56,12 +58,23 @@ func RegisterConversions(s *runtime.Scheme) error { }); err != nil { return err } + if err := s.AddGeneratedConversionFunc((*v1beta1.Topology)(nil), (*node.Topology)(nil), func(a, b interface{}, scope conversion.Scope) error { + return Convert_v1beta1_Topology_To_node_Topology(a.(*v1beta1.Topology), b.(*node.Topology), scope) + }); err != nil { + return err + } + if err := s.AddGeneratedConversionFunc((*node.Topology)(nil), (*v1beta1.Topology)(nil), func(a, b interface{}, scope conversion.Scope) error { + return Convert_node_Topology_To_v1beta1_Topology(a.(*node.Topology), b.(*v1beta1.Topology), scope) + }); err != nil { + return err + } return nil } func autoConvert_v1beta1_RuntimeClass_To_node_RuntimeClass(in *v1beta1.RuntimeClass, out *node.RuntimeClass, s conversion.Scope) error { out.ObjectMeta = in.ObjectMeta out.Handler = in.Handler + out.Topology = (*node.Topology)(unsafe.Pointer(in.Topology)) return nil } @@ -73,6 +86,7 @@ func Convert_v1beta1_RuntimeClass_To_node_RuntimeClass(in *v1beta1.RuntimeClass, func autoConvert_node_RuntimeClass_To_v1beta1_RuntimeClass(in *node.RuntimeClass, out *v1beta1.RuntimeClass, s conversion.Scope) error { out.ObjectMeta = in.ObjectMeta out.Handler = in.Handler + out.Topology = (*v1beta1.Topology)(unsafe.Pointer(in.Topology)) return nil } @@ -102,3 +116,25 @@ func autoConvert_node_RuntimeClassList_To_v1beta1_RuntimeClassList(in *node.Runt func Convert_node_RuntimeClassList_To_v1beta1_RuntimeClassList(in *node.RuntimeClassList, out *v1beta1.RuntimeClassList, s conversion.Scope) error { return autoConvert_node_RuntimeClassList_To_v1beta1_RuntimeClassList(in, out, s) } + +func autoConvert_v1beta1_Topology_To_node_Topology(in *v1beta1.Topology, out *node.Topology, s conversion.Scope) error { + out.NodeSelector = (*core.NodeSelector)(unsafe.Pointer(in.NodeSelector)) + out.Tolerations = *(*[]core.Toleration)(unsafe.Pointer(&in.Tolerations)) + return nil +} + +// Convert_v1beta1_Topology_To_node_Topology is an autogenerated conversion function. +func Convert_v1beta1_Topology_To_node_Topology(in *v1beta1.Topology, out *node.Topology, s conversion.Scope) error { + return autoConvert_v1beta1_Topology_To_node_Topology(in, out, s) +} + +func autoConvert_node_Topology_To_v1beta1_Topology(in *node.Topology, out *v1beta1.Topology, s conversion.Scope) error { + out.NodeSelector = (*v1.NodeSelector)(unsafe.Pointer(in.NodeSelector)) + out.Tolerations = *(*[]v1.Toleration)(unsafe.Pointer(&in.Tolerations)) + return nil +} + +// Convert_node_Topology_To_v1beta1_Topology is an autogenerated conversion function. +func Convert_node_Topology_To_v1beta1_Topology(in *node.Topology, out *v1beta1.Topology, s conversion.Scope) error { + return autoConvert_node_Topology_To_v1beta1_Topology(in, out, s) +} diff --git a/pkg/apis/node/zz_generated.deepcopy.go b/pkg/apis/node/zz_generated.deepcopy.go index eb27effc89..11349c9d1d 100644 --- a/pkg/apis/node/zz_generated.deepcopy.go +++ b/pkg/apis/node/zz_generated.deepcopy.go @@ -22,6 +22,7 @@ package node import ( runtime "k8s.io/apimachinery/pkg/runtime" + core "k8s.io/kubernetes/pkg/apis/core" ) // DeepCopyInto is an autogenerated deepcopy function, copying the receiver, writing into out. in must be non-nil. @@ -29,6 +30,11 @@ func (in *RuntimeClass) DeepCopyInto(out *RuntimeClass) { *out = *in out.TypeMeta = in.TypeMeta in.ObjectMeta.DeepCopyInto(&out.ObjectMeta) + if in.Topology != nil { + in, out := &in.Topology, &out.Topology + *out = new(Topology) + (*in).DeepCopyInto(*out) + } return } @@ -82,3 +88,31 @@ func (in *RuntimeClassList) DeepCopyObject() runtime.Object { } return nil } + +// DeepCopyInto is an autogenerated deepcopy function, copying the receiver, writing into out. in must be non-nil. +func (in *Topology) DeepCopyInto(out *Topology) { + *out = *in + if in.NodeSelector != nil { + in, out := &in.NodeSelector, &out.NodeSelector + *out = new(core.NodeSelector) + (*in).DeepCopyInto(*out) + } + if in.Tolerations != nil { + in, out := &in.Tolerations, &out.Tolerations + *out = make([]core.Toleration, len(*in)) + for i := range *in { + (*in)[i].DeepCopyInto(&(*out)[i]) + } + } + return +} + +// DeepCopy is an autogenerated deepcopy function, copying the receiver, creating a new Topology. +func (in *Topology) DeepCopy() *Topology { + if in == nil { + return nil + } + out := new(Topology) + in.DeepCopyInto(out) + return out +} diff --git a/staging/src/k8s.io/api/node/v1alpha1/BUILD b/staging/src/k8s.io/api/node/v1alpha1/BUILD index 4f8f496f61..dc2094afa4 100644 --- a/staging/src/k8s.io/api/node/v1alpha1/BUILD +++ b/staging/src/k8s.io/api/node/v1alpha1/BUILD @@ -14,6 +14,7 @@ go_library( importpath = "k8s.io/api/node/v1alpha1", visibility = ["//visibility:public"], deps = [ + "//staging/src/k8s.io/api/core/v1:go_default_library", "//staging/src/k8s.io/apimachinery/pkg/apis/meta/v1:go_default_library", "//staging/src/k8s.io/apimachinery/pkg/runtime:go_default_library", "//staging/src/k8s.io/apimachinery/pkg/runtime/schema:go_default_library", diff --git a/staging/src/k8s.io/api/node/v1alpha1/types.go b/staging/src/k8s.io/api/node/v1alpha1/types.go index 2ce67c116f..3518c7796b 100644 --- a/staging/src/k8s.io/api/node/v1alpha1/types.go +++ b/staging/src/k8s.io/api/node/v1alpha1/types.go @@ -17,6 +17,7 @@ limitations under the License. package v1alpha1 import ( + "k8s.io/api/core/v1" metav1 "k8s.io/apimachinery/pkg/apis/meta/v1" ) @@ -58,6 +59,25 @@ type RuntimeClassSpec struct { // The RuntimeHandler must conform to the DNS Label (RFC 1123) requirements // and is immutable. RuntimeHandler string `json:"runtimeHandler" protobuf:"bytes,1,opt,name=runtimeHandler"` + + // Topology specifies the scheduling constrains that are necessary to assign + // pods to the right node + // +optional + Topology *Topology `json:"topology,omitempty" protobuf:"bytes,3,opt,name=topology"` +} + +// Topology specifies the structure of scheduling constrains for the runtime class +type Topology struct { + // nodeSelector selects the set of nodes that support this RuntimeClass. + // Pods using this RuntimeClass can only be scheduled to a node matched by + // this selector. The nodeSelector is intersected (AND) with a pod's other + // node affinity or node selector requirements. + // +optional + NodeSelector *v1.NodeSelector `json:"nodeSelector,omitempty" protobuf:"bytes,1,rep,name=nodeSelector"` + + // tolerations adds tolerations to pods running with this RuntimeClass. + // +optional + Tolerations []v1.Toleration `json:"tolerations,omitempty" protobuf:"bytes,2,opt,name=tolerations"` } // +k8s:deepcopy-gen:interfaces=k8s.io/apimachinery/pkg/runtime.Object diff --git a/staging/src/k8s.io/api/node/v1alpha1/types_swagger_doc_generated.go b/staging/src/k8s.io/api/node/v1alpha1/types_swagger_doc_generated.go index a51fa525df..9b7183332b 100644 --- a/staging/src/k8s.io/api/node/v1alpha1/types_swagger_doc_generated.go +++ b/staging/src/k8s.io/api/node/v1alpha1/types_swagger_doc_generated.go @@ -50,10 +50,21 @@ func (RuntimeClassList) SwaggerDoc() map[string]string { var map_RuntimeClassSpec = map[string]string{ "": "RuntimeClassSpec is a specification of a RuntimeClass. It contains parameters that are required to describe the RuntimeClass to the Container Runtime Interface (CRI) implementation, as well as any other components that need to understand how the pod will be run. The RuntimeClassSpec is immutable.", "runtimeHandler": "RuntimeHandler specifies the underlying runtime and configuration that the CRI implementation will use to handle pods of this class. The possible values are specific to the node & CRI configuration. It is assumed that all handlers are available on every node, and handlers of the same name are equivalent on every node. For example, a handler called \"runc\" might specify that the runc OCI runtime (using native Linux containers) will be used to run the containers in a pod. The RuntimeHandler must conform to the DNS Label (RFC 1123) requirements and is immutable.", + "topology": "Topology specifies the scheduling constrains that are necessary to assign pods to the right node", } func (RuntimeClassSpec) SwaggerDoc() map[string]string { return map_RuntimeClassSpec } +var map_Topology = map[string]string{ + "": "Topology specifies the structure of scheduling constrains for the runtime class", + "nodeSelector": "nodeSelector selects the set of nodes that support this RuntimeClass. Pods using this RuntimeClass can only be scheduled to a node matched by this selector. The nodeSelector is intersected (AND) with a pod's other node affinity or node selector requirements.", + "tolerations": "tolerations adds tolerations to pods running with this RuntimeClass.", +} + +func (Topology) SwaggerDoc() map[string]string { + return map_Topology +} + // AUTO-GENERATED FUNCTIONS END HERE diff --git a/staging/src/k8s.io/api/node/v1alpha1/zz_generated.deepcopy.go b/staging/src/k8s.io/api/node/v1alpha1/zz_generated.deepcopy.go index 0d63110b3b..30c50160d3 100644 --- a/staging/src/k8s.io/api/node/v1alpha1/zz_generated.deepcopy.go +++ b/staging/src/k8s.io/api/node/v1alpha1/zz_generated.deepcopy.go @@ -21,6 +21,7 @@ limitations under the License. package v1alpha1 import ( + v1 "k8s.io/api/core/v1" runtime "k8s.io/apimachinery/pkg/runtime" ) @@ -29,7 +30,7 @@ func (in *RuntimeClass) DeepCopyInto(out *RuntimeClass) { *out = *in out.TypeMeta = in.TypeMeta in.ObjectMeta.DeepCopyInto(&out.ObjectMeta) - out.Spec = in.Spec + in.Spec.DeepCopyInto(&out.Spec) return } @@ -87,6 +88,11 @@ func (in *RuntimeClassList) DeepCopyObject() runtime.Object { // DeepCopyInto is an autogenerated deepcopy function, copying the receiver, writing into out. in must be non-nil. func (in *RuntimeClassSpec) DeepCopyInto(out *RuntimeClassSpec) { *out = *in + if in.Topology != nil { + in, out := &in.Topology, &out.Topology + *out = new(Topology) + (*in).DeepCopyInto(*out) + } return } @@ -99,3 +105,31 @@ func (in *RuntimeClassSpec) DeepCopy() *RuntimeClassSpec { in.DeepCopyInto(out) return out } + +// DeepCopyInto is an autogenerated deepcopy function, copying the receiver, writing into out. in must be non-nil. +func (in *Topology) DeepCopyInto(out *Topology) { + *out = *in + if in.NodeSelector != nil { + in, out := &in.NodeSelector, &out.NodeSelector + *out = new(v1.NodeSelector) + (*in).DeepCopyInto(*out) + } + if in.Tolerations != nil { + in, out := &in.Tolerations, &out.Tolerations + *out = make([]v1.Toleration, len(*in)) + for i := range *in { + (*in)[i].DeepCopyInto(&(*out)[i]) + } + } + return +} + +// DeepCopy is an autogenerated deepcopy function, copying the receiver, creating a new Topology. +func (in *Topology) DeepCopy() *Topology { + if in == nil { + return nil + } + out := new(Topology) + in.DeepCopyInto(out) + return out +} diff --git a/staging/src/k8s.io/api/node/v1beta1/BUILD b/staging/src/k8s.io/api/node/v1beta1/BUILD index 5ae9e598da..214090d851 100644 --- a/staging/src/k8s.io/api/node/v1beta1/BUILD +++ b/staging/src/k8s.io/api/node/v1beta1/BUILD @@ -14,6 +14,7 @@ go_library( importpath = "k8s.io/api/node/v1beta1", visibility = ["//visibility:public"], deps = [ + "//staging/src/k8s.io/api/core/v1:go_default_library", "//staging/src/k8s.io/apimachinery/pkg/apis/meta/v1:go_default_library", "//staging/src/k8s.io/apimachinery/pkg/runtime:go_default_library", "//staging/src/k8s.io/apimachinery/pkg/runtime/schema:go_default_library", diff --git a/staging/src/k8s.io/api/node/v1beta1/types.go b/staging/src/k8s.io/api/node/v1beta1/types.go index 993c6e5066..4234df5eb0 100644 --- a/staging/src/k8s.io/api/node/v1beta1/types.go +++ b/staging/src/k8s.io/api/node/v1beta1/types.go @@ -17,6 +17,7 @@ limitations under the License. package v1beta1 import ( + "k8s.io/api/core/v1" metav1 "k8s.io/apimachinery/pkg/apis/meta/v1" ) @@ -48,6 +49,27 @@ type RuntimeClass struct { // The Handler must conform to the DNS Label (RFC 1123) requirements, and is // immutable. Handler string `json:"handler" protobuf:"bytes,2,opt,name=handler"` + + // Topology describes the set of nodes in the cluster that support this RuntimeClass. The rules are applied to the pod during scheduling time. + // If topology is nil, this RuntimeClass is assumed to be supported by all nodes. + // pods to the right node + // +optional + Topology *Topology `json:"topology,omitempty" protobuf:"bytes,3,opt,name=topology"` +} + +// Topology specifies the scheduling constraints for nodes supporting a RuntimeClass. +type Topology struct { + // nodeSelector selects the set of nodes that support this RuntimeClass. + // Pods using this RuntimeClass can only be scheduled to a node matched by + // this selector. The nodeSelector is intersected (AND) with a pod's other + // node affinity or node selector requirements. A nil nodeSelector selects all nodes. + // +optional + NodeSelector *v1.NodeSelector `json:"nodeSelector,omitempty" protobuf:"bytes,1,rep,name=nodeSelector"` + + // tolerations adds tolerations to pods running with this RuntimeClass. + // the tolerations are appended (excluding duplicates) to the pod's tolerations during admission. + // +optional + Tolerations []v1.Toleration `json:"tolerations,omitempty" protobuf:"bytes,2,opt,name=tolerations"` } // +k8s:deepcopy-gen:interfaces=k8s.io/apimachinery/pkg/runtime.Object diff --git a/staging/src/k8s.io/api/node/v1beta1/types_swagger_doc_generated.go b/staging/src/k8s.io/api/node/v1beta1/types_swagger_doc_generated.go index 8bfa304e78..c98957fcc6 100644 --- a/staging/src/k8s.io/api/node/v1beta1/types_swagger_doc_generated.go +++ b/staging/src/k8s.io/api/node/v1beta1/types_swagger_doc_generated.go @@ -31,6 +31,7 @@ var map_RuntimeClass = map[string]string{ "": "RuntimeClass defines a class of container runtime supported in the cluster. The RuntimeClass is used to determine which container runtime is used to run all containers in a pod. RuntimeClasses are (currently) manually defined by a user or cluster provisioner, and referenced in the PodSpec. The Kubelet is responsible for resolving the RuntimeClassName reference before running the pod. For more details, see https://git.k8s.io/enhancements/keps/sig-node/runtime-class.md", "metadata": "More info: https://git.k8s.io/community/contributors/devel/api-conventions.md#metadata", "handler": "Handler specifies the underlying runtime and configuration that the CRI implementation will use to handle pods of this class. The possible values are specific to the node & CRI configuration. It is assumed that all handlers are available on every node, and handlers of the same name are equivalent on every node. For example, a handler called \"runc\" might specify that the runc OCI runtime (using native Linux containers) will be used to run the containers in a pod. The Handler must conform to the DNS Label (RFC 1123) requirements, and is immutable.", + "topology": "Topology describes the set of nodes in the cluster that support this RuntimeClass. The rules are applied to the pod during scheduling time. If topology is nil, this RuntimeClass is assumed to be supported by all nodes. pods to the right node", } func (RuntimeClass) SwaggerDoc() map[string]string { @@ -47,4 +48,14 @@ func (RuntimeClassList) SwaggerDoc() map[string]string { return map_RuntimeClassList } +var map_Topology = map[string]string{ + "": "Topology specifies the scheduling constraints for nodes supporting a RuntimeClass.", + "nodeSelector": "nodeSelector selects the set of nodes that support this RuntimeClass. Pods using this RuntimeClass can only be scheduled to a node matched by this selector. The nodeSelector is intersected (AND) with a pod's other node affinity or node selector requirements. A nil nodeSelector selects all nodes.", + "tolerations": "tolerations adds tolerations to pods running with this RuntimeClass. the tolerations are appended (excluding duplicates) to the pod's tolerations during admission.", +} + +func (Topology) SwaggerDoc() map[string]string { + return map_Topology +} + // AUTO-GENERATED FUNCTIONS END HERE diff --git a/staging/src/k8s.io/api/node/v1beta1/zz_generated.deepcopy.go b/staging/src/k8s.io/api/node/v1beta1/zz_generated.deepcopy.go index 98b5d480af..cccc806e89 100644 --- a/staging/src/k8s.io/api/node/v1beta1/zz_generated.deepcopy.go +++ b/staging/src/k8s.io/api/node/v1beta1/zz_generated.deepcopy.go @@ -21,6 +21,7 @@ limitations under the License. package v1beta1 import ( + v1 "k8s.io/api/core/v1" runtime "k8s.io/apimachinery/pkg/runtime" ) @@ -29,6 +30,11 @@ func (in *RuntimeClass) DeepCopyInto(out *RuntimeClass) { *out = *in out.TypeMeta = in.TypeMeta in.ObjectMeta.DeepCopyInto(&out.ObjectMeta) + if in.Topology != nil { + in, out := &in.Topology, &out.Topology + *out = new(Topology) + (*in).DeepCopyInto(*out) + } return } @@ -82,3 +88,31 @@ func (in *RuntimeClassList) DeepCopyObject() runtime.Object { } return nil } + +// DeepCopyInto is an autogenerated deepcopy function, copying the receiver, writing into out. in must be non-nil. +func (in *Topology) DeepCopyInto(out *Topology) { + *out = *in + if in.NodeSelector != nil { + in, out := &in.NodeSelector, &out.NodeSelector + *out = new(v1.NodeSelector) + (*in).DeepCopyInto(*out) + } + if in.Tolerations != nil { + in, out := &in.Tolerations, &out.Tolerations + *out = make([]v1.Toleration, len(*in)) + for i := range *in { + (*in)[i].DeepCopyInto(&(*out)[i]) + } + } + return +} + +// DeepCopy is an autogenerated deepcopy function, copying the receiver, creating a new Topology. +func (in *Topology) DeepCopy() *Topology { + if in == nil { + return nil + } + out := new(Topology) + in.DeepCopyInto(out) + return out +} From 02288bc34f98618d57660d3eb8b4c53e79a9cac9 Mon Sep 17 00:00:00 2001 From: Yassine TIJANI Date: Sat, 20 Apr 2019 01:50:39 +0200 Subject: [PATCH 2/9] reuse autoconversion --- pkg/apis/node/v1alpha1/conversion.go | 9 ++++++--- 1 file changed, 6 insertions(+), 3 deletions(-) diff --git a/pkg/apis/node/v1alpha1/conversion.go b/pkg/apis/node/v1alpha1/conversion.go index d9da7f6cde..0829eea4d8 100644 --- a/pkg/apis/node/v1alpha1/conversion.go +++ b/pkg/apis/node/v1alpha1/conversion.go @@ -21,7 +21,6 @@ import ( conversion "k8s.io/apimachinery/pkg/conversion" runtime "k8s.io/apimachinery/pkg/runtime" node "k8s.io/kubernetes/pkg/apis/node" - "unsafe" ) func addConversionFuncs(s *runtime.Scheme) error { @@ -34,13 +33,17 @@ func addConversionFuncs(s *runtime.Scheme) error { func Convert_v1alpha1_RuntimeClass_To_node_RuntimeClass(in *v1alpha1.RuntimeClass, out *node.RuntimeClass, s conversion.Scope) error { out.ObjectMeta = in.ObjectMeta out.Handler = in.Spec.RuntimeHandler - out.Topology = (*node.Topology)(unsafe.Pointer(in.Spec.Topology)) + if in.Spec.Topology != nil { + autoConvert_v1alpha1_Topology_To_node_Topology(in.Spec.Topology,out.Topology,s) + } return nil } func Convert_node_RuntimeClass_To_v1alpha1_RuntimeClass(in *node.RuntimeClass, out *v1alpha1.RuntimeClass, s conversion.Scope) error { out.ObjectMeta = in.ObjectMeta out.Spec.RuntimeHandler = in.Handler - out.Spec.Topology = (*v1alpha1.Topology)(unsafe.Pointer(in.Topology)) + if in.Topology != nil { + autoConvert_node_Topology_To_v1alpha1_Topology(in.Topology,out.Spec.Topology,s) + } return nil } From 3285db8649ae4cb9ad0c148a90706504aafa736e Mon Sep 17 00:00:00 2001 From: Yassine TIJANI Date: Sat, 20 Apr 2019 02:19:20 +0200 Subject: [PATCH 3/9] add output topology --- pkg/apis/node/v1alpha1/conversion.go | 2 ++ staging/src/k8s.io/api/node/v1alpha1/types.go | 4 ++-- staging/src/k8s.io/api/node/v1beta1/types.go | 4 ++-- 3 files changed, 6 insertions(+), 4 deletions(-) diff --git a/pkg/apis/node/v1alpha1/conversion.go b/pkg/apis/node/v1alpha1/conversion.go index 0829eea4d8..7a69b02642 100644 --- a/pkg/apis/node/v1alpha1/conversion.go +++ b/pkg/apis/node/v1alpha1/conversion.go @@ -34,6 +34,7 @@ func Convert_v1alpha1_RuntimeClass_To_node_RuntimeClass(in *v1alpha1.RuntimeClas out.ObjectMeta = in.ObjectMeta out.Handler = in.Spec.RuntimeHandler if in.Spec.Topology != nil { + out.Topology = new(node.Topology) autoConvert_v1alpha1_Topology_To_node_Topology(in.Spec.Topology,out.Topology,s) } return nil @@ -43,6 +44,7 @@ func Convert_node_RuntimeClass_To_v1alpha1_RuntimeClass(in *node.RuntimeClass, o out.ObjectMeta = in.ObjectMeta out.Spec.RuntimeHandler = in.Handler if in.Topology != nil { + out.Spec.Topology = new(v1alpha1.Topology) autoConvert_node_Topology_To_v1alpha1_Topology(in.Topology,out.Spec.Topology,s) } return nil diff --git a/staging/src/k8s.io/api/node/v1alpha1/types.go b/staging/src/k8s.io/api/node/v1alpha1/types.go index 3518c7796b..a0c133cfb6 100644 --- a/staging/src/k8s.io/api/node/v1alpha1/types.go +++ b/staging/src/k8s.io/api/node/v1alpha1/types.go @@ -73,11 +73,11 @@ type Topology struct { // this selector. The nodeSelector is intersected (AND) with a pod's other // node affinity or node selector requirements. // +optional - NodeSelector *v1.NodeSelector `json:"nodeSelector,omitempty" protobuf:"bytes,1,rep,name=nodeSelector"` + NodeSelector *v1.NodeSelector `json:"nodeSelector,omitempty" protobuf:"bytes,1,opt,name=nodeSelector"` // tolerations adds tolerations to pods running with this RuntimeClass. // +optional - Tolerations []v1.Toleration `json:"tolerations,omitempty" protobuf:"bytes,2,opt,name=tolerations"` + Tolerations []v1.Toleration `json:"tolerations,omitempty" protobuf:"bytes,2,rep,name=tolerations"` } // +k8s:deepcopy-gen:interfaces=k8s.io/apimachinery/pkg/runtime.Object diff --git a/staging/src/k8s.io/api/node/v1beta1/types.go b/staging/src/k8s.io/api/node/v1beta1/types.go index 4234df5eb0..628507be25 100644 --- a/staging/src/k8s.io/api/node/v1beta1/types.go +++ b/staging/src/k8s.io/api/node/v1beta1/types.go @@ -64,12 +64,12 @@ type Topology struct { // this selector. The nodeSelector is intersected (AND) with a pod's other // node affinity or node selector requirements. A nil nodeSelector selects all nodes. // +optional - NodeSelector *v1.NodeSelector `json:"nodeSelector,omitempty" protobuf:"bytes,1,rep,name=nodeSelector"` + NodeSelector *v1.NodeSelector `json:"nodeSelector,omitempty" protobuf:"bytes,1,opt,name=nodeSelector"` // tolerations adds tolerations to pods running with this RuntimeClass. // the tolerations are appended (excluding duplicates) to the pod's tolerations during admission. // +optional - Tolerations []v1.Toleration `json:"tolerations,omitempty" protobuf:"bytes,2,opt,name=tolerations"` + Tolerations []v1.Toleration `json:"tolerations,omitempty" protobuf:"bytes,2,rep,name=tolerations"` } // +k8s:deepcopy-gen:interfaces=k8s.io/apimachinery/pkg/runtime.Object From d2a87d5afc3cd745b9c5ee989bc7c2ad60baee36 Mon Sep 17 00:00:00 2001 From: Tim Allclair Date: Tue, 23 Apr 2019 17:06:09 -0700 Subject: [PATCH 4/9] Clean up RuntimeClass Topology documentation --- pkg/apis/node/types.go | 28 +++-- pkg/apis/node/v1alpha1/BUILD | 2 + pkg/apis/node/v1alpha1/conversion_test.go | 101 +++++++++++++++--- pkg/apis/node/v1beta1/BUILD | 1 - pkg/apis/node/v1beta1/conversion.go | 25 ----- pkg/apis/node/v1beta1/register.go | 7 -- staging/src/k8s.io/api/node/v1alpha1/doc.go | 1 + staging/src/k8s.io/api/node/v1alpha1/types.go | 22 ++-- staging/src/k8s.io/api/node/v1beta1/doc.go | 1 + staging/src/k8s.io/api/node/v1beta1/types.go | 24 +++-- staging/src/k8s.io/api/roundtrip_test.go | 4 + 11 files changed, 141 insertions(+), 75 deletions(-) delete mode 100644 pkg/apis/node/v1beta1/conversion.go diff --git a/pkg/apis/node/types.go b/pkg/apis/node/types.go index 5db5600f9b..0bf1808578 100644 --- a/pkg/apis/node/types.go +++ b/pkg/apis/node/types.go @@ -17,8 +17,8 @@ limitations under the License. package node import ( - v1 "k8s.io/kubernetes/pkg/apis/core" metav1 "k8s.io/apimachinery/pkg/apis/meta/v1" + "k8s.io/kubernetes/pkg/apis/core" ) // +k8s:deepcopy-gen:interfaces=k8s.io/apimachinery/pkg/runtime.Object @@ -47,24 +47,32 @@ type RuntimeClass struct { // immutable. Handler string - // Topology specifies the scheduling constrains that are necessary to assign - // pods to the right node + // Topology describes the set of nodes in the cluster that support this + // RuntimeClass. The rules are applied applied to pods running with this + // RuntimeClass and semantically merged with other scheduling constraints on + // the pod. + // If topology is nil, this RuntimeClass is assumed to be supported by all + // nodes. // +optional Topology *Topology } -// Topology specifies the structure of scheduling constrains for the runtime class +// Topology specifies the scheduling constraints for nodes supporting a +// RuntimeClass. type Topology struct { - // nodeSelector selects the set of nodes that support this RuntimeClass. + // NodeSelector selects the set of nodes that support this RuntimeClass. // Pods using this RuntimeClass can only be scheduled to a node matched by - // this selector. The nodeSelector is intersected (AND) with a pod's other - // node affinity or node selector requirements. + // this selector. The NodeSelector is intersected (AND) with a pod's other + // NodeAffinity or NodeSelector requirements. + // A nil NodeSelector selects all nodes. // +optional - NodeSelector *v1.NodeSelector + NodeSelector *core.NodeSelector - // tolerations adds tolerations to pods running with this RuntimeClass. + // Tolerations are appended (excluding duplicates) to pods running with this + // RuntimeClass during admission, effectively unioning the set of nodes + // tolerated by the pod and the RuntimeClass. // +optional - Tolerations []v1.Toleration + Tolerations []core.Toleration } // +k8s:deepcopy-gen:interfaces=k8s.io/apimachinery/pkg/runtime.Object diff --git a/pkg/apis/node/v1alpha1/BUILD b/pkg/apis/node/v1alpha1/BUILD index 061c744953..216b1e4f2b 100644 --- a/pkg/apis/node/v1alpha1/BUILD +++ b/pkg/apis/node/v1alpha1/BUILD @@ -40,7 +40,9 @@ go_test( srcs = ["conversion_test.go"], embed = [":go_default_library"], deps = [ + "//pkg/apis/core:go_default_library", "//pkg/apis/node:go_default_library", + "//staging/src/k8s.io/api/core/v1:go_default_library", "//staging/src/k8s.io/api/node/v1alpha1:go_default_library", "//staging/src/k8s.io/apimachinery/pkg/apis/meta/v1:go_default_library", "//vendor/github.com/stretchr/testify/assert:go_default_library", diff --git a/pkg/apis/node/v1alpha1/conversion_test.go b/pkg/apis/node/v1alpha1/conversion_test.go index 6c794ef6c7..124643820f 100644 --- a/pkg/apis/node/v1alpha1/conversion_test.go +++ b/pkg/apis/node/v1alpha1/conversion_test.go @@ -21,8 +21,10 @@ import ( "github.com/stretchr/testify/assert" "github.com/stretchr/testify/require" + corev1 "k8s.io/api/core/v1" v1alpha1 "k8s.io/api/node/v1alpha1" metav1 "k8s.io/apimachinery/pkg/apis/meta/v1" + core "k8s.io/kubernetes/pkg/apis/core" node "k8s.io/kubernetes/pkg/apis/node" ) @@ -31,24 +33,91 @@ func TestRuntimeClassConversion(t *testing.T) { name = "puppy" handler = "heidi" ) - internalRC := node.RuntimeClass{ - ObjectMeta: metav1.ObjectMeta{Name: name}, - Handler: handler, - } - v1alpha1RC := v1alpha1.RuntimeClass{ - ObjectMeta: metav1.ObjectMeta{Name: name}, - Spec: v1alpha1.RuntimeClassSpec{ - RuntimeHandler: handler, + tests := map[string]struct { + internal *node.RuntimeClass + external *v1alpha1.RuntimeClass + }{ + "fully-specified": { + internal: &node.RuntimeClass{ + ObjectMeta: metav1.ObjectMeta{Name: name}, + Handler: handler, + Topology: &node.Topology{ + NodeSelector: &core.NodeSelector{ + NodeSelectorTerms: []core.NodeSelectorTerm{{ + MatchExpressions: []core.NodeSelectorRequirement{{ + Key: "extra-soft", + Operator: core.NodeSelectorOpExists, + }}, + }}, + }, + Tolerations: []core.Toleration{{ + Key: "stinky", + Operator: core.TolerationOpExists, + Effect: core.TaintEffectNoSchedule, + }}, + }, + }, + external: &v1alpha1.RuntimeClass{ + ObjectMeta: metav1.ObjectMeta{Name: name}, + Spec: v1alpha1.RuntimeClassSpec{ + RuntimeHandler: handler, + Topology: &v1alpha1.Topology{ + NodeSelector: &corev1.NodeSelector{ + NodeSelectorTerms: []corev1.NodeSelectorTerm{{ + MatchExpressions: []corev1.NodeSelectorRequirement{{ + Key: "extra-soft", + Operator: corev1.NodeSelectorOpExists, + }}, + }}, + }, + Tolerations: []corev1.Toleration{{ + Key: "stinky", + Operator: corev1.TolerationOpExists, + Effect: corev1.TaintEffectNoSchedule, + }}, + }, + }, + }, + }, + "empty-topology": { + internal: &node.RuntimeClass{ + ObjectMeta: metav1.ObjectMeta{Name: name}, + Handler: handler, + Topology: &node.Topology{}, + }, + external: &v1alpha1.RuntimeClass{ + ObjectMeta: metav1.ObjectMeta{Name: name}, + Spec: v1alpha1.RuntimeClassSpec{ + RuntimeHandler: handler, + Topology: &v1alpha1.Topology{}, + }, + }, + }, + "empty": { + internal: &node.RuntimeClass{ + ObjectMeta: metav1.ObjectMeta{Name: name}, + Handler: handler, + }, + external: &v1alpha1.RuntimeClass{ + ObjectMeta: metav1.ObjectMeta{Name: name}, + Spec: v1alpha1.RuntimeClassSpec{ + RuntimeHandler: handler, + }, + }, }, } - convertedInternal := node.RuntimeClass{} - require.NoError(t, - Convert_v1alpha1_RuntimeClass_To_node_RuntimeClass(&v1alpha1RC, &convertedInternal, nil)) - assert.Equal(t, internalRC, convertedInternal) + for name, test := range tests { + t.Run(name, func(t *testing.T) { + convertedInternal := &node.RuntimeClass{} + require.NoError(t, + Convert_v1alpha1_RuntimeClass_To_node_RuntimeClass(test.external, convertedInternal, nil)) + assert.Equal(t, test.internal, convertedInternal, "external -> internal") - convertedV1alpha1 := v1alpha1.RuntimeClass{} - require.NoError(t, - Convert_node_RuntimeClass_To_v1alpha1_RuntimeClass(&internalRC, &convertedV1alpha1, nil)) - assert.Equal(t, v1alpha1RC, convertedV1alpha1) + convertedV1alpha1 := &v1alpha1.RuntimeClass{} + require.NoError(t, + Convert_node_RuntimeClass_To_v1alpha1_RuntimeClass(test.internal, convertedV1alpha1, nil)) + assert.Equal(t, test.external, convertedV1alpha1, "internal -> external") + }) + } } diff --git a/pkg/apis/node/v1beta1/BUILD b/pkg/apis/node/v1beta1/BUILD index 53b756e3a7..07ef4b482b 100644 --- a/pkg/apis/node/v1beta1/BUILD +++ b/pkg/apis/node/v1beta1/BUILD @@ -3,7 +3,6 @@ load("@io_bazel_rules_go//go:def.bzl", "go_library") go_library( name = "go_default_library", srcs = [ - "conversion.go", "doc.go", "register.go", "zz_generated.conversion.go", diff --git a/pkg/apis/node/v1beta1/conversion.go b/pkg/apis/node/v1beta1/conversion.go deleted file mode 100644 index b7d88363d2..0000000000 --- a/pkg/apis/node/v1beta1/conversion.go +++ /dev/null @@ -1,25 +0,0 @@ -/* -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 v1beta1 - -import ( - "k8s.io/apimachinery/pkg/runtime" -) - -func addConversionFuncs(s *runtime.Scheme) error { - return s.AddConversionFuncs() -} diff --git a/pkg/apis/node/v1beta1/register.go b/pkg/apis/node/v1beta1/register.go index 19250848d0..e018e3b70e 100644 --- a/pkg/apis/node/v1beta1/register.go +++ b/pkg/apis/node/v1beta1/register.go @@ -37,10 +37,3 @@ var ( // AddToScheme node API registration 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(addConversionFuncs) -} diff --git a/staging/src/k8s.io/api/node/v1alpha1/doc.go b/staging/src/k8s.io/api/node/v1alpha1/doc.go index f7f8b78b42..dfe99540b5 100644 --- a/staging/src/k8s.io/api/node/v1alpha1/doc.go +++ b/staging/src/k8s.io/api/node/v1alpha1/doc.go @@ -15,6 +15,7 @@ limitations under the License. */ // +k8s:deepcopy-gen=package +// +k8s:protobuf-gen=package // +k8s:openapi-gen=true // +groupName=node.k8s.io diff --git a/staging/src/k8s.io/api/node/v1alpha1/types.go b/staging/src/k8s.io/api/node/v1alpha1/types.go index a0c133cfb6..e061335d4c 100644 --- a/staging/src/k8s.io/api/node/v1alpha1/types.go +++ b/staging/src/k8s.io/api/node/v1alpha1/types.go @@ -60,22 +60,30 @@ type RuntimeClassSpec struct { // and is immutable. RuntimeHandler string `json:"runtimeHandler" protobuf:"bytes,1,opt,name=runtimeHandler"` - // Topology specifies the scheduling constrains that are necessary to assign - // pods to the right node + // Topology describes the set of nodes in the cluster that support this + // RuntimeClass. The rules are applied applied to pods running with this + // RuntimeClass and semantically merged with other scheduling constraints on + // the pod. + // If topology is nil, this RuntimeClass is assumed to be supported by all + // nodes. // +optional Topology *Topology `json:"topology,omitempty" protobuf:"bytes,3,opt,name=topology"` } -// Topology specifies the structure of scheduling constrains for the runtime class +// Topology specifies the scheduling constraints for nodes supporting a +// RuntimeClass. type Topology struct { - // nodeSelector selects the set of nodes that support this RuntimeClass. + // NodeSelector selects the set of nodes that support this RuntimeClass. // Pods using this RuntimeClass can only be scheduled to a node matched by - // this selector. The nodeSelector is intersected (AND) with a pod's other - // node affinity or node selector requirements. + // this selector. The NodeSelector is intersected (AND) with a pod's other + // NodeAffinity or NodeSelector requirements. + // A nil NodeSelector selects all nodes. // +optional NodeSelector *v1.NodeSelector `json:"nodeSelector,omitempty" protobuf:"bytes,1,opt,name=nodeSelector"` - // tolerations adds tolerations to pods running with this RuntimeClass. + // Tolerations are appended (excluding duplicates) to pods running with this + // RuntimeClass during admission, effectively unioning the set of nodes + // tolerated by the pod and the RuntimeClass. // +optional Tolerations []v1.Toleration `json:"tolerations,omitempty" protobuf:"bytes,2,rep,name=tolerations"` } diff --git a/staging/src/k8s.io/api/node/v1beta1/doc.go b/staging/src/k8s.io/api/node/v1beta1/doc.go index 0e8338cf7a..e87583cea9 100644 --- a/staging/src/k8s.io/api/node/v1beta1/doc.go +++ b/staging/src/k8s.io/api/node/v1beta1/doc.go @@ -15,6 +15,7 @@ limitations under the License. */ // +k8s:deepcopy-gen=package +// +k8s:protobuf-gen=package // +k8s:openapi-gen=true // +groupName=node.k8s.io diff --git a/staging/src/k8s.io/api/node/v1beta1/types.go b/staging/src/k8s.io/api/node/v1beta1/types.go index 628507be25..8d65785803 100644 --- a/staging/src/k8s.io/api/node/v1beta1/types.go +++ b/staging/src/k8s.io/api/node/v1beta1/types.go @@ -50,24 +50,30 @@ type RuntimeClass struct { // immutable. Handler string `json:"handler" protobuf:"bytes,2,opt,name=handler"` - // Topology describes the set of nodes in the cluster that support this RuntimeClass. The rules are applied to the pod during scheduling time. - // If topology is nil, this RuntimeClass is assumed to be supported by all nodes. - // pods to the right node + // Topology describes the set of nodes in the cluster that support this + // RuntimeClass. The rules are applied applied to pods running with this + // RuntimeClass and semantically merged with other scheduling constraints on + // the pod. + // If topology is nil, this RuntimeClass is assumed to be supported by all + // nodes. // +optional Topology *Topology `json:"topology,omitempty" protobuf:"bytes,3,opt,name=topology"` } -// Topology specifies the scheduling constraints for nodes supporting a RuntimeClass. +// Topology specifies the scheduling constraints for nodes supporting a +// RuntimeClass. type Topology struct { - // nodeSelector selects the set of nodes that support this RuntimeClass. + // NodeSelector selects the set of nodes that support this RuntimeClass. // Pods using this RuntimeClass can only be scheduled to a node matched by - // this selector. The nodeSelector is intersected (AND) with a pod's other - // node affinity or node selector requirements. A nil nodeSelector selects all nodes. + // this selector. The NodeSelector is intersected (AND) with a pod's other + // NodeAffinity or NodeSelector requirements. + // A nil NodeSelector selects all nodes. // +optional NodeSelector *v1.NodeSelector `json:"nodeSelector,omitempty" protobuf:"bytes,1,opt,name=nodeSelector"` - // tolerations adds tolerations to pods running with this RuntimeClass. - // the tolerations are appended (excluding duplicates) to the pod's tolerations during admission. + // Tolerations are appended (excluding duplicates) to pods running with this + // RuntimeClass during admission, effectively unioning the set of nodes + // tolerated by the pod and the RuntimeClass. // +optional Tolerations []v1.Toleration `json:"tolerations,omitempty" protobuf:"bytes,2,rep,name=tolerations"` } diff --git a/staging/src/k8s.io/api/roundtrip_test.go b/staging/src/k8s.io/api/roundtrip_test.go index a36721f10a..910732174f 100644 --- a/staging/src/k8s.io/api/roundtrip_test.go +++ b/staging/src/k8s.io/api/roundtrip_test.go @@ -40,6 +40,8 @@ import ( extensionsv1beta1 "k8s.io/api/extensions/v1beta1" imagepolicyv1alpha1 "k8s.io/api/imagepolicy/v1alpha1" networkingv1 "k8s.io/api/networking/v1" + nodev1alpha1 "k8s.io/api/node/v1alpha1" + nodev1beta1 "k8s.io/api/node/v1beta1" policyv1beta1 "k8s.io/api/policy/v1beta1" rbacv1 "k8s.io/api/rbac/v1" rbacv1alpha1 "k8s.io/api/rbac/v1alpha1" @@ -83,6 +85,8 @@ var groups = []runtime.SchemeBuilder{ extensionsv1beta1.SchemeBuilder, imagepolicyv1alpha1.SchemeBuilder, networkingv1.SchemeBuilder, + nodev1alpha1.SchemeBuilder, + nodev1beta1.SchemeBuilder, policyv1beta1.SchemeBuilder, rbacv1alpha1.SchemeBuilder, rbacv1beta1.SchemeBuilder, From 12bcbd9a74df5b7c365040aa6ba1ef240fd0820f Mon Sep 17 00:00:00 2001 From: Tim Allclair Date: Tue, 23 Apr 2019 17:26:13 -0700 Subject: [PATCH 5/9] Regenerate generated files --- api/openapi-spec/swagger.json | 14 +- staging/src/k8s.io/api/BUILD | 2 + .../k8s.io/api/node/v1alpha1/generated.pb.go | 299 ++++++++++++++++-- .../k8s.io/api/node/v1alpha1/generated.proto | 28 ++ .../v1alpha1/types_swagger_doc_generated.go | 8 +- .../k8s.io/api/node/v1beta1/generated.pb.go | 299 ++++++++++++++++-- .../k8s.io/api/node/v1beta1/generated.proto | 28 ++ .../v1beta1/types_swagger_doc_generated.go | 6 +- 8 files changed, 614 insertions(+), 70 deletions(-) diff --git a/api/openapi-spec/swagger.json b/api/openapi-spec/swagger.json index ccaae47b8d..5904d8a8ae 100644 --- a/api/openapi-spec/swagger.json +++ b/api/openapi-spec/swagger.json @@ -13283,7 +13283,7 @@ }, "topology": { "$ref": "#/definitions/io.k8s.api.node.v1alpha1.Topology", - "description": "Topology specifies the scheduling constrains that are necessary to assign pods to the right node" + "description": "Topology describes the set of nodes in the cluster that support this RuntimeClass. The rules are applied applied to pods running with this RuntimeClass and semantically merged with other scheduling constraints on the pod. If topology is nil, this RuntimeClass is assumed to be supported by all nodes." } }, "required": [ @@ -13292,14 +13292,14 @@ "type": "object" }, "io.k8s.api.node.v1alpha1.Topology": { - "description": "Topology specifies the structure of scheduling constrains for the runtime class", + "description": "Topology specifies the scheduling constraints for nodes supporting a RuntimeClass.", "properties": { "nodeSelector": { "$ref": "#/definitions/io.k8s.api.core.v1.NodeSelector", - "description": "nodeSelector selects the set of nodes that support this RuntimeClass. Pods using this RuntimeClass can only be scheduled to a node matched by this selector. The nodeSelector is intersected (AND) with a pod's other node affinity or node selector requirements." + "description": "NodeSelector selects the set of nodes that support this RuntimeClass. Pods using this RuntimeClass can only be scheduled to a node matched by this selector. The NodeSelector is intersected (AND) with a pod's other NodeAffinity or NodeSelector requirements. A nil NodeSelector selects all nodes." }, "tolerations": { - "description": "tolerations adds tolerations to pods running with this RuntimeClass.", + "description": "Tolerations are appended (excluding duplicates) to pods running with this RuntimeClass during admission, effectively unioning the set of nodes tolerated by the pod and the RuntimeClass.", "items": { "$ref": "#/definitions/io.k8s.api.core.v1.Toleration" }, @@ -13329,7 +13329,7 @@ }, "topology": { "$ref": "#/definitions/io.k8s.api.node.v1beta1.Topology", - "description": "Topology describes the set of nodes in the cluster that support this RuntimeClass. The rules are applied to the pod during scheduling time. If topology is nil, this RuntimeClass is assumed to be supported by all nodes. pods to the right node" + "description": "Topology describes the set of nodes in the cluster that support this RuntimeClass. The rules are applied applied to pods running with this RuntimeClass and semantically merged with other scheduling constraints on the pod. If topology is nil, this RuntimeClass is assumed to be supported by all nodes." } }, "required": [ @@ -13384,10 +13384,10 @@ "properties": { "nodeSelector": { "$ref": "#/definitions/io.k8s.api.core.v1.NodeSelector", - "description": "nodeSelector selects the set of nodes that support this RuntimeClass. Pods using this RuntimeClass can only be scheduled to a node matched by this selector. The nodeSelector is intersected (AND) with a pod's other node affinity or node selector requirements. A nil nodeSelector selects all nodes." + "description": "NodeSelector selects the set of nodes that support this RuntimeClass. Pods using this RuntimeClass can only be scheduled to a node matched by this selector. The NodeSelector is intersected (AND) with a pod's other NodeAffinity or NodeSelector requirements. A nil NodeSelector selects all nodes." }, "tolerations": { - "description": "tolerations adds tolerations to pods running with this RuntimeClass. the tolerations are appended (excluding duplicates) to the pod's tolerations during admission.", + "description": "Tolerations are appended (excluding duplicates) to pods running with this RuntimeClass during admission, effectively unioning the set of nodes tolerated by the pod and the RuntimeClass.", "items": { "$ref": "#/definitions/io.k8s.api.core.v1.Toleration" }, diff --git a/staging/src/k8s.io/api/BUILD b/staging/src/k8s.io/api/BUILD index 364f85d0a5..e1d4fecb37 100644 --- a/staging/src/k8s.io/api/BUILD +++ b/staging/src/k8s.io/api/BUILD @@ -24,6 +24,8 @@ go_test( "//staging/src/k8s.io/api/extensions/v1beta1:go_default_library", "//staging/src/k8s.io/api/imagepolicy/v1alpha1:go_default_library", "//staging/src/k8s.io/api/networking/v1:go_default_library", + "//staging/src/k8s.io/api/node/v1alpha1:go_default_library", + "//staging/src/k8s.io/api/node/v1beta1:go_default_library", "//staging/src/k8s.io/api/policy/v1beta1:go_default_library", "//staging/src/k8s.io/api/rbac/v1:go_default_library", "//staging/src/k8s.io/api/rbac/v1alpha1:go_default_library", diff --git a/staging/src/k8s.io/api/node/v1alpha1/generated.pb.go b/staging/src/k8s.io/api/node/v1alpha1/generated.pb.go index 16f5af9299..fc4bc16983 100644 --- a/staging/src/k8s.io/api/node/v1alpha1/generated.pb.go +++ b/staging/src/k8s.io/api/node/v1alpha1/generated.pb.go @@ -27,6 +27,7 @@ limitations under the License. RuntimeClass RuntimeClassList RuntimeClassSpec + Topology */ package v1alpha1 @@ -34,6 +35,8 @@ import proto "github.com/gogo/protobuf/proto" import fmt "fmt" import math "math" +import k8s_io_api_core_v1 "k8s.io/api/core/v1" + import strings "strings" import reflect "reflect" @@ -62,10 +65,15 @@ func (m *RuntimeClassSpec) Reset() { *m = RuntimeClassSpec{} func (*RuntimeClassSpec) ProtoMessage() {} func (*RuntimeClassSpec) Descriptor() ([]byte, []int) { return fileDescriptorGenerated, []int{2} } +func (m *Topology) Reset() { *m = Topology{} } +func (*Topology) ProtoMessage() {} +func (*Topology) Descriptor() ([]byte, []int) { return fileDescriptorGenerated, []int{3} } + func init() { proto.RegisterType((*RuntimeClass)(nil), "k8s.io.api.node.v1alpha1.RuntimeClass") proto.RegisterType((*RuntimeClassList)(nil), "k8s.io.api.node.v1alpha1.RuntimeClassList") proto.RegisterType((*RuntimeClassSpec)(nil), "k8s.io.api.node.v1alpha1.RuntimeClassSpec") + proto.RegisterType((*Topology)(nil), "k8s.io.api.node.v1alpha1.Topology") } func (m *RuntimeClass) Marshal() (dAtA []byte, err error) { size := m.Size() @@ -158,6 +166,56 @@ func (m *RuntimeClassSpec) MarshalTo(dAtA []byte) (int, error) { i++ i = encodeVarintGenerated(dAtA, i, uint64(len(m.RuntimeHandler))) i += copy(dAtA[i:], m.RuntimeHandler) + if m.Topology != nil { + dAtA[i] = 0x1a + i++ + i = encodeVarintGenerated(dAtA, i, uint64(m.Topology.Size())) + n4, err := m.Topology.MarshalTo(dAtA[i:]) + if err != nil { + return 0, err + } + i += n4 + } + return i, nil +} + +func (m *Topology) Marshal() (dAtA []byte, err error) { + size := m.Size() + dAtA = make([]byte, size) + n, err := m.MarshalTo(dAtA) + if err != nil { + return nil, err + } + return dAtA[:n], nil +} + +func (m *Topology) MarshalTo(dAtA []byte) (int, error) { + var i int + _ = i + var l int + _ = l + if m.NodeSelector != nil { + dAtA[i] = 0xa + i++ + i = encodeVarintGenerated(dAtA, i, uint64(m.NodeSelector.Size())) + n5, err := m.NodeSelector.MarshalTo(dAtA[i:]) + if err != nil { + return 0, err + } + i += n5 + } + if len(m.Tolerations) > 0 { + for _, msg := range m.Tolerations { + dAtA[i] = 0x12 + i++ + i = encodeVarintGenerated(dAtA, i, uint64(msg.Size())) + n, err := msg.MarshalTo(dAtA[i:]) + if err != nil { + return 0, err + } + i += n + } + } return i, nil } @@ -199,6 +257,26 @@ func (m *RuntimeClassSpec) Size() (n int) { _ = l l = len(m.RuntimeHandler) n += 1 + l + sovGenerated(uint64(l)) + if m.Topology != nil { + l = m.Topology.Size() + n += 1 + l + sovGenerated(uint64(l)) + } + return n +} + +func (m *Topology) Size() (n int) { + var l int + _ = l + if m.NodeSelector != nil { + l = m.NodeSelector.Size() + n += 1 + l + sovGenerated(uint64(l)) + } + if len(m.Tolerations) > 0 { + for _, e := range m.Tolerations { + l = e.Size() + n += 1 + l + sovGenerated(uint64(l)) + } + } return n } @@ -243,6 +321,18 @@ func (this *RuntimeClassSpec) String() string { } s := strings.Join([]string{`&RuntimeClassSpec{`, `RuntimeHandler:` + fmt.Sprintf("%v", this.RuntimeHandler) + `,`, + `Topology:` + strings.Replace(fmt.Sprintf("%v", this.Topology), "Topology", "Topology", 1) + `,`, + `}`, + }, "") + return s +} +func (this *Topology) String() string { + if this == nil { + return "nil" + } + s := strings.Join([]string{`&Topology{`, + `NodeSelector:` + strings.Replace(fmt.Sprintf("%v", this.NodeSelector), "NodeSelector", "k8s_io_api_core_v1.NodeSelector", 1) + `,`, + `Tolerations:` + strings.Replace(strings.Replace(fmt.Sprintf("%v", this.Tolerations), "Toleration", "k8s_io_api_core_v1.Toleration", 1), `&`, ``, 1) + `,`, `}`, }, "") return s @@ -534,6 +624,153 @@ func (m *RuntimeClassSpec) Unmarshal(dAtA []byte) error { } m.RuntimeHandler = string(dAtA[iNdEx:postIndex]) iNdEx = postIndex + case 3: + if wireType != 2 { + return fmt.Errorf("proto: wrong wireType = %d for field Topology", wireType) + } + var msglen int + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowGenerated + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + msglen |= (int(b) & 0x7F) << shift + if b < 0x80 { + break + } + } + if msglen < 0 { + return ErrInvalidLengthGenerated + } + postIndex := iNdEx + msglen + if postIndex > l { + return io.ErrUnexpectedEOF + } + if m.Topology == nil { + m.Topology = &Topology{} + } + if err := m.Topology.Unmarshal(dAtA[iNdEx:postIndex]); err != nil { + return err + } + iNdEx = postIndex + default: + iNdEx = preIndex + skippy, err := skipGenerated(dAtA[iNdEx:]) + if err != nil { + return err + } + if skippy < 0 { + return ErrInvalidLengthGenerated + } + if (iNdEx + skippy) > l { + return io.ErrUnexpectedEOF + } + iNdEx += skippy + } + } + + if iNdEx > l { + return io.ErrUnexpectedEOF + } + return nil +} +func (m *Topology) Unmarshal(dAtA []byte) error { + l := len(dAtA) + iNdEx := 0 + for iNdEx < l { + preIndex := iNdEx + var wire uint64 + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowGenerated + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + wire |= (uint64(b) & 0x7F) << shift + if b < 0x80 { + break + } + } + fieldNum := int32(wire >> 3) + wireType := int(wire & 0x7) + if wireType == 4 { + return fmt.Errorf("proto: Topology: wiretype end group for non-group") + } + if fieldNum <= 0 { + return fmt.Errorf("proto: Topology: illegal tag %d (wire type %d)", fieldNum, wire) + } + switch fieldNum { + case 1: + if wireType != 2 { + return fmt.Errorf("proto: wrong wireType = %d for field NodeSelector", wireType) + } + var msglen int + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowGenerated + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + msglen |= (int(b) & 0x7F) << shift + if b < 0x80 { + break + } + } + if msglen < 0 { + return ErrInvalidLengthGenerated + } + postIndex := iNdEx + msglen + if postIndex > l { + return io.ErrUnexpectedEOF + } + if m.NodeSelector == nil { + m.NodeSelector = &k8s_io_api_core_v1.NodeSelector{} + } + if err := m.NodeSelector.Unmarshal(dAtA[iNdEx:postIndex]); err != nil { + return err + } + iNdEx = postIndex + case 2: + if wireType != 2 { + return fmt.Errorf("proto: wrong wireType = %d for field Tolerations", wireType) + } + var msglen int + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowGenerated + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + msglen |= (int(b) & 0x7F) << shift + if b < 0x80 { + break + } + } + if msglen < 0 { + return ErrInvalidLengthGenerated + } + postIndex := iNdEx + msglen + if postIndex > l { + return io.ErrUnexpectedEOF + } + m.Tolerations = append(m.Tolerations, k8s_io_api_core_v1.Toleration{}) + if err := m.Tolerations[len(m.Tolerations)-1].Unmarshal(dAtA[iNdEx:postIndex]); err != nil { + return err + } + iNdEx = postIndex default: iNdEx = preIndex skippy, err := skipGenerated(dAtA[iNdEx:]) @@ -665,32 +902,38 @@ func init() { } var fileDescriptorGenerated = []byte{ - // 421 bytes of a gzipped FileDescriptorProto - 0x1f, 0x8b, 0x08, 0x00, 0x00, 0x00, 0x00, 0x00, 0x02, 0xff, 0x8c, 0x91, 0x41, 0x6b, 0xd4, 0x40, - 0x14, 0xc7, 0x33, 0xb5, 0x85, 0x75, 0x5a, 0x4b, 0xc9, 0x41, 0xc2, 0x1e, 0xa6, 0x65, 0x0f, 0x52, - 0x04, 0x67, 0xdc, 0x22, 0xe2, 0x49, 0x30, 0x5e, 0x14, 0x2b, 0x42, 0xbc, 0x89, 0x07, 0x27, 0xc9, - 0x33, 0x19, 0xb3, 0xc9, 0x0c, 0x99, 0x49, 0xc0, 0x9b, 0x1f, 0xc1, 0x2f, 0xa4, 0xe7, 0x3d, 0xf6, - 0xd8, 0x53, 0x71, 0xe3, 0x17, 0x91, 0x99, 0x64, 0x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9, 0xd5, 0xb1, 0xd7, - 0x5d, 0x1d, 0xe3, 0x55, 0x2f, 0xba, 0xa6, 0xfa, 0xe7, 0x78, 0x57, 0x2b, 0x48, 0x82, 0x1d, 0x47, - 0x7f, 0x4c, 0xef, 0xba, 0x34, 0x5d, 0xdf, 0xeb, 0xa3, 0x82, 0x24, 0x3c, 0x18, 0xb8, 0xbb, 0xb6, - 0x8a, 0x1c, 0x65, 0xf2, 0x0b, 0xe1, 0xa3, 0x75, 0xe1, 0xb9, 0xd0, 0xc6, 0xff, 0xbc, 0x11, 0x82, - 0x6e, 0x17, 0xc2, 0xba, 0x5d, 0x84, 0xa3, 0x61, 0xd4, 0x68, 0xd9, 0x59, 0x0b, 0xf0, 0x0e, 0xef, - 0x09, 0x03, 0xa5, 0x0e, 0x76, 0x4e, 0xee, 0x9d, 0xee, 0x9f, 0x3d, 0xda, 0x2e, 0x41, 0xf8, 0x60, - 0x40, 0xee, 0xbd, 0xb5, 0xe6, 0xa8, 0x67, 0x4c, 0xa2, 0x9b, 0xeb, 0xdb, 0x64, 0xfe, 0x4b, 0x7c, - 0x38, 0xfc, 0xb6, 0x37, 0xbc, 0x4a, 0x67, 0x50, 0xbb, 0x10, 0xf7, 0xc3, 0x87, 0x03, 0xe1, 0x30, - 0xba, 0xf1, 0x1a, 0xdd, 0x52, 0x87, 0x74, 0xbe, 0x20, 0xde, 0xc5, 0x82, 0x78, 0x97, 0x0b, 0xe2, - 0xfd, 0xe8, 0x08, 0x9a, 0x77, 0x04, 0x5d, 0x74, 0x04, 0x5d, 0x76, 0x04, 0xfd, 0xe9, 0x08, 0xfa, - 0xf9, 0x97, 0x78, 0x9f, 0x46, 0xcb, 0x35, 0xff, 0x05, 0x00, 0x00, 0xff, 0xff, 0x94, 0x34, 0x0e, - 0xef, 0x30, 0x03, 0x00, 0x00, + // 527 bytes of a gzipped FileDescriptorProto + 0x1f, 0x8b, 0x08, 0x00, 0x00, 0x00, 0x00, 0x00, 0x02, 0xff, 0x8c,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2, 0x47, 0x90, 0x15, 0x29, 0xfe, 0x73, 0xee, 0x96, 0x88, 0x23, + 0xf7, 0xca, 0x53, 0x77, 0x4b, 0x6d, 0x8e, 0x70, 0x5b, 0x89, 0x54, 0x44, 0x22, 0x38, 0xb7, 0xf6, + 0x8b, 0xfc, 0xf6, 0xee, 0x25, 0xcf, 0x4a, 0xa5, 0x63, 0xe8, 0xbc, 0x55, 0xe5, 0xd6, 0x04, 0xfb, + 0x07, 0xc2, 0x75, 0xdb, 0x7c, 0x8f, 0x0d, 0x6d, 0x3f, 0x85, 0x08, 0x3c, 0x25, 0xb2, 0xf2, 0xbc, + 0x83, 0x26, 0x5e, 0x7f, 0x0a, 0xfa, 0x98, 0x6f, 0x1a, 0x3a, 0xa7, 0x9b, 0x2f, 0xfb, 0x46, 0xb3, + 0xe3, 0x5e, 0xe1, 0x98, 0xef, 0x70, 0x47, 0x89, 0x48, 0xff, 0x37, 0x43, 0x91, 0x54, 0xa7, 0x25, + 0x37, 0x61, 0xcf, 0x6a, 0x99, 0x73, 0xa7, 0xbc, 0x47, 0x67, 0xd3, 0x93, 0x6e, 0x93, 0xe3, 0xd0, + 0xc5, 0x8a, 0xb4, 0x2e, 0x56, 0xa4, 0x75, 0xb9, 0x22, 0xad, 0xaf, 0x39, 0x41, 0x8b, 0x9c, 0xa0, + 0x8b, 0x9c, 0xa0, 0xcb, 0x9c, 0xa0, 0xdf, 0x39, 0x41, 0xdf, 0xfe, 0x90, 0xd6, 0x87, 0x76, 0x75, + 0x8c, 0xbf, 0x01, 0x00, 0x00, 0xff, 0xff, 0x61, 0x6b, 0x4c, 0x0f, 0x5f, 0x04, 0x00, 0x00, } diff --git a/staging/src/k8s.io/api/node/v1alpha1/generated.proto b/staging/src/k8s.io/api/node/v1alpha1/generated.proto index ca4e5e5350..ef5bae6c5c 100644 --- a/staging/src/k8s.io/api/node/v1alpha1/generated.proto +++ b/staging/src/k8s.io/api/node/v1alpha1/generated.proto @@ -21,6 +21,7 @@ syntax = 'proto2'; package k8s.io.api.node.v1alpha1; +import "k8s.io/api/core/v1/generated.proto"; import "k8s.io/apimachinery/pkg/apis/meta/v1/generated.proto"; import "k8s.io/apimachinery/pkg/runtime/generated.proto"; import "k8s.io/apimachinery/pkg/runtime/schema/generated.proto"; @@ -72,5 +73,32 @@ message RuntimeClassSpec { // The RuntimeHandler must conform to the DNS Label (RFC 1123) requirements // and is immutable. optional string runtimeHandler = 1; + + // Topology describes the set of nodes in the cluster that support this + // RuntimeClass. The rules are applied applied to pods running with this + // RuntimeClass and semantically merged with other scheduling constraints on + // the pod. + // If topology is nil, this RuntimeClass is assumed to be supported by all + // nodes. + // +optional + optional Topology topology = 3; +} + +// Topology specifies the scheduling constraints for nodes supporting a +// RuntimeClass. +message Topology { + // NodeSelector selects the set of nodes that support this RuntimeClass. + // Pods using this RuntimeClass can only be scheduled to a node matched by + // this selector. The NodeSelector is intersected (AND) with a pod's other + // NodeAffinity or NodeSelector requirements. + // A nil NodeSelector selects all nodes. + // +optional + optional k8s.io.api.core.v1.NodeSelector nodeSelector = 1; + + // Tolerations are appended (excluding duplicates) to pods running with this + // RuntimeClass during admission, effectively unioning the set of nodes + // tolerated by the pod and the RuntimeClass. + // +optional + repeated k8s.io.api.core.v1.Toleration tolerations = 2; } diff --git a/staging/src/k8s.io/api/node/v1alpha1/types_swagger_doc_generated.go b/staging/src/k8s.io/api/node/v1alpha1/types_swagger_doc_generated.go index 9b7183332b..5be2d04ec9 100644 --- a/staging/src/k8s.io/api/node/v1alpha1/types_swagger_doc_generated.go +++ b/staging/src/k8s.io/api/node/v1alpha1/types_swagger_doc_generated.go @@ -50,7 +50,7 @@ func (RuntimeClassList) SwaggerDoc() map[string]string { var map_RuntimeClassSpec = map[string]string{ "": "RuntimeClassSpec is a specification of a RuntimeClass. It contains parameters that are required to describe the RuntimeClass to the Container Runtime Interface (CRI) implementation, as well as any other components that need to understand how the pod will be run. The RuntimeClassSpec is immutable.", "runtimeHandler": "RuntimeHandler specifies the underlying runtime and configuration that the CRI implementation will use to handle pods of this class. The possible values are specific to the node & CRI configuration. It is assumed that all handlers are available on every node, and handlers of the same name are equivalent on every node. For example, a handler called \"runc\" might specify that the runc OCI runtime (using native Linux containers) will be used to run the containers in a pod. The RuntimeHandler must conform to the DNS Label (RFC 1123) requirements and is immutable.", - "topology": "Topology specifies the scheduling constrains that are necessary to assign pods to the right node", + "topology": "Topology describes the set of nodes in the cluster that support this RuntimeClass. The rules are applied applied to pods running with this RuntimeClass and semantically merged with other scheduling constraints on the pod. If topology is nil, this RuntimeClass is assumed to be supported by all nodes.", } func (RuntimeClassSpec) SwaggerDoc() map[string]string { @@ -58,9 +58,9 @@ func (RuntimeClassSpec) SwaggerDoc() map[string]string { } var map_Topology = map[string]string{ - "": "Topology specifies the structure of scheduling constrains for the runtime class", - "nodeSelector": "nodeSelector selects the set of nodes that support this RuntimeClass. Pods using this RuntimeClass can only be scheduled to a node matched by this selector. The nodeSelector is intersected (AND) with a pod's other node affinity or node selector requirements.", - "tolerations": "tolerations adds tolerations to pods running with this RuntimeClass.", + "": "Topology specifies the scheduling constraints for nodes supporting a RuntimeClass.", + "nodeSelector": "NodeSelector selects the set of nodes that support this RuntimeClass. Pods using this RuntimeClass can only be scheduled to a node matched by this selector. The NodeSelector is intersected (AND) with a pod's other NodeAffinity or NodeSelector requirements. A nil NodeSelector selects all nodes.", + "tolerations": "Tolerations are appended (excluding duplicates) to pods running with this RuntimeClass during admission, effectively unioning the set of nodes tolerated by the pod and the RuntimeClass.", } func (Topology) SwaggerDoc() map[string]string { diff --git a/staging/src/k8s.io/api/node/v1beta1/generated.pb.go b/staging/src/k8s.io/api/node/v1beta1/generated.pb.go index 27251a8a89..c9b285f99d 100644 --- a/staging/src/k8s.io/api/node/v1beta1/generated.pb.go +++ b/staging/src/k8s.io/api/node/v1beta1/generated.pb.go @@ -26,6 +26,7 @@ limitations under the License. It has these top-level messages: RuntimeClass RuntimeClassList + Topology */ package v1beta1 @@ -33,6 +34,8 @@ import proto "github.com/gogo/protobuf/proto" import fmt "fmt" import math "math" +import k8s_io_api_core_v1 "k8s.io/api/core/v1" + import strings "strings" import reflect "reflect" @@ -57,9 +60,14 @@ func (m *RuntimeClassList) Reset() { *m = RuntimeClassList{} func (*RuntimeClassList) ProtoMessage() {} func (*RuntimeClassList) Descriptor() ([]byte, []int) { return fileDescriptorGenerated, []int{1} } +func (m *Topology) Reset() { *m = Topology{} } +func (*Topology) ProtoMessage() {} +func (*Topology) Descriptor() ([]byte, []int) { return fileDescriptorGenerated, []int{2} } + func init() { proto.RegisterType((*RuntimeClass)(nil), "k8s.io.api.node.v1beta1.RuntimeClass") proto.RegisterType((*RuntimeClassList)(nil), "k8s.io.api.node.v1beta1.RuntimeClassList") + proto.RegisterType((*Topology)(nil), "k8s.io.api.node.v1beta1.Topology") } func (m *RuntimeClass) Marshal() (dAtA []byte, err error) { size := m.Size() @@ -88,6 +96,16 @@ func (m *RuntimeClass) MarshalTo(dAtA []byte) (int, error) { i++ i = encodeVarintGenerated(dAtA, i, uint64(len(m.Handler))) i += copy(dAtA[i:], m.Handler) + if m.Topology != nil { + dAtA[i] = 0x1a + i++ + i = encodeVarintGenerated(dAtA, i, uint64(m.Topology.Size())) + n2, err := m.Topology.MarshalTo(dAtA[i:]) + if err != nil { + return 0, err + } + i += n2 + } return i, nil } @@ -109,11 +127,11 @@ func (m *RuntimeClassList) MarshalTo(dAtA []byte) (int, error) { dAtA[i] = 0xa i++ i = encodeVarintGenerated(dAtA, i, uint64(m.ListMeta.Size())) - n2, err := m.ListMeta.MarshalTo(dAtA[i:]) + n3, err := m.ListMeta.MarshalTo(dAtA[i:]) if err != nil { return 0, err } - i += n2 + i += n3 if len(m.Items) > 0 { for _, msg := range m.Items { dAtA[i] = 0x12 @@ -129,6 +147,46 @@ func (m *RuntimeClassList) MarshalTo(dAtA []byte) (int, error) { return i, nil } +func (m *Topology) Marshal() (dAtA []byte, err error) { + size := m.Size() + dAtA = make([]byte, size) + n, err := m.MarshalTo(dAtA) + if err != nil { + return nil, err + } + return dAtA[:n], nil +} + +func (m *Topology) MarshalTo(dAtA []byte) (int, error) { + var i int + _ = i + var l int + _ = l + if m.NodeSelector != nil { + dAtA[i] = 0xa + i++ + i = encodeVarintGenerated(dAtA, i, uint64(m.NodeSelector.Size())) + n4, err := m.NodeSelector.MarshalTo(dAtA[i:]) + if err != nil { + return 0, err + } + i += n4 + } + if len(m.Tolerations) > 0 { + for _, msg := range m.Tolerations { + dAtA[i] = 0x12 + i++ + i = encodeVarintGenerated(dAtA, i, uint64(msg.Size())) + n, err := msg.MarshalTo(dAtA[i:]) + if err != nil { + return 0, err + } + i += n + } + } + return i, nil +} + func encodeVarintGenerated(dAtA []byte, offset int, v uint64) int { for v >= 1<<7 { dAtA[offset] = uint8(v&0x7f | 0x80) @@ -145,6 +203,10 @@ func (m *RuntimeClass) Size() (n int) { n += 1 + l + sovGenerated(uint64(l)) l = len(m.Handler) n += 1 + l + sovGenerated(uint64(l)) + if m.Topology != nil { + l = m.Topology.Size() + n += 1 + l + sovGenerated(uint64(l)) + } return n } @@ -162,6 +224,22 @@ func (m *RuntimeClassList) Size() (n int) { return n } +func (m *Topology) Size() (n int) { + var l int + _ = l + if m.NodeSelector != nil { + l = m.NodeSelector.Size() + n += 1 + l + sovGenerated(uint64(l)) + } + if len(m.Tolerations) > 0 { + for _, e := range m.Tolerations { + l = e.Size() + n += 1 + l + sovGenerated(uint64(l)) + } + } + return n +} + func sovGenerated(x uint64) (n int) { for { n++ @@ -182,6 +260,7 @@ func (this *RuntimeClass) String() string { s := strings.Join([]string{`&RuntimeClass{`, `ObjectMeta:` + strings.Replace(strings.Replace(this.ObjectMeta.String(), "ObjectMeta", "k8s_io_apimachinery_pkg_apis_meta_v1.ObjectMeta", 1), `&`, ``, 1) + `,`, `Handler:` + fmt.Sprintf("%v", this.Handler) + `,`, + `Topology:` + strings.Replace(fmt.Sprintf("%v", this.Topology), "Topology", "Topology", 1) + `,`, `}`, }, "") return s @@ -197,6 +276,17 @@ func (this *RuntimeClassList) String() string { }, "") return s } +func (this *Topology) String() string { + if this == nil { + return "nil" + } + s := strings.Join([]string{`&Topology{`, + `NodeSelector:` + strings.Replace(fmt.Sprintf("%v", this.NodeSelector), "NodeSelector", "k8s_io_api_core_v1.NodeSelector", 1) + `,`, + `Tolerations:` + strings.Replace(strings.Replace(fmt.Sprintf("%v", this.Tolerations), "Toleration", "k8s_io_api_core_v1.Toleration", 1), `&`, ``, 1) + `,`, + `}`, + }, "") + return s +} func valueToStringGenerated(v interface{}) string { rv := reflect.ValueOf(v) if rv.IsNil() { @@ -293,6 +383,39 @@ func (m *RuntimeClass) Unmarshal(dAtA []byte) error { } m.Handler = string(dAtA[iNdEx:postIndex]) iNdEx = postIndex + case 3: + if wireType != 2 { + return fmt.Errorf("proto: wrong wireType = %d for field Topology", wireType) + } + var msglen int + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowGenerated + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + msglen |= (int(b) & 0x7F) << shift + if b < 0x80 { + break + } + } + if msglen < 0 { + return ErrInvalidLengthGenerated + } + postIndex := iNdEx + msglen + if postIndex > l { + return io.ErrUnexpectedEOF + } + if m.Topology == nil { + m.Topology = &Topology{} + } + if err := m.Topology.Unmarshal(dAtA[iNdEx:postIndex]); err != nil { + return err + } + iNdEx = postIndex default: iNdEx = preIndex skippy, err := skipGenerated(dAtA[iNdEx:]) @@ -425,6 +548,120 @@ func (m *RuntimeClassList) Unmarshal(dAtA []byte) error { } return nil } +func (m *Topology) Unmarshal(dAtA []byte) error { + l := len(dAtA) + iNdEx := 0 + for iNdEx < l { + preIndex := iNdEx + var wire uint64 + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowGenerated + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + wire |= (uint64(b) & 0x7F) << shift + if b < 0x80 { + break + } + } + fieldNum := int32(wire >> 3) + wireType := int(wire & 0x7) + if wireType == 4 { + return fmt.Errorf("proto: Topology: wiretype end group for non-group") + } + if fieldNum <= 0 { + return fmt.Errorf("proto: Topology: illegal tag %d (wire type %d)", fieldNum, wire) + } + switch fieldNum { + case 1: + if wireType != 2 { + return fmt.Errorf("proto: wrong wireType = %d for field NodeSelector", wireType) + } + var msglen int + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowGenerated + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + msglen |= (int(b) & 0x7F) << shift + if b < 0x80 { + break + } + } + if msglen < 0 { + return ErrInvalidLengthGenerated + } + postIndex := iNdEx + msglen + if postIndex > l { + return io.ErrUnexpectedEOF + } + if m.NodeSelector == nil { + m.NodeSelector = &k8s_io_api_core_v1.NodeSelector{} + } + if err := m.NodeSelector.Unmarshal(dAtA[iNdEx:postIndex]); err != nil { + return err + } + iNdEx = postIndex + case 2: + if wireType != 2 { + return fmt.Errorf("proto: wrong wireType = %d for field Tolerations", wireType) + } + var msglen int + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowGenerated + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + msglen |= (int(b) & 0x7F) << shift + if b < 0x80 { + break + } + } + if msglen < 0 { + return ErrInvalidLengthGenerated + } + postIndex := iNdEx + msglen + if postIndex > l { + return io.ErrUnexpectedEOF + } + m.Tolerations = append(m.Tolerations, k8s_io_api_core_v1.Toleration{}) + if err := m.Tolerations[len(m.Tolerations)-1].Unmarshal(dAtA[iNdEx:postIndex]); err != nil { + return err + } + iNdEx = postIndex + default: + iNdEx = preIndex + skippy, err := skipGenerated(dAtA[iNdEx:]) + if err != nil { + return err + } + if skippy < 0 { + return ErrInvalidLengthGenerated + } + if (iNdEx + skippy) > l { + return io.ErrUnexpectedEOF + } + iNdEx += skippy + } + } + + if iNdEx > l { + return io.ErrUnexpectedEOF + } + return nil +} func skipGenerated(dAtA []byte) (n int, err error) { l := len(dAtA) iNdEx := 0 @@ -535,30 +772,36 @@ func init() { } var fileDescriptorGenerated = []byte{ - // 389 bytes of a gzipped FileDescriptorProto - 0x1f, 0x8b, 0x08, 0x00, 0x00, 0x00, 0x00, 0x00, 0x02, 0xff, 0x8c, 0x92, 0xcd, 0x6a, 0xdb, 0x40, - 0x14, 0x85, 0x35, 0x2e, 0xc6, 0xae, 0xdc, 0x52, 0xa3, 0x4d, 0x8d, 0x17, 0x63, 0x63, 0x28, 0xb8, - 0x0b, 0xcf, 0xd4, 0xa6, 0x94, 0x2e, 0x8b, 0xba, 0x69, 0x4b, 0x4b, 0x41, 0xcb, 0x90, 0x45, 0x46, - 0xd2, 0x8d, 0x34, 0x91, 0xa5, 0x11, 0x9a, 0x91, 0x20, 0xbb, 0x3c, 0x42, 0xf6, 0x79, 0x95, 0x3c, - 0x80, 0x97, 0x5e, 0x7a, 0x65, 0x62, 0xe5, 0x45, 0x82, 0x7e, 0xfc, 0x43, 0x8c, 0x49, 0x76, 0xba, - 0xe7, 0x9e, 0x73, 0xee, 0x87, 0x18, 0xfd, 0x47, 0xf0, 0x5d, 0x12, 0x2e, 0x68, 0x90, 0xda, 0x90, - 0x44, 0xa0, 0x40, 0xd2, 0x0c, 0x22, 0x57, 0x24, 0xb4, 0x5e, 0xb0, 0x98, 0xd3, 0x48, 0xb8, 0x40, - 0xb3, 0xa9, 0x0d, 0x8a, 0x4d, 0xa9, 0x07, 0x11, 0x24, 0x4c, 0x81, 0x4b, 0xe2, 0x44, 0x28, 0x61, - 0x7c, 0xac, 0x8c, 0x84, 0xc5, 0x9c, 0x14, 0x46, 0x52, 0x1b, 0xfb, 0x13, 0x8f, 0x2b, 0x3f, 0xb5, - 0x89, 0x23, 0x42, 0xea, 0x09, 0x4f, 0xd0, 0xd2, 0x6f, 0xa7, 0x97, 0xe5, 0x54, 0x0e, 0xe5, 0x57, - 0xd5, 0xd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x83, 0xb5, 0xe5, 0x06, 0x6b, 0xab, 0x0d, - 0xd6, 0x6e, 0x72, 0x8c, 0x16, 0x39, 0x46, 0xcb, 0x1c, 0xa3, 0x55, 0x8e, 0xd1, 0x43, 0x8e, 0xd1, - 0xed, 0x23, 0xd6, 0xce, 0x5a, 0x75, 0xe3, 0x53, 0x00, 0x00, 0x00, 0xff, 0xff, 0x93, 0x68, 0xe5, - 0x0d, 0xb5, 0x02, 0x00, 0x00, + // 493 bytes of a gzipped FileDescriptorProto + 0x1f, 0x8b, 0x08, 0x00, 0x00, 0x00, 0x00, 0x00, 0x02, 0xff, 0x8c, 0x52, 0xcf, 0x8e, 0xd3, 0x3e, + 0x18, 0x8c, 0x77, 0xb5, 0x6a, 0x7f, 0x6e, 0x7f, 0xa2, 0x0a, 0x07, 0xaa, 0x1e, 0xdc, 0x52, 0x09, + 0xa9, 0x1c, 0xd6, 0xa6, 0x2b, 0x84, 0x38, 0xa2, 0x70, 0xe1, 0x3f, 0x52, 0x58, 0x38, 0x20, 0x0e, + 0x38, 0xc9, 0x47, 0x1a, 0x9a, 0xc4, 0x51, 0xec, 0x56, 0xda, 0x1b, 0x8f, 0xc0, 0xeb, 0x20, 0xf1, + 0x00, 0x3d, 0xee, 0x71, 0x4f, 0x15, 0x0d, 0x17, 0x1e, 0x03, 0x39, 0x71, 0xd3, 0xb0, 0xbb, 0x15, + 0xdc, 0xf2, 0x8d, 0x67, 0xe6, 0x9b, 0x71, 0x8c, 0x1f, 0xcd, 0x1f, 0x4a, 0x1a, 0x09, 0x36, 0x5f, + 0x78, 0x90, 0xa7, 0xa0, 0x40, 0xb2, 0x25, 0xa4, 0x81, 0xc8, 0x99, 0x39, 0xe0, 0x59, 0xc4, 0x52, + 0x11, 0x00, 0x5b, 0x4e, 0x3d, 0x50, 0x7c, 0xca, 0x42, 0x48, 0x21, 0xe7, 0x0a, 0x02, 0x9a, 0xe5, + 0x42, 0x09, 0xfb, 0x56, 0x45, 0xa4, 0x3c, 0x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 0x1a, 0xa2, 0xd3, 0x2d, + 0xd6, 0xc3, 0xf6, 0x76, 0x72, 0x6b, 0x83, 0xf1, 0x77, 0x84, 0x7b, 0xcd, 0xaa, 0x2f, 0x22, 0xa9, + 0xec, 0x0f, 0x57, 0xea, 0xd2, 0x7f, 0xab, 0xab, 0xd5, 0x65, 0xd9, 0x9e, 0x49, 0xdf, 0xde, 0x22, + 0x8d, 0xaa, 0xcf, 0xf0, 0x51, 0xa4, 0x20, 0x91, 0xfd, 0x83, 0xd1, 0xe1, 0xa4, 0x73, 0x72, 0x67, + 0x6f, 0xf8, 0x66, 0x2e, 0xe7, 0x7f, 0xe3, 0x78, 0xf4, 0x54, 0x6b, 0xdd, 0xca, 0x62, 0xfc, 0x0d, + 0xe1, 0xba, 0x95, 0xfd, 0x0e, 0x77, 0xb5, 0xfe, 0x0d, 0xc4, 0xe0, 0x2b, 0x91, 0x9b, 0xe8, 0xa3, + 0xa6, 0xbf, 0x7e, 0x90, 0x3a, 0xe8, 0xab, 0x06, 0xcf, 0xe9, 0x15, 0xeb, 0x61, 0xb7, 0x89, 0xb8, + 0x7f, 0xf8, 0xd8, 0x6f, 0x71, 0x47, 0x89, 0x58, 0xbf, 0x90, 0x48, 0xa4, 0xdb, 0xd8, 0xe4, 0x3a, + 0xdb, 0xd3, 0x9a, 0xe6, 0xdc, 0x34, 0x79, 0x3b, 0x3b, 0x4c, 0xba, 0x4d, 0x1f, 0xe7, 0x78, 0xb5, + 0x21, 0xd6, 0xf9, 0x86, 0x58, 0x17, 0x1b, 0x62, 0x7d, 0x29, 0x08, 0x5a, 0x15, 0x04, 0x9d, 0x17, + 0x04, 0x5d, 0x14, 0x04, 0xfd, 0x28, 0x08, 0xfa, 0xfa, 0x93, 0x58, 0xef, 0x5b, 0xe6, 0x36, 0x7e, + 0x07, 0x00, 0x00, 0xff, 0xff, 0xcb, 0xb4, 0x5d, 0x60, 0xe2, 0x03, 0x00, 0x00, } diff --git a/staging/src/k8s.io/api/node/v1beta1/generated.proto b/staging/src/k8s.io/api/node/v1beta1/generated.proto index 9082fbd334..ec01723471 100644 --- a/staging/src/k8s.io/api/node/v1beta1/generated.proto +++ b/staging/src/k8s.io/api/node/v1beta1/generated.proto @@ -21,6 +21,7 @@ syntax = 'proto2'; package k8s.io.api.node.v1beta1; +import "k8s.io/api/core/v1/generated.proto"; import "k8s.io/apimachinery/pkg/apis/meta/v1/generated.proto"; import "k8s.io/apimachinery/pkg/runtime/generated.proto"; import "k8s.io/apimachinery/pkg/runtime/schema/generated.proto"; @@ -51,6 +52,15 @@ message RuntimeClass { // The Handler must conform to the DNS Label (RFC 1123) requirements, and is // immutable. optional string handler = 2; + + // Topology describes the set of nodes in the cluster that support this + // RuntimeClass. The rules are applied applied to pods running with this + // RuntimeClass and semantically merged with other scheduling constraints on + // the pod. + // If topology is nil, this RuntimeClass is assumed to be supported by all + // nodes. + // +optional + optional Topology topology = 3; } // RuntimeClassList is a list of RuntimeClass objects. @@ -64,3 +74,21 @@ message RuntimeClassList { repeated RuntimeClass items = 2; } +// Topology specifies the scheduling constraints for nodes supporting a +// RuntimeClass. +message Topology { + // NodeSelector selects the set of nodes that support this RuntimeClass. + // Pods using this RuntimeClass can only be scheduled to a node matched by + // this selector. The NodeSelector is intersected (AND) with a pod's other + // NodeAffinity or NodeSelector requirements. + // A nil NodeSelector selects all nodes. + // +optional + optional k8s.io.api.core.v1.NodeSelector nodeSelector = 1; + + // Tolerations are appended (excluding duplicates) to pods running with this + // RuntimeClass during admission, effectively unioning the set of nodes + // tolerated by the pod and the RuntimeClass. + // +optional + repeated k8s.io.api.core.v1.Toleration tolerations = 2; +} + diff --git a/staging/src/k8s.io/api/node/v1beta1/types_swagger_doc_generated.go b/staging/src/k8s.io/api/node/v1beta1/types_swagger_doc_generated.go index c98957fcc6..3f85eb9472 100644 --- a/staging/src/k8s.io/api/node/v1beta1/types_swagger_doc_generated.go +++ b/staging/src/k8s.io/api/node/v1beta1/types_swagger_doc_generated.go @@ -31,7 +31,7 @@ var map_RuntimeClass = map[string]string{ "": "RuntimeClass defines a class of container runtime supported in the cluster. The RuntimeClass is used to determine which container runtime is used to run all containers in a pod. RuntimeClasses are (currently) manually defined by a user or cluster provisioner, and referenced in the PodSpec. The Kubelet is responsible for resolving the RuntimeClassName reference before running the pod. For more details, see https://git.k8s.io/enhancements/keps/sig-node/runtime-class.md", "metadata": "More info: https://git.k8s.io/community/contributors/devel/api-conventions.md#metadata", "handler": "Handler specifies the underlying runtime and configuration that the CRI implementation will use to handle pods of this class. The possible values are specific to the node & CRI configuration. It is assumed that all handlers are available on every node, and handlers of the same name are equivalent on every node. For example, a handler called \"runc\" might specify that the runc OCI runtime (using native Linux containers) will be used to run the containers in a pod. The Handler must conform to the DNS Label (RFC 1123) requirements, and is immutable.", - "topology": "Topology describes the set of nodes in the cluster that support this RuntimeClass. The rules are applied to the pod during scheduling time. If topology is nil, this RuntimeClass is assumed to be supported by all nodes. pods to the right node", + "topology": "Topology describes the set of nodes in the cluster that support this RuntimeClass. The rules are applied applied to pods running with this RuntimeClass and semantically merged with other scheduling constraints on the pod. If topology is nil, this RuntimeClass is assumed to be supported by all nodes.", } func (RuntimeClass) SwaggerDoc() map[string]string { @@ -50,8 +50,8 @@ func (RuntimeClassList) SwaggerDoc() map[string]string { var map_Topology = map[string]string{ "": "Topology specifies the scheduling constraints for nodes supporting a RuntimeClass.", - "nodeSelector": "nodeSelector selects the set of nodes that support this RuntimeClass. Pods using this RuntimeClass can only be scheduled to a node matched by this selector. The nodeSelector is intersected (AND) with a pod's other node affinity or node selector requirements. A nil nodeSelector selects all nodes.", - "tolerations": "tolerations adds tolerations to pods running with this RuntimeClass. the tolerations are appended (excluding duplicates) to the pod's tolerations during admission.", + "nodeSelector": "NodeSelector selects the set of nodes that support this RuntimeClass. Pods using this RuntimeClass can only be scheduled to a node matched by this selector. The NodeSelector is intersected (AND) with a pod's other NodeAffinity or NodeSelector requirements. A nil NodeSelector selects all nodes.", + "tolerations": "Tolerations are appended (excluding duplicates) to pods running with this RuntimeClass during admission, effectively unioning the set of nodes tolerated by the pod and the RuntimeClass.", } func (Topology) SwaggerDoc() map[string]string { From a7ca6fa728602717f22be6eab95d001b636623b1 Mon Sep 17 00:00:00 2001 From: Yassine TIJANI Date: Thu, 25 Apr 2019 20:50:26 +0200 Subject: [PATCH 6/9] update gofmt --- pkg/apis/node/v1alpha1/conversion.go | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/pkg/apis/node/v1alpha1/conversion.go b/pkg/apis/node/v1alpha1/conversion.go index 7a69b02642..c814af811a 100644 --- a/pkg/apis/node/v1alpha1/conversion.go +++ b/pkg/apis/node/v1alpha1/conversion.go @@ -35,7 +35,7 @@ func Convert_v1alpha1_RuntimeClass_To_node_RuntimeClass(in *v1alpha1.RuntimeClas out.Handler = in.Spec.RuntimeHandler if in.Spec.Topology != nil { out.Topology = new(node.Topology) - autoConvert_v1alpha1_Topology_To_node_Topology(in.Spec.Topology,out.Topology,s) + autoConvert_v1alpha1_Topology_To_node_Topology(in.Spec.Topology, out.Topology, s) } return nil } @@ -45,7 +45,7 @@ func Convert_node_RuntimeClass_To_v1alpha1_RuntimeClass(in *node.RuntimeClass, o out.Spec.RuntimeHandler = in.Handler if in.Topology != nil { out.Spec.Topology = new(v1alpha1.Topology) - autoConvert_node_Topology_To_v1alpha1_Topology(in.Topology,out.Spec.Topology,s) + autoConvert_node_Topology_To_v1alpha1_Topology(in.Topology, out.Spec.Topology, s) } return nil } From d419bdfcd94e4bd2d1218bdcd9461f0f6b810b62 Mon Sep 17 00:00:00 2001 From: Tim Allclair Date: Mon, 6 May 2019 18:38:56 -0700 Subject: [PATCH 7/9] Validate topology --- pkg/apis/node/validation/BUILD | 2 + pkg/apis/node/validation/validation.go | 14 ++++ pkg/apis/node/validation/validation_test.go | 89 +++++++++++++++++++++ 3 files changed, 105 insertions(+) diff --git a/pkg/apis/node/validation/BUILD b/pkg/apis/node/validation/BUILD index 7d7345099d..0633424f1c 100644 --- a/pkg/apis/node/validation/BUILD +++ b/pkg/apis/node/validation/BUILD @@ -6,6 +6,7 @@ go_library( importpath = "k8s.io/kubernetes/pkg/apis/node/validation", visibility = ["//visibility:public"], deps = [ + "//pkg/apis/core/validation:go_default_library", "//pkg/apis/node:go_default_library", "//staging/src/k8s.io/apimachinery/pkg/api/validation:go_default_library", "//staging/src/k8s.io/apimachinery/pkg/util/validation/field:go_default_library", @@ -17,6 +18,7 @@ go_test( srcs = ["validation_test.go"], embed = [":go_default_library"], deps = [ + "//pkg/apis/core:go_default_library", "//pkg/apis/node:go_default_library", "//staging/src/k8s.io/apimachinery/pkg/apis/meta/v1:go_default_library", "//vendor/github.com/stretchr/testify/assert:go_default_library", diff --git a/pkg/apis/node/validation/validation.go b/pkg/apis/node/validation/validation.go index b89a01ff58..a8cc562ed0 100644 --- a/pkg/apis/node/validation/validation.go +++ b/pkg/apis/node/validation/validation.go @@ -19,6 +19,7 @@ package validation import ( apivalidation "k8s.io/apimachinery/pkg/api/validation" "k8s.io/apimachinery/pkg/util/validation/field" + corevalidation "k8s.io/kubernetes/pkg/apis/core/validation" "k8s.io/kubernetes/pkg/apis/node" ) @@ -30,6 +31,10 @@ func ValidateRuntimeClass(rc *node.RuntimeClass) field.ErrorList { allErrs = append(allErrs, field.Invalid(field.NewPath("handler"), rc.Handler, msg)) } + if rc.Topology != nil { + allErrs = append(allErrs, validateTopology(rc.Topology, field.NewPath("topology"))...) + } + return allErrs } @@ -41,3 +46,12 @@ func ValidateRuntimeClassUpdate(new, old *node.RuntimeClass) field.ErrorList { return allErrs } + +func validateTopology(t *node.Topology, fldPath *field.Path) field.ErrorList { + var allErrs field.ErrorList + if t.NodeSelector != nil { + allErrs = append(allErrs, corevalidation.ValidateNodeSelector(t.NodeSelector, fldPath.Child("nodeSelector"))...) + } + allErrs = append(allErrs, corevalidation.ValidateTolerations(t.Tolerations, fldPath.Child("tolerations"))...) + return allErrs +} diff --git a/pkg/apis/node/validation/validation_test.go b/pkg/apis/node/validation/validation_test.go index fcbdc0e9a1..aafe677763 100644 --- a/pkg/apis/node/validation/validation_test.go +++ b/pkg/apis/node/validation/validation_test.go @@ -20,6 +20,7 @@ import ( "testing" metav1 "k8s.io/apimachinery/pkg/apis/meta/v1" + "k8s.io/kubernetes/pkg/apis/core" "k8s.io/kubernetes/pkg/apis/node" "github.com/stretchr/testify/assert" @@ -126,3 +127,91 @@ func TestValidateRuntimeUpdate(t *testing.T) { }) } } + +func TestValidateTopology(t *testing.T) { + tests := []struct { + name string + topology *node.Topology + expectErrs int + }{{ + name: "valid topology", + topology: &node.Topology{ + NodeSelector: &core.NodeSelector{ + NodeSelectorTerms: []core.NodeSelectorTerm{{ + MatchExpressions: []core.NodeSelectorRequirement{{ + Key: "valid", + Operator: core.NodeSelectorOpExists, + }}, + }}, + }, + Tolerations: []core.Toleration{{ + Key: "valid", + Operator: core.TolerationOpExists, + Effect: core.TaintEffectNoSchedule, + }}, + }, + }, { + name: "empty topology", + topology: &node.Topology{}, + }, { + name: "invalid nodeSelector", + topology: &node.Topology{ + NodeSelector: &core.NodeSelector{ + NodeSelectorTerms: []core.NodeSelectorTerm{{ + MatchExpressions: []core.NodeSelectorRequirement{{ + Key: "not a valid key!!!", + Operator: core.NodeSelectorOpExists, + }}, + }}, + }, + }, + expectErrs: 1, + }, { + name: "invalid toleration", + topology: &node.Topology{ + Tolerations: []core.Toleration{{ + Key: "valid", + Operator: core.TolerationOpExists, + Effect: core.TaintEffectNoSchedule, + }, { + Key: "not a valid key!!!", + Operator: core.TolerationOpExists, + Effect: core.TaintEffectNoSchedule, + }}, + }, + expectErrs: 1, + }, { + name: "invalid topology", + topology: &node.Topology{ + NodeSelector: &core.NodeSelector{ + NodeSelectorTerms: []core.NodeSelectorTerm{{ + MatchExpressions: []core.NodeSelectorRequirement{{ + Key: "not a valid label key!!!", + Operator: core.NodeSelectorOpExists, + }}, + }}, + }, + Tolerations: []core.Toleration{{ + Key: "valid", + Operator: core.TolerationOpExists, + Effect: core.TaintEffectNoSchedule, + }, { + Key: "not a valid toleration key!!!", + Operator: core.TolerationOpExists, + Effect: core.TaintEffectNoSchedule, + }}, + }, + expectErrs: 2, + }} + + for _, test := range tests { + t.Run(test.name, func(t *testing.T) { + rc := &node.RuntimeClass{ + ObjectMeta: metav1.ObjectMeta{Name: "foo"}, + Handler: "bar", + Topology: test.topology, + } + assert.Len(t, ValidateRuntimeClass(rc), test.expectErrs) + }) + } +} From 10c514725b1398b166845646168076b27a47f693 Mon Sep 17 00:00:00 2001 From: Tim Allclair Date: Tue, 21 May 2019 18:33:24 -0700 Subject: [PATCH 8/9] Update types from api review --- pkg/apis/node/types.go | 28 +++++------ pkg/apis/node/v1alpha1/conversion.go | 12 ++--- pkg/apis/node/v1alpha1/conversion_test.go | 28 +++-------- pkg/apis/node/validation/validation.go | 13 ++--- pkg/apis/node/validation/validation_test.go | 49 ++++++------------- staging/src/k8s.io/api/node/v1alpha1/types.go | 28 +++++------ staging/src/k8s.io/api/node/v1beta1/types.go | 28 +++++------ 7 files changed, 73 insertions(+), 113 deletions(-) diff --git a/pkg/apis/node/types.go b/pkg/apis/node/types.go index 0bf1808578..cebc555577 100644 --- a/pkg/apis/node/types.go +++ b/pkg/apis/node/types.go @@ -47,28 +47,26 @@ type RuntimeClass struct { // immutable. Handler string - // Topology describes the set of nodes in the cluster that support this - // RuntimeClass. The rules are applied applied to pods running with this - // RuntimeClass and semantically merged with other scheduling constraints on - // the pod. - // If topology is nil, this RuntimeClass is assumed to be supported by all + // Scheduling holds the scheduling constraints to ensure that pods running + // with this RuntimeClass are scheduled to nodes that support it. + // If scheduling is nil, this RuntimeClass is assumed to be supported by all // nodes. // +optional - Topology *Topology + Scheduling *Scheduling } -// Topology specifies the scheduling constraints for nodes supporting a +// Scheduling specifies the scheduling constraints for nodes supporting a // RuntimeClass. -type Topology struct { - // NodeSelector selects the set of nodes that support this RuntimeClass. - // Pods using this RuntimeClass can only be scheduled to a node matched by - // this selector. The NodeSelector is intersected (AND) with a pod's other - // NodeAffinity or NodeSelector requirements. - // A nil NodeSelector selects all nodes. +type Scheduling struct { + // nodeSelector lists labels that must be present on nodes that support this + // RuntimeClass. Pods using this RuntimeClass can only be scheduled to a + // node matched by this selector. The RuntimeClass nodeSelector is merged + // with a pod's existing nodeSelector. Any conflicts will cause the pod to + // be rejected in admission. // +optional - NodeSelector *core.NodeSelector + NodeSelector map[string]string - // Tolerations are appended (excluding duplicates) to pods running with this + // tolerations are appended (excluding duplicates) to pods running with this // RuntimeClass during admission, effectively unioning the set of nodes // tolerated by the pod and the RuntimeClass. // +optional diff --git a/pkg/apis/node/v1alpha1/conversion.go b/pkg/apis/node/v1alpha1/conversion.go index c814af811a..bbf499bed9 100644 --- a/pkg/apis/node/v1alpha1/conversion.go +++ b/pkg/apis/node/v1alpha1/conversion.go @@ -33,9 +33,9 @@ func addConversionFuncs(s *runtime.Scheme) error { func Convert_v1alpha1_RuntimeClass_To_node_RuntimeClass(in *v1alpha1.RuntimeClass, out *node.RuntimeClass, s conversion.Scope) error { out.ObjectMeta = in.ObjectMeta out.Handler = in.Spec.RuntimeHandler - if in.Spec.Topology != nil { - out.Topology = new(node.Topology) - autoConvert_v1alpha1_Topology_To_node_Topology(in.Spec.Topology, out.Topology, s) + if in.Spec.Scheduling != nil { + out.Scheduling = new(node.Scheduling) + autoConvert_v1alpha1_Scheduling_To_node_Scheduling(in.Spec.Scheduling, out.Scheduling, s) } return nil } @@ -43,9 +43,9 @@ func Convert_v1alpha1_RuntimeClass_To_node_RuntimeClass(in *v1alpha1.RuntimeClas func Convert_node_RuntimeClass_To_v1alpha1_RuntimeClass(in *node.RuntimeClass, out *v1alpha1.RuntimeClass, s conversion.Scope) error { out.ObjectMeta = in.ObjectMeta out.Spec.RuntimeHandler = in.Handler - if in.Topology != nil { - out.Spec.Topology = new(v1alpha1.Topology) - autoConvert_node_Topology_To_v1alpha1_Topology(in.Topology, out.Spec.Topology, s) + if in.Scheduling != nil { + out.Spec.Scheduling = new(v1alpha1.Scheduling) + autoConvert_node_Scheduling_To_v1alpha1_Scheduling(in.Scheduling, out.Spec.Scheduling, s) } return nil } diff --git a/pkg/apis/node/v1alpha1/conversion_test.go b/pkg/apis/node/v1alpha1/conversion_test.go index 124643820f..62dd0986e8 100644 --- a/pkg/apis/node/v1alpha1/conversion_test.go +++ b/pkg/apis/node/v1alpha1/conversion_test.go @@ -41,15 +41,8 @@ func TestRuntimeClassConversion(t *testing.T) { internal: &node.RuntimeClass{ ObjectMeta: metav1.ObjectMeta{Name: name}, Handler: handler, - Topology: &node.Topology{ - NodeSelector: &core.NodeSelector{ - NodeSelectorTerms: []core.NodeSelectorTerm{{ - MatchExpressions: []core.NodeSelectorRequirement{{ - Key: "extra-soft", - Operator: core.NodeSelectorOpExists, - }}, - }}, - }, + Scheduling: &node.Scheduling{ + NodeSelector: map[string]string{"extra-soft": "true"}, Tolerations: []core.Toleration{{ Key: "stinky", Operator: core.TolerationOpExists, @@ -61,15 +54,8 @@ func TestRuntimeClassConversion(t *testing.T) { ObjectMeta: metav1.ObjectMeta{Name: name}, Spec: v1alpha1.RuntimeClassSpec{ RuntimeHandler: handler, - Topology: &v1alpha1.Topology{ - NodeSelector: &corev1.NodeSelector{ - NodeSelectorTerms: []corev1.NodeSelectorTerm{{ - MatchExpressions: []corev1.NodeSelectorRequirement{{ - Key: "extra-soft", - Operator: corev1.NodeSelectorOpExists, - }}, - }}, - }, + Scheduling: &v1alpha1.Scheduling{ + NodeSelector: map[string]string{"extra-soft": "true"}, Tolerations: []corev1.Toleration{{ Key: "stinky", Operator: corev1.TolerationOpExists, @@ -79,17 +65,17 @@ func TestRuntimeClassConversion(t *testing.T) { }, }, }, - "empty-topology": { + "empty-scheduling": { internal: &node.RuntimeClass{ ObjectMeta: metav1.ObjectMeta{Name: name}, Handler: handler, - Topology: &node.Topology{}, + Scheduling: &node.Scheduling{}, }, external: &v1alpha1.RuntimeClass{ ObjectMeta: metav1.ObjectMeta{Name: name}, Spec: v1alpha1.RuntimeClassSpec{ RuntimeHandler: handler, - Topology: &v1alpha1.Topology{}, + Scheduling: &v1alpha1.Scheduling{}, }, }, }, diff --git a/pkg/apis/node/validation/validation.go b/pkg/apis/node/validation/validation.go index a8cc562ed0..b5a22c9bd4 100644 --- a/pkg/apis/node/validation/validation.go +++ b/pkg/apis/node/validation/validation.go @@ -18,6 +18,7 @@ package validation import ( apivalidation "k8s.io/apimachinery/pkg/api/validation" + unversionedvalidation "k8s.io/apimachinery/pkg/apis/meta/v1/validation" "k8s.io/apimachinery/pkg/util/validation/field" corevalidation "k8s.io/kubernetes/pkg/apis/core/validation" "k8s.io/kubernetes/pkg/apis/node" @@ -31,8 +32,8 @@ func ValidateRuntimeClass(rc *node.RuntimeClass) field.ErrorList { allErrs = append(allErrs, field.Invalid(field.NewPath("handler"), rc.Handler, msg)) } - if rc.Topology != nil { - allErrs = append(allErrs, validateTopology(rc.Topology, field.NewPath("topology"))...) + if rc.Scheduling != nil { + allErrs = append(allErrs, validateScheduling(rc.Scheduling, field.NewPath("scheduling"))...) } return allErrs @@ -47,11 +48,11 @@ func ValidateRuntimeClassUpdate(new, old *node.RuntimeClass) field.ErrorList { return allErrs } -func validateTopology(t *node.Topology, fldPath *field.Path) field.ErrorList { +func validateScheduling(s *node.Scheduling, fldPath *field.Path) field.ErrorList { var allErrs field.ErrorList - if t.NodeSelector != nil { - allErrs = append(allErrs, corevalidation.ValidateNodeSelector(t.NodeSelector, fldPath.Child("nodeSelector"))...) + if s.NodeSelector != nil { + allErrs = append(allErrs, unversionedvalidation.ValidateLabels(s.NodeSelector, fldPath.Child("nodeSelector"))...) } - allErrs = append(allErrs, corevalidation.ValidateTolerations(t.Tolerations, fldPath.Child("tolerations"))...) + allErrs = append(allErrs, corevalidation.ValidateTolerations(s.Tolerations, fldPath.Child("tolerations"))...) return allErrs } diff --git a/pkg/apis/node/validation/validation_test.go b/pkg/apis/node/validation/validation_test.go index aafe677763..1e27602ed4 100644 --- a/pkg/apis/node/validation/validation_test.go +++ b/pkg/apis/node/validation/validation_test.go @@ -128,22 +128,15 @@ func TestValidateRuntimeUpdate(t *testing.T) { } } -func TestValidateTopology(t *testing.T) { +func TestValidateScheduling(t *testing.T) { tests := []struct { name string - topology *node.Topology + scheduling *node.Scheduling expectErrs int }{{ - name: "valid topology", - topology: &node.Topology{ - NodeSelector: &core.NodeSelector{ - NodeSelectorTerms: []core.NodeSelectorTerm{{ - MatchExpressions: []core.NodeSelectorRequirement{{ - Key: "valid", - Operator: core.NodeSelectorOpExists, - }}, - }}, - }, + name: "valid scheduling", + scheduling: &node.Scheduling{ + NodeSelector: map[string]string{"valid": "yes"}, Tolerations: []core.Toleration{{ Key: "valid", Operator: core.TolerationOpExists, @@ -151,24 +144,17 @@ func TestValidateTopology(t *testing.T) { }}, }, }, { - name: "empty topology", - topology: &node.Topology{}, + name: "empty scheduling", + scheduling: &node.Scheduling{}, }, { name: "invalid nodeSelector", - topology: &node.Topology{ - NodeSelector: &core.NodeSelector{ - NodeSelectorTerms: []core.NodeSelectorTerm{{ - MatchExpressions: []core.NodeSelectorRequirement{{ - Key: "not a valid key!!!", - Operator: core.NodeSelectorOpExists, - }}, - }}, - }, + scheduling: &node.Scheduling{ + NodeSelector: map[string]string{"not a valid key!!!": "nope"}, }, expectErrs: 1, }, { name: "invalid toleration", - topology: &node.Topology{ + scheduling: &node.Scheduling{ Tolerations: []core.Toleration{{ Key: "valid", Operator: core.TolerationOpExists, @@ -181,16 +167,9 @@ func TestValidateTopology(t *testing.T) { }, expectErrs: 1, }, { - name: "invalid topology", - topology: &node.Topology{ - NodeSelector: &core.NodeSelector{ - NodeSelectorTerms: []core.NodeSelectorTerm{{ - MatchExpressions: []core.NodeSelectorRequirement{{ - Key: "not a valid label key!!!", - Operator: core.NodeSelectorOpExists, - }}, - }}, - }, + name: "invalid scheduling", + scheduling: &node.Scheduling{ + NodeSelector: map[string]string{"not a valid key!!!": "nope"}, Tolerations: []core.Toleration{{ Key: "valid", Operator: core.TolerationOpExists, @@ -209,7 +188,7 @@ func TestValidateTopology(t *testing.T) { rc := &node.RuntimeClass{ ObjectMeta: metav1.ObjectMeta{Name: "foo"}, Handler: "bar", - Topology: test.topology, + Scheduling: test.scheduling, } assert.Len(t, ValidateRuntimeClass(rc), test.expectErrs) }) diff --git a/staging/src/k8s.io/api/node/v1alpha1/types.go b/staging/src/k8s.io/api/node/v1alpha1/types.go index e061335d4c..9807acb323 100644 --- a/staging/src/k8s.io/api/node/v1alpha1/types.go +++ b/staging/src/k8s.io/api/node/v1alpha1/types.go @@ -60,28 +60,26 @@ type RuntimeClassSpec struct { // and is immutable. RuntimeHandler string `json:"runtimeHandler" protobuf:"bytes,1,opt,name=runtimeHandler"` - // Topology describes the set of nodes in the cluster that support this - // RuntimeClass. The rules are applied applied to pods running with this - // RuntimeClass and semantically merged with other scheduling constraints on - // the pod. - // If topology is nil, this RuntimeClass is assumed to be supported by all + // Scheduling holds the scheduling constraints to ensure that pods running + // with this RuntimeClass are scheduled to nodes that support it. + // If scheduling is nil, this RuntimeClass is assumed to be supported by all // nodes. // +optional - Topology *Topology `json:"topology,omitempty" protobuf:"bytes,3,opt,name=topology"` + Scheduling *Scheduling `json:"scheduling,omitempty" protobuf:"bytes,3,opt,name=scheduling"` } -// Topology specifies the scheduling constraints for nodes supporting a +// Scheduling specifies the scheduling constraints for nodes supporting a // RuntimeClass. -type Topology struct { - // NodeSelector selects the set of nodes that support this RuntimeClass. - // Pods using this RuntimeClass can only be scheduled to a node matched by - // this selector. The NodeSelector is intersected (AND) with a pod's other - // NodeAffinity or NodeSelector requirements. - // A nil NodeSelector selects all nodes. +type Scheduling struct { + // nodeSelector lists labels that must be present on nodes that support this + // RuntimeClass. Pods using this RuntimeClass can only be scheduled to a + // node matched by this selector. The RuntimeClass nodeSelector is merged + // with a pod's existing nodeSelector. Any conflicts will cause the pod to + // be rejected in admission. // +optional - NodeSelector *v1.NodeSelector `json:"nodeSelector,omitempty" protobuf:"bytes,1,opt,name=nodeSelector"` + NodeSelector map[string]string `json:"nodeSelector,omitempty" protobuf:"bytes,1,opt,name=nodeSelector"` - // Tolerations are appended (excluding duplicates) to pods running with this + // tolerations are appended (excluding duplicates) to pods running with this // RuntimeClass during admission, effectively unioning the set of nodes // tolerated by the pod and the RuntimeClass. // +optional diff --git a/staging/src/k8s.io/api/node/v1beta1/types.go b/staging/src/k8s.io/api/node/v1beta1/types.go index 8d65785803..e437580d35 100644 --- a/staging/src/k8s.io/api/node/v1beta1/types.go +++ b/staging/src/k8s.io/api/node/v1beta1/types.go @@ -50,28 +50,26 @@ type RuntimeClass struct { // immutable. Handler string `json:"handler" protobuf:"bytes,2,opt,name=handler"` - // Topology describes the set of nodes in the cluster that support this - // RuntimeClass. The rules are applied applied to pods running with this - // RuntimeClass and semantically merged with other scheduling constraints on - // the pod. - // If topology is nil, this RuntimeClass is assumed to be supported by all + // Scheduling holds the scheduling constraints to ensure that pods running + // with this RuntimeClass are scheduled to nodes that support it. + // If scheduling is nil, this RuntimeClass is assumed to be supported by all // nodes. // +optional - Topology *Topology `json:"topology,omitempty" protobuf:"bytes,3,opt,name=topology"` + Scheduling *Scheduling `json:"scheduling,omitempty" protobuf:"bytes,3,opt,name=scheduling"` } -// Topology specifies the scheduling constraints for nodes supporting a +// Scheduling specifies the scheduling constraints for nodes supporting a // RuntimeClass. -type Topology struct { - // NodeSelector selects the set of nodes that support this RuntimeClass. - // Pods using this RuntimeClass can only be scheduled to a node matched by - // this selector. The NodeSelector is intersected (AND) with a pod's other - // NodeAffinity or NodeSelector requirements. - // A nil NodeSelector selects all nodes. +type Scheduling struct { + // nodeSelector lists labels that must be present on nodes that support this + // RuntimeClass. Pods using this RuntimeClass can only be scheduled to a + // node matched by this selector. The RuntimeClass nodeSelector is merged + // with a pod's existing nodeSelector. Any conflicts will cause the pod to + // be rejected in admission. // +optional - NodeSelector *v1.NodeSelector `json:"nodeSelector,omitempty" protobuf:"bytes,1,opt,name=nodeSelector"` + NodeSelector map[string]string `json:"nodeSelector,omitempty" protobuf:"bytes,1,opt,name=nodeSelector"` - // Tolerations are appended (excluding duplicates) to pods running with this + // tolerations are appended (excluding duplicates) to pods running with this // RuntimeClass during admission, effectively unioning the set of nodes // tolerated by the pod and the RuntimeClass. // +optional From 2e384858f037dab1e301a121358111e6aae57614 Mon Sep 17 00:00:00 2001 From: Tim Allclair Date: Tue, 21 May 2019 18:33:34 -0700 Subject: [PATCH 9/9] regenerate --- api/openapi-spec/swagger.json | 38 +-- .../node/v1alpha1/zz_generated.conversion.go | 30 +- .../node/v1beta1/zz_generated.conversion.go | 32 +-- pkg/apis/node/validation/BUILD | 1 + pkg/apis/node/zz_generated.deepcopy.go | 20 +- staging/src/k8s.io/api/node/v1alpha1/BUILD | 1 + .../k8s.io/api/node/v1alpha1/generated.pb.go | 260 +++++++++++++----- .../k8s.io/api/node/v1alpha1/generated.proto | 28 +- .../v1alpha1/types_swagger_doc_generated.go | 14 +- .../node/v1alpha1/zz_generated.deepcopy.go | 20 +- staging/src/k8s.io/api/node/v1beta1/BUILD | 1 + .../k8s.io/api/node/v1beta1/generated.pb.go | 256 ++++++++++++----- .../k8s.io/api/node/v1beta1/generated.proto | 28 +- .../v1beta1/types_swagger_doc_generated.go | 20 +- .../api/node/v1beta1/zz_generated.deepcopy.go | 20 +- 15 files changed, 506 insertions(+), 263 deletions(-) diff --git a/api/openapi-spec/swagger.json b/api/openapi-spec/swagger.json index 5904d8a8ae..f5c930920e 100644 --- a/api/openapi-spec/swagger.json +++ b/api/openapi-spec/swagger.json @@ -13281,9 +13281,9 @@ "description": "RuntimeHandler specifies the underlying runtime and configuration that the CRI implementation will use to handle pods of this class. The possible values are specific to the node & CRI configuration. It is assumed that all handlers are available on every node, and handlers of the same name are equivalent on every node. For example, a handler called \"runc\" might specify that the runc OCI runtime (using native Linux containers) will be used to run the containers in a pod. The RuntimeHandler must conform to the DNS Label (RFC 1123) requirements and is immutable.", "type": "string" }, - "topology": { - "$ref": "#/definitions/io.k8s.api.node.v1alpha1.Topology", - "description": "Topology describes the set of nodes in the cluster that support this RuntimeClass. The rules are applied applied to pods running with this RuntimeClass and semantically merged with other scheduling constraints on the pod. If topology is nil, this RuntimeClass is assumed to be supported by all nodes." + "scheduling": { + "$ref": "#/definitions/io.k8s.api.node.v1alpha1.Scheduling", + "description": "Scheduling holds the scheduling constraints to ensure that pods running with this RuntimeClass are scheduled to nodes that support it. If scheduling is nil, this RuntimeClass is assumed to be supported by all nodes." } }, "required": [ @@ -13291,15 +13291,18 @@ ], "type": "object" }, - "io.k8s.api.node.v1alpha1.Topology": { - "description": "Topology specifies the scheduling constraints for nodes supporting a RuntimeClass.", + "io.k8s.api.node.v1alpha1.Scheduling": { + "description": "Scheduling specifies the scheduling constraints for nodes supporting a RuntimeClass.", "properties": { "nodeSelector": { - "$ref": "#/definitions/io.k8s.api.core.v1.NodeSelector", - "description": "NodeSelector selects the set of nodes that support this RuntimeClass. Pods using this RuntimeClass can only be scheduled to a node matched by this selector. The NodeSelector is intersected (AND) with a pod's other NodeAffinity or NodeSelector requirements. A nil NodeSelector selects all nodes." + "additionalProperties": { + "type": "string" + }, + "description": "nodeSelector lists labels that must be present on nodes that support this RuntimeClass. Pods using this RuntimeClass can only be scheduled to a node matched by this selector. The RuntimeClass nodeSelector is merged with a pod's existing nodeSelector. Any conflicts will cause the pod to be rejected in admission.", + "type": "object" }, "tolerations": { - "description": "Tolerations are appended (excluding duplicates) to pods running with this RuntimeClass during admission, effectively unioning the set of nodes tolerated by the pod and the RuntimeClass.", + "description": "tolerations are appended (excluding duplicates) to pods running with this RuntimeClass during admission, effectively unioning the set of nodes tolerated by the pod and the RuntimeClass.", "items": { "$ref": "#/definitions/io.k8s.api.core.v1.Toleration" }, @@ -13327,9 +13330,9 @@ "$ref": "#/definitions/io.k8s.apimachinery.pkg.apis.meta.v1.ObjectMeta", "description": "More info: https://git.k8s.io/community/contributors/devel/api-conventions.md#metadata" }, - "topology": { - "$ref": "#/definitions/io.k8s.api.node.v1beta1.Topology", - "description": "Topology describes the set of nodes in the cluster that support this RuntimeClass. The rules are applied applied to pods running with this RuntimeClass and semantically merged with other scheduling constraints on the pod. If topology is nil, this RuntimeClass is assumed to be supported by all nodes." + "scheduling": { + "$ref": "#/definitions/io.k8s.api.node.v1beta1.Scheduling", + "description": "Scheduling holds the scheduling constraints to ensure that pods running with this RuntimeClass are scheduled to nodes that support it. If scheduling is nil, this RuntimeClass is assumed to be supported by all nodes." } }, "required": [ @@ -13379,15 +13382,18 @@ } ] }, - "io.k8s.api.node.v1beta1.Topology": { - "description": "Topology specifies the scheduling constraints for nodes supporting a RuntimeClass.", + "io.k8s.api.node.v1beta1.Scheduling": { + "description": "Scheduling specifies the scheduling constraints for nodes supporting a RuntimeClass.", "properties": { "nodeSelector": { - "$ref": "#/definitions/io.k8s.api.core.v1.NodeSelector", - "description": "NodeSelector selects the set of nodes that support this RuntimeClass. Pods using this RuntimeClass can only be scheduled to a node matched by this selector. The NodeSelector is intersected (AND) with a pod's other NodeAffinity or NodeSelector requirements. A nil NodeSelector selects all nodes." + "additionalProperties": { + "type": "string" + }, + "description": "nodeSelector lists labels that must be present on nodes that support this RuntimeClass. Pods using this RuntimeClass can only be scheduled to a node matched by this selector. The RuntimeClass nodeSelector is merged with a pod's existing nodeSelector. Any conflicts will cause the pod to be rejected in admission.", + "type": "object" }, "tolerations": { - "description": "Tolerations are appended (excluding duplicates) to pods running with this RuntimeClass during admission, effectively unioning the set of nodes tolerated by the pod and the RuntimeClass.", + "description": "tolerations are appended (excluding duplicates) to pods running with this RuntimeClass during admission, effectively unioning the set of nodes tolerated by the pod and the RuntimeClass.", "items": { "$ref": "#/definitions/io.k8s.api.core.v1.Toleration" }, diff --git a/pkg/apis/node/v1alpha1/zz_generated.conversion.go b/pkg/apis/node/v1alpha1/zz_generated.conversion.go index c7c602f990..f4c4804d54 100644 --- a/pkg/apis/node/v1alpha1/zz_generated.conversion.go +++ b/pkg/apis/node/v1alpha1/zz_generated.conversion.go @@ -58,13 +58,13 @@ func RegisterConversions(s *runtime.Scheme) error { }); err != nil { return err } - if err := s.AddGeneratedConversionFunc((*v1alpha1.Topology)(nil), (*node.Topology)(nil), func(a, b interface{}, scope conversion.Scope) error { - return Convert_v1alpha1_Topology_To_node_Topology(a.(*v1alpha1.Topology), b.(*node.Topology), scope) + if err := s.AddGeneratedConversionFunc((*v1alpha1.Scheduling)(nil), (*node.Scheduling)(nil), func(a, b interface{}, scope conversion.Scope) error { + return Convert_v1alpha1_Scheduling_To_node_Scheduling(a.(*v1alpha1.Scheduling), b.(*node.Scheduling), scope) }); err != nil { return err } - if err := s.AddGeneratedConversionFunc((*node.Topology)(nil), (*v1alpha1.Topology)(nil), func(a, b interface{}, scope conversion.Scope) error { - return Convert_node_Topology_To_v1alpha1_Topology(a.(*node.Topology), b.(*v1alpha1.Topology), scope) + if err := s.AddGeneratedConversionFunc((*node.Scheduling)(nil), (*v1alpha1.Scheduling)(nil), func(a, b interface{}, scope conversion.Scope) error { + return Convert_node_Scheduling_To_v1alpha1_Scheduling(a.(*node.Scheduling), b.(*v1alpha1.Scheduling), scope) }); err != nil { return err } @@ -90,7 +90,7 @@ func autoConvert_v1alpha1_RuntimeClass_To_node_RuntimeClass(in *v1alpha1.Runtime func autoConvert_node_RuntimeClass_To_v1alpha1_RuntimeClass(in *node.RuntimeClass, out *v1alpha1.RuntimeClass, s conversion.Scope) error { out.ObjectMeta = in.ObjectMeta // WARNING: in.Handler requires manual conversion: does not exist in peer-type - // WARNING: in.Topology requires manual conversion: does not exist in peer-type + // WARNING: in.Scheduling requires manual conversion: does not exist in peer-type return nil } @@ -136,24 +136,24 @@ func Convert_node_RuntimeClassList_To_v1alpha1_RuntimeClassList(in *node.Runtime return autoConvert_node_RuntimeClassList_To_v1alpha1_RuntimeClassList(in, out, s) } -func autoConvert_v1alpha1_Topology_To_node_Topology(in *v1alpha1.Topology, out *node.Topology, s conversion.Scope) error { - out.NodeSelector = (*core.NodeSelector)(unsafe.Pointer(in.NodeSelector)) +func autoConvert_v1alpha1_Scheduling_To_node_Scheduling(in *v1alpha1.Scheduling, out *node.Scheduling, s conversion.Scope) error { + out.NodeSelector = *(*map[string]string)(unsafe.Pointer(&in.NodeSelector)) out.Tolerations = *(*[]core.Toleration)(unsafe.Pointer(&in.Tolerations)) return nil } -// Convert_v1alpha1_Topology_To_node_Topology is an autogenerated conversion function. -func Convert_v1alpha1_Topology_To_node_Topology(in *v1alpha1.Topology, out *node.Topology, s conversion.Scope) error { - return autoConvert_v1alpha1_Topology_To_node_Topology(in, out, s) +// Convert_v1alpha1_Scheduling_To_node_Scheduling is an autogenerated conversion function. +func Convert_v1alpha1_Scheduling_To_node_Scheduling(in *v1alpha1.Scheduling, out *node.Scheduling, s conversion.Scope) error { + return autoConvert_v1alpha1_Scheduling_To_node_Scheduling(in, out, s) } -func autoConvert_node_Topology_To_v1alpha1_Topology(in *node.Topology, out *v1alpha1.Topology, s conversion.Scope) error { - out.NodeSelector = (*v1.NodeSelector)(unsafe.Pointer(in.NodeSelector)) +func autoConvert_node_Scheduling_To_v1alpha1_Scheduling(in *node.Scheduling, out *v1alpha1.Scheduling, s conversion.Scope) error { + out.NodeSelector = *(*map[string]string)(unsafe.Pointer(&in.NodeSelector)) out.Tolerations = *(*[]v1.Toleration)(unsafe.Pointer(&in.Tolerations)) return nil } -// Convert_node_Topology_To_v1alpha1_Topology is an autogenerated conversion function. -func Convert_node_Topology_To_v1alpha1_Topology(in *node.Topology, out *v1alpha1.Topology, s conversion.Scope) error { - return autoConvert_node_Topology_To_v1alpha1_Topology(in, out, s) +// Convert_node_Scheduling_To_v1alpha1_Scheduling is an autogenerated conversion function. +func Convert_node_Scheduling_To_v1alpha1_Scheduling(in *node.Scheduling, out *v1alpha1.Scheduling, s conversion.Scope) error { + return autoConvert_node_Scheduling_To_v1alpha1_Scheduling(in, out, s) } diff --git a/pkg/apis/node/v1beta1/zz_generated.conversion.go b/pkg/apis/node/v1beta1/zz_generated.conversion.go index 8ab2ab3be6..35f23db576 100644 --- a/pkg/apis/node/v1beta1/zz_generated.conversion.go +++ b/pkg/apis/node/v1beta1/zz_generated.conversion.go @@ -58,13 +58,13 @@ func RegisterConversions(s *runtime.Scheme) error { }); err != nil { return err } - if err := s.AddGeneratedConversionFunc((*v1beta1.Topology)(nil), (*node.Topology)(nil), func(a, b interface{}, scope conversion.Scope) error { - return Convert_v1beta1_Topology_To_node_Topology(a.(*v1beta1.Topology), b.(*node.Topology), scope) + if err := s.AddGeneratedConversionFunc((*v1beta1.Scheduling)(nil), (*node.Scheduling)(nil), func(a, b interface{}, scope conversion.Scope) error { + return Convert_v1beta1_Scheduling_To_node_Scheduling(a.(*v1beta1.Scheduling), b.(*node.Scheduling), scope) }); err != nil { return err } - if err := s.AddGeneratedConversionFunc((*node.Topology)(nil), (*v1beta1.Topology)(nil), func(a, b interface{}, scope conversion.Scope) error { - return Convert_node_Topology_To_v1beta1_Topology(a.(*node.Topology), b.(*v1beta1.Topology), scope) + if err := s.AddGeneratedConversionFunc((*node.Scheduling)(nil), (*v1beta1.Scheduling)(nil), func(a, b interface{}, scope conversion.Scope) error { + return Convert_node_Scheduling_To_v1beta1_Scheduling(a.(*node.Scheduling), b.(*v1beta1.Scheduling), scope) }); err != nil { return err } @@ -74,7 +74,7 @@ func RegisterConversions(s *runtime.Scheme) error { func autoConvert_v1beta1_RuntimeClass_To_node_RuntimeClass(in *v1beta1.RuntimeClass, out *node.RuntimeClass, s conversion.Scope) error { out.ObjectMeta = in.ObjectMeta out.Handler = in.Handler - out.Topology = (*node.Topology)(unsafe.Pointer(in.Topology)) + out.Scheduling = (*node.Scheduling)(unsafe.Pointer(in.Scheduling)) return nil } @@ -86,7 +86,7 @@ func Convert_v1beta1_RuntimeClass_To_node_RuntimeClass(in *v1beta1.RuntimeClass, func autoConvert_node_RuntimeClass_To_v1beta1_RuntimeClass(in *node.RuntimeClass, out *v1beta1.RuntimeClass, s conversion.Scope) error { out.ObjectMeta = in.ObjectMeta out.Handler = in.Handler - out.Topology = (*v1beta1.Topology)(unsafe.Pointer(in.Topology)) + out.Scheduling = (*v1beta1.Scheduling)(unsafe.Pointer(in.Scheduling)) return nil } @@ -117,24 +117,24 @@ func Convert_node_RuntimeClassList_To_v1beta1_RuntimeClassList(in *node.RuntimeC return autoConvert_node_RuntimeClassList_To_v1beta1_RuntimeClassList(in, out, s) } -func autoConvert_v1beta1_Topology_To_node_Topology(in *v1beta1.Topology, out *node.Topology, s conversion.Scope) error { - out.NodeSelector = (*core.NodeSelector)(unsafe.Pointer(in.NodeSelector)) +func autoConvert_v1beta1_Scheduling_To_node_Scheduling(in *v1beta1.Scheduling, out *node.Scheduling, s conversion.Scope) error { + out.NodeSelector = *(*map[string]string)(unsafe.Pointer(&in.NodeSelector)) out.Tolerations = *(*[]core.Toleration)(unsafe.Pointer(&in.Tolerations)) return nil } -// Convert_v1beta1_Topology_To_node_Topology is an autogenerated conversion function. -func Convert_v1beta1_Topology_To_node_Topology(in *v1beta1.Topology, out *node.Topology, s conversion.Scope) error { - return autoConvert_v1beta1_Topology_To_node_Topology(in, out, s) +// Convert_v1beta1_Scheduling_To_node_Scheduling is an autogenerated conversion function. +func Convert_v1beta1_Scheduling_To_node_Scheduling(in *v1beta1.Scheduling, out *node.Scheduling, s conversion.Scope) error { + return autoConvert_v1beta1_Scheduling_To_node_Scheduling(in, out, s) } -func autoConvert_node_Topology_To_v1beta1_Topology(in *node.Topology, out *v1beta1.Topology, s conversion.Scope) error { - out.NodeSelector = (*v1.NodeSelector)(unsafe.Pointer(in.NodeSelector)) +func autoConvert_node_Scheduling_To_v1beta1_Scheduling(in *node.Scheduling, out *v1beta1.Scheduling, s conversion.Scope) error { + out.NodeSelector = *(*map[string]string)(unsafe.Pointer(&in.NodeSelector)) out.Tolerations = *(*[]v1.Toleration)(unsafe.Pointer(&in.Tolerations)) return nil } -// Convert_node_Topology_To_v1beta1_Topology is an autogenerated conversion function. -func Convert_node_Topology_To_v1beta1_Topology(in *node.Topology, out *v1beta1.Topology, s conversion.Scope) error { - return autoConvert_node_Topology_To_v1beta1_Topology(in, out, s) +// Convert_node_Scheduling_To_v1beta1_Scheduling is an autogenerated conversion function. +func Convert_node_Scheduling_To_v1beta1_Scheduling(in *node.Scheduling, out *v1beta1.Scheduling, s conversion.Scope) error { + return autoConvert_node_Scheduling_To_v1beta1_Scheduling(in, out, s) } diff --git a/pkg/apis/node/validation/BUILD b/pkg/apis/node/validation/BUILD index 0633424f1c..6e28a9229b 100644 --- a/pkg/apis/node/validation/BUILD +++ b/pkg/apis/node/validation/BUILD @@ -9,6 +9,7 @@ go_library( "//pkg/apis/core/validation:go_default_library", "//pkg/apis/node:go_default_library", "//staging/src/k8s.io/apimachinery/pkg/api/validation:go_default_library", + "//staging/src/k8s.io/apimachinery/pkg/apis/meta/v1/validation:go_default_library", "//staging/src/k8s.io/apimachinery/pkg/util/validation/field:go_default_library", ], ) diff --git a/pkg/apis/node/zz_generated.deepcopy.go b/pkg/apis/node/zz_generated.deepcopy.go index 11349c9d1d..d1c2f92110 100644 --- a/pkg/apis/node/zz_generated.deepcopy.go +++ b/pkg/apis/node/zz_generated.deepcopy.go @@ -30,9 +30,9 @@ func (in *RuntimeClass) DeepCopyInto(out *RuntimeClass) { *out = *in out.TypeMeta = in.TypeMeta in.ObjectMeta.DeepCopyInto(&out.ObjectMeta) - if in.Topology != nil { - in, out := &in.Topology, &out.Topology - *out = new(Topology) + if in.Scheduling != nil { + in, out := &in.Scheduling, &out.Scheduling + *out = new(Scheduling) (*in).DeepCopyInto(*out) } return @@ -90,12 +90,14 @@ func (in *RuntimeClassList) DeepCopyObject() runtime.Object { } // DeepCopyInto is an autogenerated deepcopy function, copying the receiver, writing into out. in must be non-nil. -func (in *Topology) DeepCopyInto(out *Topology) { +func (in *Scheduling) DeepCopyInto(out *Scheduling) { *out = *in if in.NodeSelector != nil { in, out := &in.NodeSelector, &out.NodeSelector - *out = new(core.NodeSelector) - (*in).DeepCopyInto(*out) + *out = make(map[string]string, len(*in)) + for key, val := range *in { + (*out)[key] = val + } } if in.Tolerations != nil { in, out := &in.Tolerations, &out.Tolerations @@ -107,12 +109,12 @@ func (in *Topology) DeepCopyInto(out *Topology) { return } -// DeepCopy is an autogenerated deepcopy function, copying the receiver, creating a new Topology. -func (in *Topology) DeepCopy() *Topology { +// DeepCopy is an autogenerated deepcopy function, copying the receiver, creating a new Scheduling. +func (in *Scheduling) DeepCopy() *Scheduling { if in == nil { return nil } - out := new(Topology) + out := new(Scheduling) in.DeepCopyInto(out) return out } diff --git a/staging/src/k8s.io/api/node/v1alpha1/BUILD b/staging/src/k8s.io/api/node/v1alpha1/BUILD index dc2094afa4..6a176d0a91 100644 --- a/staging/src/k8s.io/api/node/v1alpha1/BUILD +++ b/staging/src/k8s.io/api/node/v1alpha1/BUILD @@ -19,6 +19,7 @@ go_library( "//staging/src/k8s.io/apimachinery/pkg/runtime:go_default_library", "//staging/src/k8s.io/apimachinery/pkg/runtime/schema:go_default_library", "//vendor/github.com/gogo/protobuf/proto:go_default_library", + "//vendor/github.com/gogo/protobuf/sortkeys:go_default_library", ], ) diff --git a/staging/src/k8s.io/api/node/v1alpha1/generated.pb.go b/staging/src/k8s.io/api/node/v1alpha1/generated.pb.go index fc4bc16983..28c5e6a437 100644 --- a/staging/src/k8s.io/api/node/v1alpha1/generated.pb.go +++ b/staging/src/k8s.io/api/node/v1alpha1/generated.pb.go @@ -27,7 +27,7 @@ limitations under the License. RuntimeClass RuntimeClassList RuntimeClassSpec - Topology + Scheduling */ package v1alpha1 @@ -37,6 +37,8 @@ import math "math" import k8s_io_api_core_v1 "k8s.io/api/core/v1" +import github_com_gogo_protobuf_sortkeys "github.com/gogo/protobuf/sortkeys" + import strings "strings" import reflect "reflect" @@ -65,15 +67,15 @@ func (m *RuntimeClassSpec) Reset() { *m = RuntimeClassSpec{} func (*RuntimeClassSpec) ProtoMessage() {} func (*RuntimeClassSpec) Descriptor() ([]byte, []int) { return fileDescriptorGenerated, []int{2} } -func (m *Topology) Reset() { *m = Topology{} } -func (*Topology) ProtoMessage() {} -func (*Topology) Descriptor() ([]byte, []int) { return fileDescriptorGenerated, []int{3} } +func (m *Scheduling) Reset() { *m = Scheduling{} } +func (*Scheduling) ProtoMessage() {} +func (*Scheduling) Descriptor() ([]byte, []int) { return fileDescriptorGenerated, []int{3} } func init() { proto.RegisterType((*RuntimeClass)(nil), "k8s.io.api.node.v1alpha1.RuntimeClass") proto.RegisterType((*RuntimeClassList)(nil), "k8s.io.api.node.v1alpha1.RuntimeClassList") proto.RegisterType((*RuntimeClassSpec)(nil), "k8s.io.api.node.v1alpha1.RuntimeClassSpec") - proto.RegisterType((*Topology)(nil), "k8s.io.api.node.v1alpha1.Topology") + proto.RegisterType((*Scheduling)(nil), "k8s.io.api.node.v1alpha1.Scheduling") } func (m *RuntimeClass) Marshal() (dAtA []byte, err error) { size := m.Size() @@ -166,11 +168,11 @@ func (m *RuntimeClassSpec) MarshalTo(dAtA []byte) (int, error) { i++ i = encodeVarintGenerated(dAtA, i, uint64(len(m.RuntimeHandler))) i += copy(dAtA[i:], m.RuntimeHandler) - if m.Topology != nil { + if m.Scheduling != nil { dAtA[i] = 0x1a i++ - i = encodeVarintGenerated(dAtA, i, uint64(m.Topology.Size())) - n4, err := m.Topology.MarshalTo(dAtA[i:]) + i = encodeVarintGenerated(dAtA, i, uint64(m.Scheduling.Size())) + n4, err := m.Scheduling.MarshalTo(dAtA[i:]) if err != nil { return 0, err } @@ -179,7 +181,7 @@ func (m *RuntimeClassSpec) MarshalTo(dAtA []byte) (int, error) { return i, nil } -func (m *Topology) Marshal() (dAtA []byte, err error) { +func (m *Scheduling) Marshal() (dAtA []byte, err error) { size := m.Size() dAtA = make([]byte, size) n, err := m.MarshalTo(dAtA) @@ -189,20 +191,32 @@ func (m *Topology) Marshal() (dAtA []byte, err error) { return dAtA[:n], nil } -func (m *Topology) MarshalTo(dAtA []byte) (int, error) { +func (m *Scheduling) MarshalTo(dAtA []byte) (int, error) { var i int _ = i var l int _ = l - if m.NodeSelector != nil { - dAtA[i] = 0xa - i++ - i = encodeVarintGenerated(dAtA, i, uint64(m.NodeSelector.Size())) - n5, err := m.NodeSelector.MarshalTo(dAtA[i:]) - if err != nil { - return 0, err + if len(m.NodeSelector) > 0 { + keysForNodeSelector := make([]string, 0, len(m.NodeSelector)) + for k := range m.NodeSelector { + keysForNodeSelector = append(keysForNodeSelector, string(k)) + } + github_com_gogo_protobuf_sortkeys.Strings(keysForNodeSelector) + for _, k := range keysForNodeSelector { + dAtA[i] = 0xa + i++ + v := m.NodeSelector[string(k)] + mapSize := 1 + len(k) + sovGenerated(uint64(len(k))) + 1 + len(v) + sovGenerated(uint64(len(v))) + i = encodeVarintGenerated(dAtA, i, uint64(mapSize)) + dAtA[i] = 0xa + i++ + i = encodeVarintGenerated(dAtA, i, uint64(len(k))) + i += copy(dAtA[i:], k) + dAtA[i] = 0x12 + i++ + i = encodeVarintGenerated(dAtA, i, uint64(len(v))) + i += copy(dAtA[i:], v) } - i += n5 } if len(m.Tolerations) > 0 { for _, msg := range m.Tolerations { @@ -257,19 +271,23 @@ func (m *RuntimeClassSpec) Size() (n int) { _ = l l = len(m.RuntimeHandler) n += 1 + l + sovGenerated(uint64(l)) - if m.Topology != nil { - l = m.Topology.Size() + if m.Scheduling != nil { + l = m.Scheduling.Size() n += 1 + l + sovGenerated(uint64(l)) } return n } -func (m *Topology) Size() (n int) { +func (m *Scheduling) Size() (n int) { var l int _ = l - if m.NodeSelector != nil { - l = m.NodeSelector.Size() - n += 1 + l + sovGenerated(uint64(l)) + if len(m.NodeSelector) > 0 { + for k, v := range m.NodeSelector { + _ = k + _ = v + mapEntrySize := 1 + len(k) + sovGenerated(uint64(len(k))) + 1 + len(v) + sovGenerated(uint64(len(v))) + n += mapEntrySize + 1 + sovGenerated(uint64(mapEntrySize)) + } } if len(m.Tolerations) > 0 { for _, e := range m.Tolerations { @@ -321,17 +339,27 @@ func (this *RuntimeClassSpec) String() string { } s := strings.Join([]string{`&RuntimeClassSpec{`, `RuntimeHandler:` + fmt.Sprintf("%v", this.RuntimeHandler) + `,`, - `Topology:` + strings.Replace(fmt.Sprintf("%v", this.Topology), "Topology", "Topology", 1) + `,`, + `Scheduling:` + strings.Replace(fmt.Sprintf("%v", this.Scheduling), "Scheduling", "Scheduling", 1) + `,`, `}`, }, "") return s } -func (this *Topology) String() string { +func (this *Scheduling) String() string { if this == nil { return "nil" } - s := strings.Join([]string{`&Topology{`, - `NodeSelector:` + strings.Replace(fmt.Sprintf("%v", this.NodeSelector), "NodeSelector", "k8s_io_api_core_v1.NodeSelector", 1) + `,`, + keysForNodeSelector := make([]string, 0, len(this.NodeSelector)) + for k := range this.NodeSelector { + keysForNodeSelector = append(keysForNodeSelector, k) + } + github_com_gogo_protobuf_sortkeys.Strings(keysForNodeSelector) + mapStringForNodeSelector := "map[string]string{" + for _, k := range keysForNodeSelector { + mapStringForNodeSelector += fmt.Sprintf("%v: %v,", k, this.NodeSelector[k]) + } + mapStringForNodeSelector += "}" + s := strings.Join([]string{`&Scheduling{`, + `NodeSelector:` + mapStringForNodeSelector + `,`, `Tolerations:` + strings.Replace(strings.Replace(fmt.Sprintf("%v", this.Tolerations), "Toleration", "k8s_io_api_core_v1.Toleration", 1), `&`, ``, 1) + `,`, `}`, }, "") @@ -626,7 +654,7 @@ func (m *RuntimeClassSpec) Unmarshal(dAtA []byte) error { iNdEx = postIndex case 3: if wireType != 2 { - return fmt.Errorf("proto: wrong wireType = %d for field Topology", wireType) + return fmt.Errorf("proto: wrong wireType = %d for field Scheduling", wireType) } var msglen int for shift := uint(0); ; shift += 7 { @@ -650,10 +678,10 @@ func (m *RuntimeClassSpec) Unmarshal(dAtA []byte) error { if postIndex > l { return io.ErrUnexpectedEOF } - if m.Topology == nil { - m.Topology = &Topology{} + if m.Scheduling == nil { + m.Scheduling = &Scheduling{} } - if err := m.Topology.Unmarshal(dAtA[iNdEx:postIndex]); err != nil { + if err := m.Scheduling.Unmarshal(dAtA[iNdEx:postIndex]); err != nil { return err } iNdEx = postIndex @@ -678,7 +706,7 @@ func (m *RuntimeClassSpec) Unmarshal(dAtA []byte) error { } return nil } -func (m *Topology) Unmarshal(dAtA []byte) error { +func (m *Scheduling) Unmarshal(dAtA []byte) error { l := len(dAtA) iNdEx := 0 for iNdEx < l { @@ -701,10 +729,10 @@ func (m *Topology) Unmarshal(dAtA []byte) error { fieldNum := int32(wire >> 3) wireType := int(wire & 0x7) if wireType == 4 { - return fmt.Errorf("proto: Topology: wiretype end group for non-group") + return fmt.Errorf("proto: Scheduling: wiretype end group for non-group") } if fieldNum <= 0 { - return fmt.Errorf("proto: Topology: illegal tag %d (wire type %d)", fieldNum, wire) + return fmt.Errorf("proto: Scheduling: illegal tag %d (wire type %d)", fieldNum, wire) } switch fieldNum { case 1: @@ -734,11 +762,96 @@ func (m *Topology) Unmarshal(dAtA []byte) error { return io.ErrUnexpectedEOF } if m.NodeSelector == nil { - m.NodeSelector = &k8s_io_api_core_v1.NodeSelector{} + m.NodeSelector = make(map[string]string) } - if err := m.NodeSelector.Unmarshal(dAtA[iNdEx:postIndex]); err != nil { - return err + var mapkey string + var mapvalue string + for iNdEx < postIndex { + entryPreIndex := iNdEx + var wire uint64 + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowGenerated + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + wire |= (uint64(b) & 0x7F) << shift + if b < 0x80 { + break + } + } + fieldNum := int32(wire >> 3) + if fieldNum == 1 { + var stringLenmapkey uint64 + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowGenerated + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + stringLenmapkey |= (uint64(b) & 0x7F) << shift + if b < 0x80 { + break + } + } + intStringLenmapkey := int(stringLenmapkey) + if intStringLenmapkey < 0 { + return ErrInvalidLengthGenerated + } + postStringIndexmapkey := iNdEx + intStringLenmapkey + if postStringIndexmapkey > l { + return io.ErrUnexpectedEOF + } + mapkey = string(dAtA[iNdEx:postStringIndexmapkey]) + iNdEx = postStringIndexmapkey + } else if fieldNum == 2 { + var stringLenmapvalue uint64 + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowGenerated + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + stringLenmapvalue |= (uint64(b) & 0x7F) << shift + if b < 0x80 { + break + } + } + intStringLenmapvalue := int(stringLenmapvalue) + if intStringLenmapvalue < 0 { + return ErrInvalidLengthGenerated + } + postStringIndexmapvalue := iNdEx + intStringLenmapvalue + if postStringIndexmapvalue > l { + return io.ErrUnexpectedEOF + } + mapvalue = string(dAtA[iNdEx:postStringIndexmapvalue]) + iNdEx = postStringIndexmapvalue + } else { + iNdEx = entryPreIndex + skippy, err := skipGenerated(dAtA[iNdEx:]) + if err != nil { + return err + } + if skippy < 0 { + return ErrInvalidLengthGenerated + } + if (iNdEx + skippy) > postIndex { + return io.ErrUnexpectedEOF + } + iNdEx += skippy + } } + m.NodeSelector[mapkey] = mapvalue iNdEx = postIndex case 2: if wireType != 2 { @@ -902,38 +1015,41 @@ func init() { } var fileDescriptorGenerated = []byte{ - // 527 bytes of a gzipped FileDescriptorProto - 0x1f, 0x8b, 0x08, 0x00, 0x00, 0x00, 0x00, 0x00, 0x02, 0xff, 0x8c, 0x93, 0xbf, 0x8e, 0xd3, 0x4c, - 0x14, 0xc5, 0x33, 0xfb, 0x47, 0xca, 0x37, 0xf1, 0xb7, 0x8a, 0x8c, 0x84, 0xac, 0x14, 0x93, 0xc8, - 0x05, 0x5a, 0x21, 0x31, 0x43, 0x56, 0x08, 0x51, 0x21, 0x61, 0x1a, 0x10, 0x01, 0x24, 0xef, 0x42, - 0x81, 0x28, 0x98, 0xd8, 0x17, 0xc7, 0xc4, 0xf6, 0x58, 0x9e, 0x49, 0xa4, 0xed, 0x78, 0x04, 0x1e, - 0x81, 0xd7, 0xa0, 0x80, 0x3a, 0xe5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bc, - 0x83, 0x26, 0x5e, 0x7f, 0x0a, 0xfa, 0x98, 0x6f, 0x1a, 0x3a, 0xa7, 0x9b, 0x2f, 0xfb, 0x46, 0xb3, - 0xe3, 0x5e, 0xe1, 0x98, 0xef, 0x70, 0x47, 0x89, 0x48, 0xff, 0x37, 0x43, 0x91, 0x54, 0xa7, 0x25, - 0x37, 0x61, 0xcf, 0x6a, 0x99, 0x73, 0xa7, 0xbc, 0x47, 0x67, 0xd3, 0x93, 0x6e, 0x93, 0xe3, 0xd0, - 0xc5, 0x8a, 0xb4, 0x2e, 0x56, 0xa4, 0x75, 0xb9, 0x22, 0xad, 0xaf, 0x39, 0x41, 0x8b, 0x9c, 0xa0, - 0x8b, 0x9c, 0xa0, 0xcb, 0x9c, 0xa0, 0xdf, 0x39, 0x41, 0xdf, 0xfe, 0x90, 0xd6, 0x87, 0x76, 0x75, - 0x8c, 0xbf, 0x01, 0x00, 0x00, 0xff, 0xff, 0x61, 0x6b, 0x4c, 0x0f, 0x5f, 0x04, 0x00, 0x00, + // 568 bytes of a gzipped FileDescriptorProto + 0x1f, 0x8b, 0x08, 0x00, 0x00, 0x00, 0x00, 0x00, 0x02, 0xff, 0x8c, 0x53, 0xc1, 0x6e, 0xd3, 0x4c, + 0x10, 0x8e, 0xd3, 0x56, 0x4a, 0x37, 0xf9, 0xa3, 0xfc, 0x4b, 0x85, 0xa2, 0x1c, 0xdc, 0x2a, 0x42, + 0xa8, 0x42, 0x62, 0x97, 0x54, 0xa8, 0xaa, 0x38, 0x80, 0x30, 0x42, 0x02, 0x51, 0x40, 0xda, 0x94, + 0x0b, 0xe2, 0xc0, 0xc6, 0x1e, 0x1c, 0x13, 0xdb, 0x6b, 0x79, 0xd7, 0x91, 0x72, 0xe3, 0x11, 0x38, + 0xf1, 0x0c, 0xbc, 0x04, 0x9c, 0x73, 0xec, 0xb1, 0xa7, 0x8a, 0x98, 0x17, 0x41, 0x6b, 0x3b, 0x89, + 0x9b, 0x10, 0x91, 0x9b, 0x67, 0xe6, 0xfb, 0xbe, 0x99, 0x6f, 0x66, 0x8d, 0x9e, 0x8e, 0xce, 0x24, + 0xf1, 0x04, 0x1d, 0x25, 0x03, 0x88, 0x43, 0x50, 0x20, 0xe9, 0x18, 0x42, 0x47, 0xc4, 0xb4, 0x28, + 0xf0, 0xc8, 0xa3, 0xa1, 0x70, 0x80, 0x8e, 0x7b, 0xdc, 0x8f, 0x86, 0xbc, 0x47, 0x5d, 0x08, 0x21, + 0xe6, 0x0a, 0x1c, 0x12, 0xc5, 0x42, 0x09, 0xdc, 0xce, 0x91, 0x84, 0x47, 0x1e, 0xd1, 0x48, 0x32, + 0x47, 0x76, 0xee, 0xbb, 0x9e, 0x1a, 0x26, 0x03, 0x62, 0x8b, 0x80, 0xba, 0xc2, 0x15, 0x34, 0x23, + 0x0c, 0x92, 0x4f, 0x59, 0x94, 0x05, 0xd9, 0x57, 0x2e, 0xd4, 0xe9, 0x96, 0x5a, 0xda, 0x22, 0xd6, + 0x2d, 0x57, 0x9b, 0x75, 0x1e, 0x2e, 0x31, 0x01, 0xb7, 0x87, 0x5e, 0x08, 0xf1, 0x84, 0x46, 0x23, + 0x57, 0x27, 0x24, 0x0d, 0x40, 0xf1, 0xbf, 0xb1, 0xe8, 0x26, 0x56, 0x9c, 0x84, 0xca, 0x0b, 0x60, + 0x8d, 0x70, 0xfa, 0x2f, 0x82, 0xb4, 0x87, 0x10, 0xf0, 0x55, 0x5e, 0xf7, 0xa7, 0x81, 0x1a, 0x2c, + 0x87, 0x3c, 0xf3, 0xb9, 0x94, 0xf8, 0x23, 0xaa, 0xe9, 0xa1, 0x1c, 0xae, 0x78, 0xdb, 0x38, 0x32, + 0x8e, 0xeb, 0x27, 0x0f, 0xc8, 0x72, 0x5f, 0x0b, 0x6d, 0x12, 0x8d, 0x5c, 0x9d, 0x90, 0x44, 0xa3, + 0xc9, 0xb8, 0x47, 0xde, 0x0e, 0x3e, 0x83, 0xad, 0x5e, 0x83, 0xe2, 0x16,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85, + 0xb5, 0x46, 0xb9, 0xc4, 0x6e, 0x74, 0xc0, 0xef, 0x50, 0x5d, 0x09, 0x5f, 0xbf, 0x5f, 0x4f, 0x84, + 0xf3, 0xf5, 0x9b, 0xe5, 0x86, 0xfa, 0x2f, 0xd4, 0x77, 0xbc, 0x58, 0xc0, 0xac, 0x5b, 0x85, 0x70, + 0x7d, 0x99, 0x93, 0xac, 0xac, 0xd3, 0x79, 0x82, 0xfe, 0x5f, 0x9b, 0x07, 0xb7, 0xd0, 0xce, 0x08, + 0x26, 0xf9, 0xde, 0x99, 0xfe, 0xc4, 0x07, 0x68, 0x6f, 0xcc, 0xfd, 0x04, 0xb2, 0x87, 0xbb, 0xcf, + 0xf2, 0xe0, 0x51, 0xf5, 0xcc, 0xb0, 0xc8, 0x74, 0x66, 0x56, 0x2e, 0x67, 0x66, 0xe5, 0x6a, 0x66, + 0x56, 0xbe, 0xa4, 0xa6, 0x31, 0x4d, 0x4d, 0xe3, 0x32, 0x35, 0x8d, 0xab, 0xd4, 0x34, 0x7e, 0xa5, + 0xa6, 0xf1, 0xf5, 0xb7, 0x59, 0x79, 0x5f, 0x9b, 0x2f, 0xe2, 0x4f, 0x00, 0x00, 0x00, 0xff, 0xff, + 0xa4, 0x0d, 0x70, 0xa4, 0xc4, 0x04, 0x00, 0x00, } diff --git a/staging/src/k8s.io/api/node/v1alpha1/generated.proto b/staging/src/k8s.io/api/node/v1alpha1/generated.proto index ef5bae6c5c..39d5a96b44 100644 --- a/staging/src/k8s.io/api/node/v1alpha1/generated.proto +++ b/staging/src/k8s.io/api/node/v1alpha1/generated.proto @@ -74,28 +74,26 @@ message RuntimeClassSpec { // and is immutable. optional string runtimeHandler = 1; - // Topology describes the set of nodes in the cluster that support this - // RuntimeClass. The rules are applied applied to pods running with this - // RuntimeClass and semantically merged with other scheduling constraints on - // the pod. - // If topology is nil, this RuntimeClass is assumed to be supported by all + // Scheduling holds the scheduling constraints to ensure that pods running + // with this RuntimeClass are scheduled to nodes that support it. + // If scheduling is nil, this RuntimeClass is assumed to be supported by all // nodes. // +optional - optional Topology topology = 3; + optional Scheduling scheduling = 3; } -// Topology specifies the scheduling constraints for nodes supporting a +// Scheduling specifies the scheduling constraints for nodes supporting a // RuntimeClass. -message Topology { - // NodeSelector selects the set of nodes that support this RuntimeClass. - // Pods using this RuntimeClass can only be scheduled to a node matched by - // this selector. The NodeSelector is intersected (AND) with a pod's other - // NodeAffinity or NodeSelector requirements. - // A nil NodeSelector selects all nodes. +message Scheduling { + // nodeSelector lists labels that must be present on nodes that support this + // RuntimeClass. Pods using this RuntimeClass can only be scheduled to a + // node matched by this selector. The RuntimeClass nodeSelector is merged + // with a pod's existing nodeSelector. Any conflicts will cause the pod to + // be rejected in admission. // +optional - optional k8s.io.api.core.v1.NodeSelector nodeSelector = 1; + map nodeSelector = 1; - // Tolerations are appended (excluding duplicates) to pods running with this + // tolerations are appended (excluding duplicates) to pods running with this // RuntimeClass during admission, effectively unioning the set of nodes // tolerated by the pod and the RuntimeClass. // +optional diff --git a/staging/src/k8s.io/api/node/v1alpha1/types_swagger_doc_generated.go b/staging/src/k8s.io/api/node/v1alpha1/types_swagger_doc_generated.go index 5be2d04ec9..0bcf32e16a 100644 --- a/staging/src/k8s.io/api/node/v1alpha1/types_swagger_doc_generated.go +++ b/staging/src/k8s.io/api/node/v1alpha1/types_swagger_doc_generated.go @@ -50,21 +50,21 @@ func (RuntimeClassList) SwaggerDoc() map[string]string { var map_RuntimeClassSpec = map[string]string{ "": "RuntimeClassSpec is a specification of a RuntimeClass. It contains parameters that are required to describe the RuntimeClass to the Container Runtime Interface (CRI) implementation, as well as any other components that need to understand how the pod will be run. The RuntimeClassSpec is immutable.", "runtimeHandler": "RuntimeHandler specifies the underlying runtime and configuration that the CRI implementation will use to handle pods of this class. The possible values are specific to the node & CRI configuration. It is assumed that all handlers are available on every node, and handlers of the same name are equivalent on every node. For example, a handler called \"runc\" might specify that the runc OCI runtime (using native Linux containers) will be used to run the containers in a pod. The RuntimeHandler must conform to the DNS Label (RFC 1123) requirements and is immutable.", - "topology": "Topology describes the set of nodes in the cluster that support this RuntimeClass. The rules are applied applied to pods running with this RuntimeClass and semantically merged with other scheduling constraints on the pod. If topology is nil, this RuntimeClass is assumed to be supported by all nodes.", + "scheduling": "Scheduling holds the scheduling constraints to ensure that pods running with this RuntimeClass are scheduled to nodes that support it. If scheduling is nil, this RuntimeClass is assumed to be supported by all nodes.", } func (RuntimeClassSpec) SwaggerDoc() map[string]string { return map_RuntimeClassSpec } -var map_Topology = map[string]string{ - "": "Topology specifies the scheduling constraints for nodes supporting a RuntimeClass.", - "nodeSelector": "NodeSelector selects the set of nodes that support this RuntimeClass. Pods using this RuntimeClass can only be scheduled to a node matched by this selector. The NodeSelector is intersected (AND) with a pod's other NodeAffinity or NodeSelector requirements. A nil NodeSelector selects all nodes.", - "tolerations": "Tolerations are appended (excluding duplicates) to pods running with this RuntimeClass during admission, effectively unioning the set of nodes tolerated by the pod and the RuntimeClass.", +var map_Scheduling = map[string]string{ + "": "Scheduling specifies the scheduling constraints for nodes supporting a RuntimeClass.", + "nodeSelector": "nodeSelector lists labels that must be present on nodes that support this RuntimeClass. Pods using this RuntimeClass can only be scheduled to a node matched by this selector. The RuntimeClass nodeSelector is merged with a pod's existing nodeSelector. Any conflicts will cause the pod to be rejected in admission.", + "tolerations": "tolerations are appended (excluding duplicates) to pods running with this RuntimeClass during admission, effectively unioning the set of nodes tolerated by the pod and the RuntimeClass.", } -func (Topology) SwaggerDoc() map[string]string { - return map_Topology +func (Scheduling) SwaggerDoc() map[string]string { + return map_Scheduling } // AUTO-GENERATED FUNCTIONS END HERE diff --git a/staging/src/k8s.io/api/node/v1alpha1/zz_generated.deepcopy.go b/staging/src/k8s.io/api/node/v1alpha1/zz_generated.deepcopy.go index 30c50160d3..11e169d4fb 100644 --- a/staging/src/k8s.io/api/node/v1alpha1/zz_generated.deepcopy.go +++ b/staging/src/k8s.io/api/node/v1alpha1/zz_generated.deepcopy.go @@ -88,9 +88,9 @@ func (in *RuntimeClassList) DeepCopyObject() runtime.Object { // DeepCopyInto is an autogenerated deepcopy function, copying the receiver, writing into out. in must be non-nil. func (in *RuntimeClassSpec) DeepCopyInto(out *RuntimeClassSpec) { *out = *in - if in.Topology != nil { - in, out := &in.Topology, &out.Topology - *out = new(Topology) + if in.Scheduling != nil { + in, out := &in.Scheduling, &out.Scheduling + *out = new(Scheduling) (*in).DeepCopyInto(*out) } return @@ -107,12 +107,14 @@ func (in *RuntimeClassSpec) DeepCopy() *RuntimeClassSpec { } // DeepCopyInto is an autogenerated deepcopy function, copying the receiver, writing into out. in must be non-nil. -func (in *Topology) DeepCopyInto(out *Topology) { +func (in *Scheduling) DeepCopyInto(out *Scheduling) { *out = *in if in.NodeSelector != nil { in, out := &in.NodeSelector, &out.NodeSelector - *out = new(v1.NodeSelector) - (*in).DeepCopyInto(*out) + *out = make(map[string]string, len(*in)) + for key, val := range *in { + (*out)[key] = val + } } if in.Tolerations != nil { in, out := &in.Tolerations, &out.Tolerations @@ -124,12 +126,12 @@ func (in *Topology) DeepCopyInto(out *Topology) { return } -// DeepCopy is an autogenerated deepcopy function, copying the receiver, creating a new Topology. -func (in *Topology) DeepCopy() *Topology { +// DeepCopy is an autogenerated deepcopy function, copying the receiver, creating a new Scheduling. +func (in *Scheduling) DeepCopy() *Scheduling { if in == nil { return nil } - out := new(Topology) + out := new(Scheduling) in.DeepCopyInto(out) return out } diff --git a/staging/src/k8s.io/api/node/v1beta1/BUILD b/staging/src/k8s.io/api/node/v1beta1/BUILD index 214090d851..db2cdbe037 100644 --- a/staging/src/k8s.io/api/node/v1beta1/BUILD +++ b/staging/src/k8s.io/api/node/v1beta1/BUILD @@ -19,6 +19,7 @@ go_library( "//staging/src/k8s.io/apimachinery/pkg/runtime:go_default_library", "//staging/src/k8s.io/apimachinery/pkg/runtime/schema:go_default_library", "//vendor/github.com/gogo/protobuf/proto:go_default_library", + "//vendor/github.com/gogo/protobuf/sortkeys:go_default_library", ], ) diff --git a/staging/src/k8s.io/api/node/v1beta1/generated.pb.go b/staging/src/k8s.io/api/node/v1beta1/generated.pb.go index c9b285f99d..a2cf593923 100644 --- a/staging/src/k8s.io/api/node/v1beta1/generated.pb.go +++ b/staging/src/k8s.io/api/node/v1beta1/generated.pb.go @@ -26,7 +26,7 @@ limitations under the License. It has these top-level messages: RuntimeClass RuntimeClassList - Topology + Scheduling */ package v1beta1 @@ -36,6 +36,8 @@ import math "math" import k8s_io_api_core_v1 "k8s.io/api/core/v1" +import github_com_gogo_protobuf_sortkeys "github.com/gogo/protobuf/sortkeys" + import strings "strings" import reflect "reflect" @@ -60,14 +62,14 @@ func (m *RuntimeClassList) Reset() { *m = RuntimeClassList{} func (*RuntimeClassList) ProtoMessage() {} func (*RuntimeClassList) Descriptor() ([]byte, []int) { return fileDescriptorGenerated, []int{1} } -func (m *Topology) Reset() { *m = Topology{} } -func (*Topology) ProtoMessage() {} -func (*Topology) Descriptor() ([]byte, []int) { return fileDescriptorGenerated, []int{2} } +func (m *Scheduling) Reset() { *m = Scheduling{} } +func (*Scheduling) ProtoMessage() {} +func (*Scheduling) Descriptor() ([]byte, []int) { return fileDescriptorGenerated, []int{2} } func init() { proto.RegisterType((*RuntimeClass)(nil), "k8s.io.api.node.v1beta1.RuntimeClass") proto.RegisterType((*RuntimeClassList)(nil), "k8s.io.api.node.v1beta1.RuntimeClassList") - proto.RegisterType((*Topology)(nil), "k8s.io.api.node.v1beta1.Topology") + proto.RegisterType((*Scheduling)(nil), "k8s.io.api.node.v1beta1.Scheduling") } func (m *RuntimeClass) Marshal() (dAtA []byte, err error) { size := m.Size() @@ -96,11 +98,11 @@ func (m *RuntimeClass) MarshalTo(dAtA []byte) (int, error) { i++ i = encodeVarintGenerated(dAtA, i, uint64(len(m.Handler))) i += copy(dAtA[i:], m.Handler) - if m.Topology != nil { + if m.Scheduling != nil { dAtA[i] = 0x1a i++ - i = encodeVarintGenerated(dAtA, i, uint64(m.Topology.Size())) - n2, err := m.Topology.MarshalTo(dAtA[i:]) + i = encodeVarintGenerated(dAtA, i, uint64(m.Scheduling.Size())) + n2, err := m.Scheduling.MarshalTo(dAtA[i:]) if err != nil { return 0, err } @@ -147,7 +149,7 @@ func (m *RuntimeClassList) MarshalTo(dAtA []byte) (int, error) { return i, nil } -func (m *Topology) Marshal() (dAtA []byte, err error) { +func (m *Scheduling) Marshal() (dAtA []byte, err error) { size := m.Size() dAtA = make([]byte, size) n, err := m.MarshalTo(dAtA) @@ -157,20 +159,32 @@ func (m *Topology) Marshal() (dAtA []byte, err error) { return dAtA[:n], nil } -func (m *Topology) MarshalTo(dAtA []byte) (int, error) { +func (m *Scheduling) MarshalTo(dAtA []byte) (int, error) { var i int _ = i var l int _ = l - if m.NodeSelector != nil { - dAtA[i] = 0xa - i++ - i = encodeVarintGenerated(dAtA, i, uint64(m.NodeSelector.Size())) - n4, err := m.NodeSelector.MarshalTo(dAtA[i:]) - if err != nil { - return 0, err + if len(m.NodeSelector) > 0 { + keysForNodeSelector := make([]string, 0, len(m.NodeSelector)) + for k := range m.NodeSelector { + keysForNodeSelector = append(keysForNodeSelector, string(k)) + } + github_com_gogo_protobuf_sortkeys.Strings(keysForNodeSelector) + for _, k := range keysForNodeSelector { + dAtA[i] = 0xa + i++ + v := m.NodeSelector[string(k)] + mapSize := 1 + len(k) + sovGenerated(uint64(len(k))) + 1 + len(v) + sovGenerated(uint64(len(v))) + i = encodeVarintGenerated(dAtA, i, uint64(mapSize)) + dAtA[i] = 0xa + i++ + i = encodeVarintGenerated(dAtA, i, uint64(len(k))) + i += copy(dAtA[i:], k) + dAtA[i] = 0x12 + i++ + i = encodeVarintGenerated(dAtA, i, uint64(len(v))) + i += copy(dAtA[i:], v) } - i += n4 } if len(m.Tolerations) > 0 { for _, msg := range m.Tolerations { @@ -203,8 +217,8 @@ func (m *RuntimeClass) Size() (n int) { n += 1 + l + sovGenerated(uint64(l)) l = len(m.Handler) n += 1 + l + sovGenerated(uint64(l)) - if m.Topology != nil { - l = m.Topology.Size() + if m.Scheduling != nil { + l = m.Scheduling.Size() n += 1 + l + sovGenerated(uint64(l)) } return n @@ -224,12 +238,16 @@ func (m *RuntimeClassList) Size() (n int) { return n } -func (m *Topology) Size() (n int) { +func (m *Scheduling) Size() (n int) { var l int _ = l - if m.NodeSelector != nil { - l = m.NodeSelector.Size() - n += 1 + l + sovGenerated(uint64(l)) + if len(m.NodeSelector) > 0 { + for k, v := range m.NodeSelector { + _ = k + _ = v + mapEntrySize := 1 + len(k) + sovGenerated(uint64(len(k))) + 1 + len(v) + sovGenerated(uint64(len(v))) + n += mapEntrySize + 1 + sovGenerated(uint64(mapEntrySize)) + } } if len(m.Tolerations) > 0 { for _, e := range m.Tolerations { @@ -260,7 +278,7 @@ func (this *RuntimeClass) String() string { s := strings.Join([]string{`&RuntimeClass{`, `ObjectMeta:` + strings.Replace(strings.Replace(this.ObjectMeta.String(), "ObjectMeta", "k8s_io_apimachinery_pkg_apis_meta_v1.ObjectMeta", 1), `&`, ``, 1) + `,`, `Handler:` + fmt.Sprintf("%v", this.Handler) + `,`, - `Topology:` + strings.Replace(fmt.Sprintf("%v", this.Topology), "Topology", "Topology", 1) + `,`, + `Scheduling:` + strings.Replace(fmt.Sprintf("%v", this.Scheduling), "Scheduling", "Scheduling", 1) + `,`, `}`, }, "") return s @@ -276,12 +294,22 @@ func (this *RuntimeClassList) String() string { }, "") return s } -func (this *Topology) String() string { +func (this *Scheduling) String() string { if this == nil { return "nil" } - s := strings.Join([]string{`&Topology{`, - `NodeSelector:` + strings.Replace(fmt.Sprintf("%v", this.NodeSelector), "NodeSelector", "k8s_io_api_core_v1.NodeSelector", 1) + `,`, + keysForNodeSelector := make([]string, 0, len(this.NodeSelector)) + for k := range this.NodeSelector { + keysForNodeSelector = append(keysForNodeSelector, k) + } + github_com_gogo_protobuf_sortkeys.Strings(keysForNodeSelector) + mapStringForNodeSelector := "map[string]string{" + for _, k := range keysForNodeSelector { + mapStringForNodeSelector += fmt.Sprintf("%v: %v,", k, this.NodeSelector[k]) + } + mapStringForNodeSelector += "}" + s := strings.Join([]string{`&Scheduling{`, + `NodeSelector:` + mapStringForNodeSelector + `,`, `Tolerations:` + strings.Replace(strings.Replace(fmt.Sprintf("%v", this.Tolerations), "Toleration", "k8s_io_api_core_v1.Toleration", 1), `&`, ``, 1) + `,`, `}`, }, "") @@ -385,7 +413,7 @@ func (m *RuntimeClass) Unmarshal(dAtA []byte) error { iNdEx = postIndex case 3: if wireType != 2 { - return fmt.Errorf("proto: wrong wireType = %d for field Topology", wireType) + return fmt.Errorf("proto: wrong wireType = %d for field Scheduling", wireType) } var msglen int for shift := uint(0); ; shift += 7 { @@ -409,10 +437,10 @@ func (m *RuntimeClass) Unmarshal(dAtA []byte) error { if postIndex > l { return io.ErrUnexpectedEOF } - if m.Topology == nil { - m.Topology = &Topology{} + if m.Scheduling == nil { + m.Scheduling = &Scheduling{} } - if err := m.Topology.Unmarshal(dAtA[iNdEx:postIndex]); err != nil { + if err := m.Scheduling.Unmarshal(dAtA[iNdEx:postIndex]); err != nil { return err } iNdEx = postIndex @@ -548,7 +576,7 @@ func (m *RuntimeClassList) Unmarshal(dAtA []byte) error { } return nil } -func (m *Topology) Unmarshal(dAtA []byte) error { +func (m *Scheduling) Unmarshal(dAtA []byte) error { l := len(dAtA) iNdEx := 0 for iNdEx < l { @@ -571,10 +599,10 @@ func (m *Topology) Unmarshal(dAtA []byte) error { fieldNum := int32(wire >> 3) wireType := int(wire & 0x7) if wireType == 4 { - return fmt.Errorf("proto: Topology: wiretype end group for non-group") + return fmt.Errorf("proto: Scheduling: wiretype end group for non-group") } if fieldNum <= 0 { - return fmt.Errorf("proto: Topology: illegal tag %d (wire type %d)", fieldNum, wire) + return fmt.Errorf("proto: Scheduling: illegal tag %d (wire type %d)", fieldNum, wire) } switch fieldNum { case 1: @@ -604,11 +632,96 @@ func (m *Topology) Unmarshal(dAtA []byte) error { return io.ErrUnexpectedEOF } if m.NodeSelector == nil { - m.NodeSelector = &k8s_io_api_core_v1.NodeSelector{} + m.NodeSelector = make(map[string]string) } - if err := m.NodeSelector.Unmarshal(dAtA[iNdEx:postIndex]); err != nil { - return err + var mapkey string + var mapvalue string + for iNdEx < postIndex { + entryPreIndex := iNdEx + var wire uint64 + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowGenerated + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + wire |= (uint64(b) & 0x7F) << shift + if b < 0x80 { + break + } + } + fieldNum := int32(wire >> 3) + if fieldNum == 1 { + var stringLenmapkey uint64 + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowGenerated + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + stringLenmapkey |= (uint64(b) & 0x7F) << shift + if b < 0x80 { + break + } + } + intStringLenmapkey := int(stringLenmapkey) + if intStringLenmapkey < 0 { + return ErrInvalidLengthGenerated + } + postStringIndexmapkey := iNdEx + intStringLenmapkey + if postStringIndexmapkey > l { + return io.ErrUnexpectedEOF + } + mapkey = string(dAtA[iNdEx:postStringIndexmapkey]) + iNdEx = postStringIndexmapkey + } else if fieldNum == 2 { + var stringLenmapvalue uint64 + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowGenerated + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + stringLenmapvalue |= (uint64(b) & 0x7F) << shift + if b < 0x80 { + break + } + } + intStringLenmapvalue := int(stringLenmapvalue) + if intStringLenmapvalue < 0 { + return ErrInvalidLengthGenerated + } + postStringIndexmapvalue := iNdEx + intStringLenmapvalue + if postStringIndexmapvalue > l { + return io.ErrUnexpectedEOF + } + mapvalue = string(dAtA[iNdEx:postStringIndexmapvalue]) + iNdEx = postStringIndexmapvalue + } else { + iNdEx = entryPreIndex + skippy, err := skipGenerated(dAtA[iNdEx:]) + if err != nil { + return err + } + if skippy < 0 { + return ErrInvalidLengthGenerated + } + if (iNdEx + skippy) > postIndex { + return io.ErrUnexpectedEOF + } + iNdEx += skippy + } } + m.NodeSelector[mapkey] = mapvalue iNdEx = postIndex case 2: if wireType != 2 { @@ -772,36 +885,39 @@ func init() { } var fileDescriptorGenerated = []byte{ - // 493 bytes of a gzipped FileDescriptorProto - 0x1f, 0x8b, 0x08, 0x00, 0x00, 0x00, 0x00, 0x00, 0x02, 0xff, 0x8c, 0x52, 0xcf, 0x8e, 0xd3, 0x3e, - 0x18, 0x8c, 0x77, 0xb5, 0x6a, 0x7f, 0x6e, 0x7f, 0xa2, 0x0a, 0x07, 0xaa, 0x1e, 0xdc, 0x52, 0x09, - 0xa9, 0x1c, 0xd6, 0xa6, 0x2b, 0x84, 0x38, 0xa2, 0x70, 0xe1, 0x3f, 0x52, 0x58, 0x38, 0x20, 0x0e, - 0x38, 0xc9, 0x47, 0x1a, 0x9a, 0xc4, 0x51, 0xec, 0x56, 0xda, 0x1b, 0x8f, 0xc0, 0xeb, 0x20, 0xf1, - 0x00, 0x3d, 0xee, 0x71, 0x4f, 0x15, 0x0d, 0x17, 0x1e, 0x03, 0x39, 0x71, 0xd3, 0xb0, 0xbb, 0x15, - 0xdc, 0xf2, 0x8d, 0x67, 0xe6, 0x9b, 0x71, 0x8c, 0x1f, 0xcd, 0x1f, 0x4a, 0x1a, 0x09, 0x36, 0x5f, - 0x78, 0x90, 0xa7, 0xa0, 0x40, 0xb2, 0x25, 0xa4, 0x81, 0xc8, 0x99, 0x39, 0xe0, 0x59, 0xc4, 0x52, - 0x11, 0x00, 0x5b, 0x4e, 0x3d, 0x50, 0x7c, 0xca, 0x42, 0x48, 0x21, 0xe7, 0x0a, 0x02, 0x9a, 0xe5, - 0x42, 0x09, 0xfb, 0x56, 0x45, 0xa4, 0x3c, 0x8b, 0xa8, 0x26, 0x52, 0x43, 0x1c, 0x1c, 0x87, 0x91, - 0x9a, 0x2d, 0x3c, 0xea, 0x8b, 0x84, 0x85,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 0xcd, 0xaa, 0x2f, 0x22, 0xa9, - 0xec, 0x0f, 0x57, 0xea, 0xd2, 0x7f, 0xab, 0xab, 0xd5, 0x65, 0xd9, 0x9e, 0x49, 0xdf, 0xde, 0x22, - 0x8d, 0xaa, 0xcf, 0xf0, 0x51, 0xa4, 0x20, 0x91, 0xfd, 0x83, 0xd1, 0xe1, 0xa4, 0x73, 0x72, 0x67, - 0x6f, 0xf8, 0x66, 0x2e, 0xe7, 0x7f, 0xe3, 0x78, 0xf4, 0x54, 0x6b, 0xdd, 0xca, 0x62, 0xfc, 0x0d, - 0xe1, 0xba, 0x95, 0xfd, 0x0e, 0x77, 0xb5, 0xfe, 0x0d, 0xc4, 0xe0, 0x2b, 0x91, 0x9b, 0xe8, 0xa3, - 0xa6, 0xbf, 0x7e, 0x90, 0x3a, 0xe8, 0xab, 0x06, 0xcf, 0xe9, 0x15, 0xeb, 0x61, 0xb7, 0x89, 0xb8, - 0x7f, 0xf8, 0xd8, 0x6f, 0x71, 0x47, 0x89, 0x58, 0xbf, 0x90, 0x48, 0xa4, 0xdb, 0xd8, 0xe4, 0x3a, - 0xdb, 0xd3, 0x9a, 0xe6, 0xdc, 0x34, 0x79, 0x3b, 0x3b, 0x4c, 0xba, 0x4d, 0x1f, 0xe7, 0x78, 0xb5, - 0x21, 0xd6, 0xf9, 0x86, 0x58, 0x17, 0x1b, 0x62, 0x7d, 0x29, 0x08, 0x5a, 0x15, 0x04, 0x9d, 0x17, - 0x04, 0x5d, 0x14, 0x04, 0xfd, 0x28, 0x08, 0xfa, 0xfa, 0x93, 0x58, 0xef, 0x5b, 0xe6, 0x36, 0x7e, - 0x07, 0x00, 0x00, 0xff, 0xff, 0xcb, 0xb4, 0x5d, 0x60, 0xe2, 0x03, 0x00, 0x00, + // 534 bytes of a gzipped FileDescriptorProto + 0x1f, 0x8b, 0x08, 0x00, 0x00, 0x00, 0x00, 0x00, 0x02, 0xff, 0x8c, 0x53, 0xcf, 0x8e, 0xd2, 0x40, + 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, 0xe7, 0x12, 0xfd, 0x1f, + 0x55, 0xac, 0x25, 0x33, 0x38, 0x6e, 0x29, 0x85, 0x11, 0x04, 0xe0, 0x48, 0x1e, 0x77, 0x50, 0xe6, + 0xf0, 0xf0, 0x0a, 0x4b, 0x22, 0x6f, 0x35, 0xde, 0xf3, 0x48, 0xc6, 0x0b, 0xeb, 0xa0, 0x70, 0x6c, + 0xe9, 0x47, 0xf6, 0x3f, 0x06, 0xc6, 0x07, 0xdc, 0x94, 0x3c, 0x50, 0x8f, 0xc8, 0xe7, 0xd1, 0x3a, + 0x91, 0xa9, 0xfb, 0xa9, 0x5f, 0x41, 0xad, 0xe6, 0xfd, 0x06, 0x66, 0xdd, 0x2a, 0x84, 0x9b, 0x65, + 0x4f, 0xd8, 0xba, 0x4e, 0xf7, 0x09, 0xbe, 0xb9, 0x35, 0x8f, 0xd1, 0xc6, 0xb5, 0x29, 0x2c, 0xb2, + 0x0b, 0xd9, 0xb7, 0xd5, 0xa7, 0x71, 0x80, 0xeb, 0x73, 0x16, 0x24, 0x90, 0x3f, 0x1d, 0x3b, 0x2f, + 0x1e, 0x57, 0x4f, 0x90, 0x75, 0xb4, 0x5c, 0x99, 0x95, 0xd3, 0x95, 0x59, 0x39, 0x5b, 0x99, 0x95, + 0x6f, 0xa9, 0x89, 0x96, 0xa9, 0x89, 0x4e, 0x53, 0x13, 0x9d, 0xa5, 0x26, 0xfa, 0x95, 0x9a, 0xe8, + 0xfb, 0x6f, 0xb3, 0xf2, 0xb1, 0x51, 0xec, 0xe1, 0x6f, 0x00, 0x00, 0x00, 0xff, 0xff, 0x36, 0x6a, + 0x5d, 0x42, 0x46, 0x04, 0x00, 0x00, } diff --git a/staging/src/k8s.io/api/node/v1beta1/generated.proto b/staging/src/k8s.io/api/node/v1beta1/generated.proto index ec01723471..d1124c93be 100644 --- a/staging/src/k8s.io/api/node/v1beta1/generated.proto +++ b/staging/src/k8s.io/api/node/v1beta1/generated.proto @@ -53,14 +53,12 @@ message RuntimeClass { // immutable. optional string handler = 2; - // Topology describes the set of nodes in the cluster that support this - // RuntimeClass. The rules are applied applied to pods running with this - // RuntimeClass and semantically merged with other scheduling constraints on - // the pod. - // If topology is nil, this RuntimeClass is assumed to be supported by all + // Scheduling holds the scheduling constraints to ensure that pods running + // with this RuntimeClass are scheduled to nodes that support it. + // If scheduling is nil, this RuntimeClass is assumed to be supported by all // nodes. // +optional - optional Topology topology = 3; + optional Scheduling scheduling = 3; } // RuntimeClassList is a list of RuntimeClass objects. @@ -74,18 +72,18 @@ message RuntimeClassList { repeated RuntimeClass items = 2; } -// Topology specifies the scheduling constraints for nodes supporting a +// Scheduling specifies the scheduling constraints for nodes supporting a // RuntimeClass. -message Topology { - // NodeSelector selects the set of nodes that support this RuntimeClass. - // Pods using this RuntimeClass can only be scheduled to a node matched by - // this selector. The NodeSelector is intersected (AND) with a pod's other - // NodeAffinity or NodeSelector requirements. - // A nil NodeSelector selects all nodes. +message Scheduling { + // nodeSelector lists labels that must be present on nodes that support this + // RuntimeClass. Pods using this RuntimeClass can only be scheduled to a + // node matched by this selector. The RuntimeClass nodeSelector is merged + // with a pod's existing nodeSelector. Any conflicts will cause the pod to + // be rejected in admission. // +optional - optional k8s.io.api.core.v1.NodeSelector nodeSelector = 1; + map nodeSelector = 1; - // Tolerations are appended (excluding duplicates) to pods running with this + // tolerations are appended (excluding duplicates) to pods running with this // RuntimeClass during admission, effectively unioning the set of nodes // tolerated by the pod and the RuntimeClass. // +optional diff --git a/staging/src/k8s.io/api/node/v1beta1/types_swagger_doc_generated.go b/staging/src/k8s.io/api/node/v1beta1/types_swagger_doc_generated.go index 3f85eb9472..ac6e95528d 100644 --- a/staging/src/k8s.io/api/node/v1beta1/types_swagger_doc_generated.go +++ b/staging/src/k8s.io/api/node/v1beta1/types_swagger_doc_generated.go @@ -28,10 +28,10 @@ package v1beta1 // AUTO-GENERATED FUNCTIONS START HERE. DO NOT EDIT. var map_RuntimeClass = map[string]string{ - "": "RuntimeClass defines a class of container runtime supported in the cluster. The RuntimeClass is used to determine which container runtime is used to run all containers in a pod. RuntimeClasses are (currently) manually defined by a user or cluster provisioner, and referenced in the PodSpec. The Kubelet is responsible for resolving the RuntimeClassName reference before running the pod. For more details, see https://git.k8s.io/enhancements/keps/sig-node/runtime-class.md", - "metadata": "More info: https://git.k8s.io/community/contributors/devel/api-conventions.md#metadata", - "handler": "Handler specifies the underlying runtime and configuration that the CRI implementation will use to handle pods of this class. The possible values are specific to the node & CRI configuration. It is assumed that all handlers are available on every node, and handlers of the same name are equivalent on every node. For example, a handler called \"runc\" might specify that the runc OCI runtime (using native Linux containers) will be used to run the containers in a pod. The Handler must conform to the DNS Label (RFC 1123) requirements, and is immutable.", - "topology": "Topology describes the set of nodes in the cluster that support this RuntimeClass. The rules are applied applied to pods running with this RuntimeClass and semantically merged with other scheduling constraints on the pod. If topology is nil, this RuntimeClass is assumed to be supported by all nodes.", + "": "RuntimeClass defines a class of container runtime supported in the cluster. The RuntimeClass is used to determine which container runtime is used to run all containers in a pod. RuntimeClasses are (currently) manually defined by a user or cluster provisioner, and referenced in the PodSpec. The Kubelet is responsible for resolving the RuntimeClassName reference before running the pod. For more details, see https://git.k8s.io/enhancements/keps/sig-node/runtime-class.md", + "metadata": "More info: https://git.k8s.io/community/contributors/devel/api-conventions.md#metadata", + "handler": "Handler specifies the underlying runtime and configuration that the CRI implementation will use to handle pods of this class. The possible values are specific to the node & CRI configuration. It is assumed that all handlers are available on every node, and handlers of the same name are equivalent on every node. For example, a handler called \"runc\" might specify that the runc OCI runtime (using native Linux containers) will be used to run the containers in a pod. The Handler must conform to the DNS Label (RFC 1123) requirements, and is immutable.", + "scheduling": "Scheduling holds the scheduling constraints to ensure that pods running with this RuntimeClass are scheduled to nodes that support it. If scheduling is nil, this RuntimeClass is assumed to be supported by all nodes.", } func (RuntimeClass) SwaggerDoc() map[string]string { @@ -48,14 +48,14 @@ func (RuntimeClassList) SwaggerDoc() map[string]string { return map_RuntimeClassList } -var map_Topology = map[string]string{ - "": "Topology specifies the scheduling constraints for nodes supporting a RuntimeClass.", - "nodeSelector": "NodeSelector selects the set of nodes that support this RuntimeClass. Pods using this RuntimeClass can only be scheduled to a node matched by this selector. The NodeSelector is intersected (AND) with a pod's other NodeAffinity or NodeSelector requirements. A nil NodeSelector selects all nodes.", - "tolerations": "Tolerations are appended (excluding duplicates) to pods running with this RuntimeClass during admission, effectively unioning the set of nodes tolerated by the pod and the RuntimeClass.", +var map_Scheduling = map[string]string{ + "": "Scheduling specifies the scheduling constraints for nodes supporting a RuntimeClass.", + "nodeSelector": "nodeSelector lists labels that must be present on nodes that support this RuntimeClass. Pods using this RuntimeClass can only be scheduled to a node matched by this selector. The RuntimeClass nodeSelector is merged with a pod's existing nodeSelector. Any conflicts will cause the pod to be rejected in admission.", + "tolerations": "tolerations are appended (excluding duplicates) to pods running with this RuntimeClass during admission, effectively unioning the set of nodes tolerated by the pod and the RuntimeClass.", } -func (Topology) SwaggerDoc() map[string]string { - return map_Topology +func (Scheduling) SwaggerDoc() map[string]string { + return map_Scheduling } // AUTO-GENERATED FUNCTIONS END HERE diff --git a/staging/src/k8s.io/api/node/v1beta1/zz_generated.deepcopy.go b/staging/src/k8s.io/api/node/v1beta1/zz_generated.deepcopy.go index cccc806e89..0e8d2d465d 100644 --- a/staging/src/k8s.io/api/node/v1beta1/zz_generated.deepcopy.go +++ b/staging/src/k8s.io/api/node/v1beta1/zz_generated.deepcopy.go @@ -30,9 +30,9 @@ func (in *RuntimeClass) DeepCopyInto(out *RuntimeClass) { *out = *in out.TypeMeta = in.TypeMeta in.ObjectMeta.DeepCopyInto(&out.ObjectMeta) - if in.Topology != nil { - in, out := &in.Topology, &out.Topology - *out = new(Topology) + if in.Scheduling != nil { + in, out := &in.Scheduling, &out.Scheduling + *out = new(Scheduling) (*in).DeepCopyInto(*out) } return @@ -90,12 +90,14 @@ func (in *RuntimeClassList) DeepCopyObject() runtime.Object { } // DeepCopyInto is an autogenerated deepcopy function, copying the receiver, writing into out. in must be non-nil. -func (in *Topology) DeepCopyInto(out *Topology) { +func (in *Scheduling) DeepCopyInto(out *Scheduling) { *out = *in if in.NodeSelector != nil { in, out := &in.NodeSelector, &out.NodeSelector - *out = new(v1.NodeSelector) - (*in).DeepCopyInto(*out) + *out = make(map[string]string, len(*in)) + for key, val := range *in { + (*out)[key] = val + } } if in.Tolerations != nil { in, out := &in.Tolerations, &out.Tolerations @@ -107,12 +109,12 @@ func (in *Topology) DeepCopyInto(out *Topology) { return } -// DeepCopy is an autogenerated deepcopy function, copying the receiver, creating a new Topology. -func (in *Topology) DeepCopy() *Topology { +// DeepCopy is an autogenerated deepcopy function, copying the receiver, creating a new Scheduling. +func (in *Scheduling) DeepCopy() *Scheduling { if in == nil { return nil } - out := new(Topology) + out := new(Scheduling) in.DeepCopyInto(out) return out }