mirror of
https://github.com/k3s-io/kubernetes.git
synced 2025-07-25 04:33:26 +00:00
Merge pull request #67487 from tianshapjq/validate-system-kube-reserved
validate systemReservedCgroup and kubeReservedCgroup
This commit is contained in:
commit
16b5f7d3c5
@ -299,6 +299,8 @@ func TestValidateKubeletConfiguration(t *testing.T) {
|
||||
Kubelet: &kubeletconfig.KubeletConfiguration{
|
||||
CgroupsPerQOS: true,
|
||||
EnforceNodeAllocatable: []string{"pods", "system-reserved", "kube-reserved"},
|
||||
SystemReservedCgroup: "/system.slice",
|
||||
KubeReservedCgroup: "/kubelet.service",
|
||||
SystemCgroups: "",
|
||||
CgroupRoot: "",
|
||||
EventBurst: 10,
|
||||
|
@ -113,7 +113,13 @@ func ValidateKubeletConfiguration(kc *kubeletconfig.KubeletConfiguration) error
|
||||
switch val {
|
||||
case kubetypes.NodeAllocatableEnforcementKey:
|
||||
case kubetypes.SystemReservedEnforcementKey:
|
||||
if kc.SystemReservedCgroup == "" {
|
||||
allErrors = append(allErrors, fmt.Errorf("invalid configuration: systemReservedCgroup (--system-reserved-cgroup) must be specified when system-reserved contained in EnforceNodeAllocatable (--enforce-node-allocatable)"))
|
||||
}
|
||||
case kubetypes.KubeReservedEnforcementKey:
|
||||
if kc.KubeReservedCgroup == "" {
|
||||
allErrors = append(allErrors, fmt.Errorf("invalid configuration: kubeReservedCgroup (--kube-reserved-cgroup) must be specified when kube-reserved contained in EnforceNodeAllocatable (--enforce-node-allocatable)"))
|
||||
}
|
||||
case kubetypes.NodeAllocatableNoneKey:
|
||||
if len(kc.EnforceNodeAllocatable) > 1 {
|
||||
allErrors = append(allErrors, fmt.Errorf("invalid configuration: EnforceNodeAllocatable (--enforce-node-allocatable) may not contain additional enforcements when '%s' is specified", kubetypes.NodeAllocatableNoneKey))
|
||||
|
@ -29,6 +29,8 @@ func TestValidateKubeletConfiguration(t *testing.T) {
|
||||
successCase := &kubeletconfig.KubeletConfiguration{
|
||||
CgroupsPerQOS: true,
|
||||
EnforceNodeAllocatable: []string{"pods", "system-reserved", "kube-reserved"},
|
||||
SystemReservedCgroup: "/system.slice",
|
||||
KubeReservedCgroup: "/kubelet.service",
|
||||
SystemCgroups: "",
|
||||
CgroupRoot: "",
|
||||
EventBurst: 10,
|
||||
@ -82,7 +84,7 @@ func TestValidateKubeletConfiguration(t *testing.T) {
|
||||
NodeLeaseDurationSeconds: -1,
|
||||
CPUCFSQuotaPeriod: metav1.Duration{Duration: 0},
|
||||
}
|
||||
const numErrs = 23
|
||||
const numErrs = 25
|
||||
if allErrors := ValidateKubeletConfiguration(errorCase); len(allErrors.(utilerrors.Aggregate).Errors()) != numErrs {
|
||||
t.Errorf("expect %d errors, got %v", numErrs, len(allErrors.(utilerrors.Aggregate).Errors()))
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user