Validate cgroups-per-qos for windows

This commit is contained in:
Pengfei Ni 2018-04-23 13:16:46 +08:00
parent 86bd977151
commit 40abe94a40
4 changed files with 112 additions and 1 deletions

View File

@ -8,7 +8,44 @@ load(
go_library(
name = "go_default_library",
srcs = ["validation.go"],
srcs = [
"validation.go",
] + select({
"@io_bazel_rules_go//go/platform:android": [
"validation_others.go",
],
"@io_bazel_rules_go//go/platform:darwin": [
"validation_others.go",
],
"@io_bazel_rules_go//go/platform:dragonfly": [
"validation_others.go",
],
"@io_bazel_rules_go//go/platform:freebsd": [
"validation_others.go",
],
"@io_bazel_rules_go//go/platform:linux": [
"validation_others.go",
],
"@io_bazel_rules_go//go/platform:nacl": [
"validation_others.go",
],
"@io_bazel_rules_go//go/platform:netbsd": [
"validation_others.go",
],
"@io_bazel_rules_go//go/platform:openbsd": [
"validation_others.go",
],
"@io_bazel_rules_go//go/platform:plan9": [
"validation_others.go",
],
"@io_bazel_rules_go//go/platform:solaris": [
"validation_others.go",
],
"@io_bazel_rules_go//go/platform:windows": [
"validation_windows.go",
],
"//conditions:default": [],
}),
importpath = "k8s.io/kubernetes/pkg/kubelet/apis/kubeletconfig/validation",
deps = [
"//pkg/features:go_default_library",

View File

@ -118,5 +118,9 @@ func ValidateKubeletConfiguration(kc *kubeletconfig.KubeletConfiguration) error
allErrors = append(allErrors, fmt.Errorf("invalid configuration: option %q specified for HairpinMode (--hairpin-mode). Valid options are %q, %q or %q",
kc.HairpinMode, kubeletconfig.HairpinNone, kubeletconfig.HairpinVeth, kubeletconfig.PromiscuousBridge))
}
if err := validateKubeletOSConfiguration(kc); err != nil {
allErrors = append(allErrors, err)
}
return utilerrors.NewAggregate(allErrors)
}

View File

@ -0,0 +1,28 @@
// +build !windows
/*
Copyright 2018 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 validation
import (
"k8s.io/kubernetes/pkg/kubelet/apis/kubeletconfig"
)
// validateKubeletOSConfiguration validates os specific kubelet configuration and returns an error if it is invalid.
func validateKubeletOSConfiguration(kc *kubeletconfig.KubeletConfiguration) error {
return nil
}

View File

@ -0,0 +1,42 @@
// +build windows
/*
Copyright 2018 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 validation
import (
"fmt"
utilerrors "k8s.io/apimachinery/pkg/util/errors"
"k8s.io/kubernetes/pkg/kubelet/apis/kubeletconfig"
)
// validateKubeletOSConfiguration validates os specific kubelet configuration and returns an error if it is invalid.
func validateKubeletOSConfiguration(kc *kubeletconfig.KubeletConfiguration) error {
message := "invalid configuration: %v (%v) %v is not supported on Windows"
allErrors := []error{}
if kc.CgroupsPerQOS {
allErrors = append(allErrors, fmt.Errorf(message, "CgroupsPerQOS", "--cgroups-per-qos", kc.CgroupsPerQOS))
}
if len(kc.EnforceNodeAllocatable) > 0 {
allErrors = append(allErrors, fmt.Errorf(message, "EnforceNodeAllocatable", "--enforce-node-allocatable", kc.EnforceNodeAllocatable))
}
return utilerrors.NewAggregate(allErrors)
}