Auto-create system critical prioity classes at API server startup

This commit is contained in:
Bobby (Babak) Salamat
2018-02-22 17:38:17 -08:00
parent 79257fe611
commit ebda9584f9
9 changed files with 180 additions and 63 deletions

View File

@@ -17,8 +17,6 @@ limitations under the License.
package validation
import (
"strings"
"k8s.io/apimachinery/pkg/util/validation/field"
apivalidation "k8s.io/kubernetes/pkg/apis/core/validation"
"k8s.io/kubernetes/pkg/apis/scheduling"
@@ -26,12 +24,7 @@ import (
// ValidatePriorityClassName checks whether the given priority class name is valid.
func ValidatePriorityClassName(name string, prefix bool) []string {
var allErrs []string
if strings.HasPrefix(name, scheduling.SystemPriorityClassPrefix) {
allErrs = append(allErrs, "priority class names with '"+scheduling.SystemPriorityClassPrefix+"' prefix are reserved for system use only")
}
allErrs = append(allErrs, apivalidation.NameIsDNSSubdomain(name, prefix)...)
return allErrs
return apivalidation.NameIsDNSSubdomain(name, prefix)
}
// ValidatePriorityClass tests whether required fields in the PriorityClass are

View File

@@ -53,10 +53,6 @@ func TestValidatePriorityClass(t *testing.T) {
ObjectMeta: metav1.ObjectMeta{Name: "tier&1", Namespace: ""},
Value: 100,
},
"invalid system name": {
ObjectMeta: metav1.ObjectMeta{Name: scheduling.SystemPriorityClassPrefix + "test"},
Value: 100,
},
}
for k, v := range errorCases {