Revert "Introduce topology into the runtimeClass API"

This commit is contained in:
Yassine TIJANI
2019-05-31 20:49:40 +00:00
committed by GitHub
parent b7fa33ec15
commit 480d5e47b6
27 changed files with 76 additions and 1341 deletions

View File

@@ -6,10 +6,8 @@ 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/apis/meta/v1/validation:go_default_library",
"//staging/src/k8s.io/apimachinery/pkg/util/validation/field:go_default_library",
],
)
@@ -19,7 +17,6 @@ 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",

View File

@@ -18,9 +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"
)
@@ -32,10 +30,6 @@ func ValidateRuntimeClass(rc *node.RuntimeClass) field.ErrorList {
allErrs = append(allErrs, field.Invalid(field.NewPath("handler"), rc.Handler, msg))
}
if rc.Scheduling != nil {
allErrs = append(allErrs, validateScheduling(rc.Scheduling, field.NewPath("scheduling"))...)
}
return allErrs
}
@@ -47,12 +41,3 @@ func ValidateRuntimeClassUpdate(new, old *node.RuntimeClass) field.ErrorList {
return allErrs
}
func validateScheduling(s *node.Scheduling, fldPath *field.Path) field.ErrorList {
var allErrs field.ErrorList
if s.NodeSelector != nil {
allErrs = append(allErrs, unversionedvalidation.ValidateLabels(s.NodeSelector, fldPath.Child("nodeSelector"))...)
}
allErrs = append(allErrs, corevalidation.ValidateTolerations(s.Tolerations, fldPath.Child("tolerations"))...)
return allErrs
}

View File

@@ -20,7 +20,6 @@ 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"
@@ -127,70 +126,3 @@ func TestValidateRuntimeUpdate(t *testing.T) {
})
}
}
func TestValidateScheduling(t *testing.T) {
tests := []struct {
name string
scheduling *node.Scheduling
expectErrs int
}{{
name: "valid scheduling",
scheduling: &node.Scheduling{
NodeSelector: map[string]string{"valid": "yes"},
Tolerations: []core.Toleration{{
Key: "valid",
Operator: core.TolerationOpExists,
Effect: core.TaintEffectNoSchedule,
}},
},
}, {
name: "empty scheduling",
scheduling: &node.Scheduling{},
}, {
name: "invalid nodeSelector",
scheduling: &node.Scheduling{
NodeSelector: map[string]string{"not a valid key!!!": "nope"},
},
expectErrs: 1,
}, {
name: "invalid toleration",
scheduling: &node.Scheduling{
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 scheduling",
scheduling: &node.Scheduling{
NodeSelector: map[string]string{"not a valid key!!!": "nope"},
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",
Scheduling: test.scheduling,
}
assert.Len(t, ValidateRuntimeClass(rc), test.expectErrs)
})
}
}