Revert "Introduce topology into the runtimeClass API"
This commit is contained in:
@@ -11,9 +11,7 @@ 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",
|
||||
@@ -40,9 +38,7 @@ 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",
|
||||
|
@@ -33,19 +33,11 @@ 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.Scheduling != nil {
|
||||
out.Scheduling = new(node.Scheduling)
|
||||
autoConvert_v1alpha1_Scheduling_To_node_Scheduling(in.Spec.Scheduling, out.Scheduling, 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
|
||||
if in.Scheduling != nil {
|
||||
out.Spec.Scheduling = new(v1alpha1.Scheduling)
|
||||
autoConvert_node_Scheduling_To_v1alpha1_Scheduling(in.Scheduling, out.Spec.Scheduling, s)
|
||||
}
|
||||
return nil
|
||||
}
|
||||
|
@@ -21,10 +21,8 @@ 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"
|
||||
)
|
||||
|
||||
@@ -33,77 +31,24 @@ func TestRuntimeClassConversion(t *testing.T) {
|
||||
name = "puppy"
|
||||
handler = "heidi"
|
||||
)
|
||||
tests := map[string]struct {
|
||||
internal *node.RuntimeClass
|
||||
external *v1alpha1.RuntimeClass
|
||||
}{
|
||||
"fully-specified": {
|
||||
internal: &node.RuntimeClass{
|
||||
ObjectMeta: metav1.ObjectMeta{Name: name},
|
||||
Handler: handler,
|
||||
Scheduling: &node.Scheduling{
|
||||
NodeSelector: map[string]string{"extra-soft": "true"},
|
||||
Tolerations: []core.Toleration{{
|
||||
Key: "stinky",
|
||||
Operator: core.TolerationOpExists,
|
||||
Effect: core.TaintEffectNoSchedule,
|
||||
}},
|
||||
},
|
||||
},
|
||||
external: &v1alpha1.RuntimeClass{
|
||||
ObjectMeta: metav1.ObjectMeta{Name: name},
|
||||
Spec: v1alpha1.RuntimeClassSpec{
|
||||
RuntimeHandler: handler,
|
||||
Scheduling: &v1alpha1.Scheduling{
|
||||
NodeSelector: map[string]string{"extra-soft": "true"},
|
||||
Tolerations: []corev1.Toleration{{
|
||||
Key: "stinky",
|
||||
Operator: corev1.TolerationOpExists,
|
||||
Effect: corev1.TaintEffectNoSchedule,
|
||||
}},
|
||||
},
|
||||
},
|
||||
},
|
||||
},
|
||||
"empty-scheduling": {
|
||||
internal: &node.RuntimeClass{
|
||||
ObjectMeta: metav1.ObjectMeta{Name: name},
|
||||
Handler: handler,
|
||||
Scheduling: &node.Scheduling{},
|
||||
},
|
||||
external: &v1alpha1.RuntimeClass{
|
||||
ObjectMeta: metav1.ObjectMeta{Name: name},
|
||||
Spec: v1alpha1.RuntimeClassSpec{
|
||||
RuntimeHandler: handler,
|
||||
Scheduling: &v1alpha1.Scheduling{},
|
||||
},
|
||||
},
|
||||
},
|
||||
"empty": {
|
||||
internal: &node.RuntimeClass{
|
||||
ObjectMeta: metav1.ObjectMeta{Name: name},
|
||||
Handler: handler,
|
||||
},
|
||||
external: &v1alpha1.RuntimeClass{
|
||||
ObjectMeta: metav1.ObjectMeta{Name: name},
|
||||
Spec: v1alpha1.RuntimeClassSpec{
|
||||
RuntimeHandler: handler,
|
||||
},
|
||||
},
|
||||
internalRC := node.RuntimeClass{
|
||||
ObjectMeta: metav1.ObjectMeta{Name: name},
|
||||
Handler: handler,
|
||||
}
|
||||
v1alpha1RC := v1alpha1.RuntimeClass{
|
||||
ObjectMeta: metav1.ObjectMeta{Name: name},
|
||||
Spec: v1alpha1.RuntimeClassSpec{
|
||||
RuntimeHandler: handler,
|
||||
},
|
||||
}
|
||||
|
||||
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")
|
||||
convertedInternal := node.RuntimeClass{}
|
||||
require.NoError(t,
|
||||
Convert_v1alpha1_RuntimeClass_To_node_RuntimeClass(&v1alpha1RC, &convertedInternal, nil))
|
||||
assert.Equal(t, internalRC, convertedInternal)
|
||||
|
||||
convertedV1alpha1 := &v1alpha1.RuntimeClass{}
|
||||
require.NoError(t,
|
||||
Convert_node_RuntimeClass_To_v1alpha1_RuntimeClass(test.internal, convertedV1alpha1, nil))
|
||||
assert.Equal(t, test.external, convertedV1alpha1, "internal -> external")
|
||||
})
|
||||
}
|
||||
convertedV1alpha1 := v1alpha1.RuntimeClass{}
|
||||
require.NoError(t,
|
||||
Convert_node_RuntimeClass_To_v1alpha1_RuntimeClass(&internalRC, &convertedV1alpha1, nil))
|
||||
assert.Equal(t, v1alpha1RC, convertedV1alpha1)
|
||||
}
|
||||
|
37
pkg/apis/node/v1alpha1/zz_generated.conversion.go
generated
37
pkg/apis/node/v1alpha1/zz_generated.conversion.go
generated
@@ -21,13 +21,9 @@ 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"
|
||||
)
|
||||
|
||||
@@ -58,16 +54,6 @@ func RegisterConversions(s *runtime.Scheme) error {
|
||||
}); err != nil {
|
||||
return err
|
||||
}
|
||||
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.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
|
||||
}
|
||||
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 {
|
||||
@@ -90,7 +76,6 @@ 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.Scheduling requires manual conversion: does not exist in peer-type
|
||||
return nil
|
||||
}
|
||||
|
||||
@@ -135,25 +120,3 @@ 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_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_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_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_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)
|
||||
}
|
||||
|
Reference in New Issue
Block a user