Clean up brace whitespace in **/validation_test.go
This was making my eyes bleed as I read over code. I used the following in vim. I made them up on the fly, but they seemed to pass manual inspection. :g/},\n\s*{$/s//}, {/ :w :g/{$\n\s*{$/s//{{/ :w :g/^\(\s*\)},\n\1},$/s//}},/ :w :g/^\(\s*\)},$\n\1}$/s//}}/ :w
This commit is contained in:
@@ -86,502 +86,442 @@ func TestValidateKubeletConfiguration(t *testing.T) {
|
||||
name string
|
||||
configure func(config *kubeletconfig.KubeletConfiguration) *kubeletconfig.KubeletConfiguration
|
||||
errMsg string
|
||||
}{
|
||||
{
|
||||
name: "Success",
|
||||
configure: func(conf *kubeletconfig.KubeletConfiguration) *kubeletconfig.KubeletConfiguration {
|
||||
return conf
|
||||
},
|
||||
}{{
|
||||
name: "Success",
|
||||
configure: func(conf *kubeletconfig.KubeletConfiguration) *kubeletconfig.KubeletConfiguration {
|
||||
return conf
|
||||
},
|
||||
{
|
||||
name: "invalid NodeLeaseDurationSeconds",
|
||||
configure: func(conf *kubeletconfig.KubeletConfiguration) *kubeletconfig.KubeletConfiguration {
|
||||
conf.NodeLeaseDurationSeconds = 0
|
||||
return conf
|
||||
},
|
||||
errMsg: "invalid configuration: nodeLeaseDurationSeconds must be greater than 0",
|
||||
}, {
|
||||
name: "invalid NodeLeaseDurationSeconds",
|
||||
configure: func(conf *kubeletconfig.KubeletConfiguration) *kubeletconfig.KubeletConfiguration {
|
||||
conf.NodeLeaseDurationSeconds = 0
|
||||
return conf
|
||||
},
|
||||
{
|
||||
name: "specify EnforceNodeAllocatable without enabling CgroupsPerQOS",
|
||||
configure: func(conf *kubeletconfig.KubeletConfiguration) *kubeletconfig.KubeletConfiguration {
|
||||
conf.CgroupsPerQOS = false
|
||||
conf.EnforceNodeAllocatable = []string{"pods"}
|
||||
return conf
|
||||
},
|
||||
errMsg: "invalid configuration: enforceNodeAllocatable (--enforce-node-allocatable) is not supported unless cgroupsPerQOS (--cgroups-per-qos) is set to true",
|
||||
errMsg: "invalid configuration: nodeLeaseDurationSeconds must be greater than 0",
|
||||
}, {
|
||||
name: "specify EnforceNodeAllocatable without enabling CgroupsPerQOS",
|
||||
configure: func(conf *kubeletconfig.KubeletConfiguration) *kubeletconfig.KubeletConfiguration {
|
||||
conf.CgroupsPerQOS = false
|
||||
conf.EnforceNodeAllocatable = []string{"pods"}
|
||||
return conf
|
||||
},
|
||||
{
|
||||
name: "specify SystemCgroups without CgroupRoot",
|
||||
configure: func(conf *kubeletconfig.KubeletConfiguration) *kubeletconfig.KubeletConfiguration {
|
||||
conf.SystemCgroups = "/"
|
||||
conf.CgroupRoot = ""
|
||||
return conf
|
||||
},
|
||||
errMsg: "invalid configuration: systemCgroups (--system-cgroups) was specified and cgroupRoot (--cgroup-root) was not specified",
|
||||
errMsg: "invalid configuration: enforceNodeAllocatable (--enforce-node-allocatable) is not supported unless cgroupsPerQOS (--cgroups-per-qos) is set to true",
|
||||
}, {
|
||||
name: "specify SystemCgroups without CgroupRoot",
|
||||
configure: func(conf *kubeletconfig.KubeletConfiguration) *kubeletconfig.KubeletConfiguration {
|
||||
conf.SystemCgroups = "/"
|
||||
conf.CgroupRoot = ""
|
||||
return conf
|
||||
},
|
||||
{
|
||||
name: "invalid EventBurst",
|
||||
configure: func(conf *kubeletconfig.KubeletConfiguration) *kubeletconfig.KubeletConfiguration {
|
||||
conf.EventBurst = -1
|
||||
return conf
|
||||
},
|
||||
errMsg: "invalid configuration: eventBurst (--event-burst) -1 must not be a negative number",
|
||||
errMsg: "invalid configuration: systemCgroups (--system-cgroups) was specified and cgroupRoot (--cgroup-root) was not specified",
|
||||
}, {
|
||||
name: "invalid EventBurst",
|
||||
configure: func(conf *kubeletconfig.KubeletConfiguration) *kubeletconfig.KubeletConfiguration {
|
||||
conf.EventBurst = -1
|
||||
return conf
|
||||
},
|
||||
{
|
||||
name: "invalid EventRecordQPS",
|
||||
configure: func(conf *kubeletconfig.KubeletConfiguration) *kubeletconfig.KubeletConfiguration {
|
||||
conf.EventRecordQPS = -1
|
||||
return conf
|
||||
},
|
||||
errMsg: "invalid configuration: eventRecordQPS (--event-qps) -1 must not be a negative number",
|
||||
errMsg: "invalid configuration: eventBurst (--event-burst) -1 must not be a negative number",
|
||||
}, {
|
||||
name: "invalid EventRecordQPS",
|
||||
configure: func(conf *kubeletconfig.KubeletConfiguration) *kubeletconfig.KubeletConfiguration {
|
||||
conf.EventRecordQPS = -1
|
||||
return conf
|
||||
},
|
||||
{
|
||||
name: "invalid HealthzPort",
|
||||
configure: func(conf *kubeletconfig.KubeletConfiguration) *kubeletconfig.KubeletConfiguration {
|
||||
conf.HealthzPort = 65536
|
||||
return conf
|
||||
},
|
||||
errMsg: "invalid configuration: healthzPort (--healthz-port) 65536 must be between 1 and 65535, inclusive",
|
||||
errMsg: "invalid configuration: eventRecordQPS (--event-qps) -1 must not be a negative number",
|
||||
}, {
|
||||
name: "invalid HealthzPort",
|
||||
configure: func(conf *kubeletconfig.KubeletConfiguration) *kubeletconfig.KubeletConfiguration {
|
||||
conf.HealthzPort = 65536
|
||||
return conf
|
||||
},
|
||||
{
|
||||
name: "specify CPUCFSQuotaPeriod without enabling CPUCFSQuotaPeriod",
|
||||
configure: func(conf *kubeletconfig.KubeletConfiguration) *kubeletconfig.KubeletConfiguration {
|
||||
conf.FeatureGates = map[string]bool{"CustomCPUCFSQuotaPeriod": false}
|
||||
conf.CPUCFSQuotaPeriod = metav1.Duration{Duration: 200 * time.Millisecond}
|
||||
return conf
|
||||
},
|
||||
errMsg: "invalid configuration: cpuCFSQuotaPeriod (--cpu-cfs-quota-period) {200ms} requires feature gate CustomCPUCFSQuotaPeriod",
|
||||
errMsg: "invalid configuration: healthzPort (--healthz-port) 65536 must be between 1 and 65535, inclusive",
|
||||
}, {
|
||||
name: "specify CPUCFSQuotaPeriod without enabling CPUCFSQuotaPeriod",
|
||||
configure: func(conf *kubeletconfig.KubeletConfiguration) *kubeletconfig.KubeletConfiguration {
|
||||
conf.FeatureGates = map[string]bool{"CustomCPUCFSQuotaPeriod": false}
|
||||
conf.CPUCFSQuotaPeriod = metav1.Duration{Duration: 200 * time.Millisecond}
|
||||
return conf
|
||||
},
|
||||
{
|
||||
name: "invalid CPUCFSQuotaPeriod",
|
||||
configure: func(conf *kubeletconfig.KubeletConfiguration) *kubeletconfig.KubeletConfiguration {
|
||||
conf.FeatureGates = map[string]bool{"CustomCPUCFSQuotaPeriod": true}
|
||||
conf.CPUCFSQuotaPeriod = metav1.Duration{Duration: 2 * time.Second}
|
||||
return conf
|
||||
},
|
||||
errMsg: "invalid configuration: cpuCFSQuotaPeriod (--cpu-cfs-quota-period) {2s} must be between 1ms and 1sec, inclusive",
|
||||
errMsg: "invalid configuration: cpuCFSQuotaPeriod (--cpu-cfs-quota-period) {200ms} requires feature gate CustomCPUCFSQuotaPeriod",
|
||||
}, {
|
||||
name: "invalid CPUCFSQuotaPeriod",
|
||||
configure: func(conf *kubeletconfig.KubeletConfiguration) *kubeletconfig.KubeletConfiguration {
|
||||
conf.FeatureGates = map[string]bool{"CustomCPUCFSQuotaPeriod": true}
|
||||
conf.CPUCFSQuotaPeriod = metav1.Duration{Duration: 2 * time.Second}
|
||||
return conf
|
||||
},
|
||||
{
|
||||
name: "invalid ImageGCHighThresholdPercent",
|
||||
configure: func(conf *kubeletconfig.KubeletConfiguration) *kubeletconfig.KubeletConfiguration {
|
||||
conf.ImageGCHighThresholdPercent = 101
|
||||
return conf
|
||||
},
|
||||
errMsg: "invalid configuration: imageGCHighThresholdPercent (--image-gc-high-threshold) 101 must be between 0 and 100, inclusive",
|
||||
errMsg: "invalid configuration: cpuCFSQuotaPeriod (--cpu-cfs-quota-period) {2s} must be between 1ms and 1sec, inclusive",
|
||||
}, {
|
||||
name: "invalid ImageGCHighThresholdPercent",
|
||||
configure: func(conf *kubeletconfig.KubeletConfiguration) *kubeletconfig.KubeletConfiguration {
|
||||
conf.ImageGCHighThresholdPercent = 101
|
||||
return conf
|
||||
},
|
||||
{
|
||||
name: "invalid ImageGCLowThresholdPercent",
|
||||
configure: func(conf *kubeletconfig.KubeletConfiguration) *kubeletconfig.KubeletConfiguration {
|
||||
conf.ImageGCLowThresholdPercent = -1
|
||||
return conf
|
||||
},
|
||||
errMsg: "invalid configuration: imageGCLowThresholdPercent (--image-gc-low-threshold) -1 must be between 0 and 100, inclusive",
|
||||
errMsg: "invalid configuration: imageGCHighThresholdPercent (--image-gc-high-threshold) 101 must be between 0 and 100, inclusive",
|
||||
}, {
|
||||
name: "invalid ImageGCLowThresholdPercent",
|
||||
configure: func(conf *kubeletconfig.KubeletConfiguration) *kubeletconfig.KubeletConfiguration {
|
||||
conf.ImageGCLowThresholdPercent = -1
|
||||
return conf
|
||||
},
|
||||
{
|
||||
name: "ImageGCLowThresholdPercent is equal to ImageGCHighThresholdPercent",
|
||||
configure: func(conf *kubeletconfig.KubeletConfiguration) *kubeletconfig.KubeletConfiguration {
|
||||
conf.ImageGCHighThresholdPercent = 0
|
||||
conf.ImageGCLowThresholdPercent = 0
|
||||
return conf
|
||||
},
|
||||
errMsg: "invalid configuration: imageGCLowThresholdPercent (--image-gc-low-threshold) 0 must be less than imageGCHighThresholdPercent (--image-gc-high-threshold) 0",
|
||||
errMsg: "invalid configuration: imageGCLowThresholdPercent (--image-gc-low-threshold) -1 must be between 0 and 100, inclusive",
|
||||
}, {
|
||||
name: "ImageGCLowThresholdPercent is equal to ImageGCHighThresholdPercent",
|
||||
configure: func(conf *kubeletconfig.KubeletConfiguration) *kubeletconfig.KubeletConfiguration {
|
||||
conf.ImageGCHighThresholdPercent = 0
|
||||
conf.ImageGCLowThresholdPercent = 0
|
||||
return conf
|
||||
},
|
||||
{
|
||||
name: "ImageGCLowThresholdPercent is greater than ImageGCHighThresholdPercent",
|
||||
configure: func(conf *kubeletconfig.KubeletConfiguration) *kubeletconfig.KubeletConfiguration {
|
||||
conf.ImageGCHighThresholdPercent = 0
|
||||
conf.ImageGCLowThresholdPercent = 1
|
||||
return conf
|
||||
},
|
||||
errMsg: "invalid configuration: imageGCLowThresholdPercent (--image-gc-low-threshold) 1 must be less than imageGCHighThresholdPercent (--image-gc-high-threshold) 0",
|
||||
errMsg: "invalid configuration: imageGCLowThresholdPercent (--image-gc-low-threshold) 0 must be less than imageGCHighThresholdPercent (--image-gc-high-threshold) 0",
|
||||
}, {
|
||||
name: "ImageGCLowThresholdPercent is greater than ImageGCHighThresholdPercent",
|
||||
configure: func(conf *kubeletconfig.KubeletConfiguration) *kubeletconfig.KubeletConfiguration {
|
||||
conf.ImageGCHighThresholdPercent = 0
|
||||
conf.ImageGCLowThresholdPercent = 1
|
||||
return conf
|
||||
},
|
||||
{
|
||||
name: "invalid IPTablesDropBit",
|
||||
configure: func(conf *kubeletconfig.KubeletConfiguration) *kubeletconfig.KubeletConfiguration {
|
||||
conf.IPTablesDropBit = 32
|
||||
return conf
|
||||
},
|
||||
errMsg: "invalid configuration: iptablesDropBit (--iptables-drop-bit) 32 must be between 0 and 31, inclusive",
|
||||
errMsg: "invalid configuration: imageGCLowThresholdPercent (--image-gc-low-threshold) 1 must be less than imageGCHighThresholdPercent (--image-gc-high-threshold) 0",
|
||||
}, {
|
||||
name: "invalid IPTablesDropBit",
|
||||
configure: func(conf *kubeletconfig.KubeletConfiguration) *kubeletconfig.KubeletConfiguration {
|
||||
conf.IPTablesDropBit = 32
|
||||
return conf
|
||||
},
|
||||
{
|
||||
name: "invalid IPTablesMasqueradeBit",
|
||||
configure: func(conf *kubeletconfig.KubeletConfiguration) *kubeletconfig.KubeletConfiguration {
|
||||
conf.IPTablesMasqueradeBit = 32
|
||||
return conf
|
||||
},
|
||||
errMsg: "invalid configuration: iptablesMasqueradeBit (--iptables-masquerade-bit) 32 must be between 0 and 31, inclusive",
|
||||
errMsg: "invalid configuration: iptablesDropBit (--iptables-drop-bit) 32 must be between 0 and 31, inclusive",
|
||||
}, {
|
||||
name: "invalid IPTablesMasqueradeBit",
|
||||
configure: func(conf *kubeletconfig.KubeletConfiguration) *kubeletconfig.KubeletConfiguration {
|
||||
conf.IPTablesMasqueradeBit = 32
|
||||
return conf
|
||||
},
|
||||
{
|
||||
name: "invalid KubeAPIBurst",
|
||||
configure: func(conf *kubeletconfig.KubeletConfiguration) *kubeletconfig.KubeletConfiguration {
|
||||
conf.KubeAPIBurst = -1
|
||||
return conf
|
||||
},
|
||||
errMsg: "invalid configuration: kubeAPIBurst (--kube-api-burst) -1 must not be a negative number",
|
||||
errMsg: "invalid configuration: iptablesMasqueradeBit (--iptables-masquerade-bit) 32 must be between 0 and 31, inclusive",
|
||||
}, {
|
||||
name: "invalid KubeAPIBurst",
|
||||
configure: func(conf *kubeletconfig.KubeletConfiguration) *kubeletconfig.KubeletConfiguration {
|
||||
conf.KubeAPIBurst = -1
|
||||
return conf
|
||||
},
|
||||
{
|
||||
name: "invalid KubeAPIQPS",
|
||||
configure: func(conf *kubeletconfig.KubeletConfiguration) *kubeletconfig.KubeletConfiguration {
|
||||
conf.KubeAPIQPS = -1
|
||||
return conf
|
||||
},
|
||||
errMsg: "invalid configuration: kubeAPIQPS (--kube-api-qps) -1 must not be a negative number",
|
||||
errMsg: "invalid configuration: kubeAPIBurst (--kube-api-burst) -1 must not be a negative number",
|
||||
}, {
|
||||
name: "invalid KubeAPIQPS",
|
||||
configure: func(conf *kubeletconfig.KubeletConfiguration) *kubeletconfig.KubeletConfiguration {
|
||||
conf.KubeAPIQPS = -1
|
||||
return conf
|
||||
},
|
||||
{
|
||||
name: "invalid NodeStatusMaxImages",
|
||||
configure: func(conf *kubeletconfig.KubeletConfiguration) *kubeletconfig.KubeletConfiguration {
|
||||
conf.NodeStatusMaxImages = -2
|
||||
return conf
|
||||
},
|
||||
errMsg: "invalid configuration: nodeStatusMaxImages (--node-status-max-images) -2 must be -1 or greater",
|
||||
errMsg: "invalid configuration: kubeAPIQPS (--kube-api-qps) -1 must not be a negative number",
|
||||
}, {
|
||||
name: "invalid NodeStatusMaxImages",
|
||||
configure: func(conf *kubeletconfig.KubeletConfiguration) *kubeletconfig.KubeletConfiguration {
|
||||
conf.NodeStatusMaxImages = -2
|
||||
return conf
|
||||
},
|
||||
{
|
||||
name: "invalid MaxOpenFiles",
|
||||
configure: func(conf *kubeletconfig.KubeletConfiguration) *kubeletconfig.KubeletConfiguration {
|
||||
conf.MaxOpenFiles = -1
|
||||
return conf
|
||||
},
|
||||
errMsg: "invalid configuration: maxOpenFiles (--max-open-files) -1 must not be a negative number",
|
||||
errMsg: "invalid configuration: nodeStatusMaxImages (--node-status-max-images) -2 must be -1 or greater",
|
||||
}, {
|
||||
name: "invalid MaxOpenFiles",
|
||||
configure: func(conf *kubeletconfig.KubeletConfiguration) *kubeletconfig.KubeletConfiguration {
|
||||
conf.MaxOpenFiles = -1
|
||||
return conf
|
||||
},
|
||||
{
|
||||
name: "invalid MaxPods",
|
||||
configure: func(conf *kubeletconfig.KubeletConfiguration) *kubeletconfig.KubeletConfiguration {
|
||||
conf.MaxPods = -1
|
||||
return conf
|
||||
},
|
||||
errMsg: "invalid configuration: maxPods (--max-pods) -1 must not be a negative number",
|
||||
errMsg: "invalid configuration: maxOpenFiles (--max-open-files) -1 must not be a negative number",
|
||||
}, {
|
||||
name: "invalid MaxPods",
|
||||
configure: func(conf *kubeletconfig.KubeletConfiguration) *kubeletconfig.KubeletConfiguration {
|
||||
conf.MaxPods = -1
|
||||
return conf
|
||||
},
|
||||
{
|
||||
name: "invalid OOMScoreAdj",
|
||||
configure: func(conf *kubeletconfig.KubeletConfiguration) *kubeletconfig.KubeletConfiguration {
|
||||
conf.OOMScoreAdj = 1001
|
||||
return conf
|
||||
},
|
||||
errMsg: "invalid configuration: oomScoreAdj (--oom-score-adj) 1001 must be between -1000 and 1000, inclusive",
|
||||
errMsg: "invalid configuration: maxPods (--max-pods) -1 must not be a negative number",
|
||||
}, {
|
||||
name: "invalid OOMScoreAdj",
|
||||
configure: func(conf *kubeletconfig.KubeletConfiguration) *kubeletconfig.KubeletConfiguration {
|
||||
conf.OOMScoreAdj = 1001
|
||||
return conf
|
||||
},
|
||||
{
|
||||
name: "invalid PodsPerCore",
|
||||
configure: func(conf *kubeletconfig.KubeletConfiguration) *kubeletconfig.KubeletConfiguration {
|
||||
conf.PodsPerCore = -1
|
||||
return conf
|
||||
},
|
||||
errMsg: "invalid configuration: podsPerCore (--pods-per-core) -1 must not be a negative number",
|
||||
errMsg: "invalid configuration: oomScoreAdj (--oom-score-adj) 1001 must be between -1000 and 1000, inclusive",
|
||||
}, {
|
||||
name: "invalid PodsPerCore",
|
||||
configure: func(conf *kubeletconfig.KubeletConfiguration) *kubeletconfig.KubeletConfiguration {
|
||||
conf.PodsPerCore = -1
|
||||
return conf
|
||||
},
|
||||
{
|
||||
name: "invalid Port",
|
||||
configure: func(conf *kubeletconfig.KubeletConfiguration) *kubeletconfig.KubeletConfiguration {
|
||||
conf.Port = 65536
|
||||
return conf
|
||||
},
|
||||
errMsg: "invalid configuration: port (--port) 65536 must be between 1 and 65535, inclusive",
|
||||
errMsg: "invalid configuration: podsPerCore (--pods-per-core) -1 must not be a negative number",
|
||||
}, {
|
||||
name: "invalid Port",
|
||||
configure: func(conf *kubeletconfig.KubeletConfiguration) *kubeletconfig.KubeletConfiguration {
|
||||
conf.Port = 65536
|
||||
return conf
|
||||
},
|
||||
{
|
||||
name: "invalid ReadOnlyPort",
|
||||
configure: func(conf *kubeletconfig.KubeletConfiguration) *kubeletconfig.KubeletConfiguration {
|
||||
conf.ReadOnlyPort = 65536
|
||||
return conf
|
||||
},
|
||||
errMsg: "invalid configuration: readOnlyPort (--read-only-port) 65536 must be between 0 and 65535, inclusive",
|
||||
errMsg: "invalid configuration: port (--port) 65536 must be between 1 and 65535, inclusive",
|
||||
}, {
|
||||
name: "invalid ReadOnlyPort",
|
||||
configure: func(conf *kubeletconfig.KubeletConfiguration) *kubeletconfig.KubeletConfiguration {
|
||||
conf.ReadOnlyPort = 65536
|
||||
return conf
|
||||
},
|
||||
{
|
||||
name: "invalid RegistryBurst",
|
||||
configure: func(conf *kubeletconfig.KubeletConfiguration) *kubeletconfig.KubeletConfiguration {
|
||||
conf.RegistryBurst = -1
|
||||
return conf
|
||||
},
|
||||
errMsg: "invalid configuration: registryBurst (--registry-burst) -1 must not be a negative number",
|
||||
errMsg: "invalid configuration: readOnlyPort (--read-only-port) 65536 must be between 0 and 65535, inclusive",
|
||||
}, {
|
||||
name: "invalid RegistryBurst",
|
||||
configure: func(conf *kubeletconfig.KubeletConfiguration) *kubeletconfig.KubeletConfiguration {
|
||||
conf.RegistryBurst = -1
|
||||
return conf
|
||||
},
|
||||
{
|
||||
name: "invalid RegistryPullQPS",
|
||||
configure: func(conf *kubeletconfig.KubeletConfiguration) *kubeletconfig.KubeletConfiguration {
|
||||
conf.RegistryPullQPS = -1
|
||||
return conf
|
||||
},
|
||||
errMsg: "invalid configuration: registryPullQPS (--registry-qps) -1 must not be a negative number",
|
||||
errMsg: "invalid configuration: registryBurst (--registry-burst) -1 must not be a negative number",
|
||||
}, {
|
||||
name: "invalid RegistryPullQPS",
|
||||
configure: func(conf *kubeletconfig.KubeletConfiguration) *kubeletconfig.KubeletConfiguration {
|
||||
conf.RegistryPullQPS = -1
|
||||
return conf
|
||||
},
|
||||
{
|
||||
name: "invalid MaxParallelImagePulls",
|
||||
configure: func(conf *kubeletconfig.KubeletConfiguration) *kubeletconfig.KubeletConfiguration {
|
||||
conf.MaxParallelImagePulls = utilpointer.Int32(0)
|
||||
return conf
|
||||
},
|
||||
errMsg: "invalid configuration: maxParallelImagePulls 0 must be a positive number",
|
||||
errMsg: "invalid configuration: registryPullQPS (--registry-qps) -1 must not be a negative number",
|
||||
}, {
|
||||
name: "invalid MaxParallelImagePulls",
|
||||
configure: func(conf *kubeletconfig.KubeletConfiguration) *kubeletconfig.KubeletConfiguration {
|
||||
conf.MaxParallelImagePulls = utilpointer.Int32(0)
|
||||
return conf
|
||||
},
|
||||
{
|
||||
name: "invalid MaxParallelImagePulls and SerializeImagePulls combination",
|
||||
configure: func(conf *kubeletconfig.KubeletConfiguration) *kubeletconfig.KubeletConfiguration {
|
||||
conf.MaxParallelImagePulls = utilpointer.Int32(3)
|
||||
conf.SerializeImagePulls = true
|
||||
return conf
|
||||
},
|
||||
errMsg: "invalid configuration: maxParallelImagePulls cannot be larger than 1 unless SerializeImagePulls (--serialize-image-pulls) is set to false",
|
||||
errMsg: "invalid configuration: maxParallelImagePulls 0 must be a positive number",
|
||||
}, {
|
||||
name: "invalid MaxParallelImagePulls and SerializeImagePulls combination",
|
||||
configure: func(conf *kubeletconfig.KubeletConfiguration) *kubeletconfig.KubeletConfiguration {
|
||||
conf.MaxParallelImagePulls = utilpointer.Int32(3)
|
||||
conf.SerializeImagePulls = true
|
||||
return conf
|
||||
},
|
||||
{
|
||||
name: "valid MaxParallelImagePulls and SerializeImagePulls combination",
|
||||
configure: func(conf *kubeletconfig.KubeletConfiguration) *kubeletconfig.KubeletConfiguration {
|
||||
conf.MaxParallelImagePulls = utilpointer.Int32(1)
|
||||
conf.SerializeImagePulls = true
|
||||
return conf
|
||||
},
|
||||
errMsg: "invalid configuration: maxParallelImagePulls cannot be larger than 1 unless SerializeImagePulls (--serialize-image-pulls) is set to false",
|
||||
}, {
|
||||
name: "valid MaxParallelImagePulls and SerializeImagePulls combination",
|
||||
configure: func(conf *kubeletconfig.KubeletConfiguration) *kubeletconfig.KubeletConfiguration {
|
||||
conf.MaxParallelImagePulls = utilpointer.Int32(1)
|
||||
conf.SerializeImagePulls = true
|
||||
return conf
|
||||
},
|
||||
{
|
||||
name: "specify ServerTLSBootstrap without enabling RotateKubeletServerCertificate",
|
||||
configure: func(conf *kubeletconfig.KubeletConfiguration) *kubeletconfig.KubeletConfiguration {
|
||||
conf.FeatureGates = map[string]bool{"RotateKubeletServerCertificate": false}
|
||||
conf.ServerTLSBootstrap = true
|
||||
return conf
|
||||
},
|
||||
errMsg: "invalid configuration: serverTLSBootstrap true requires feature gate RotateKubeletServerCertificate",
|
||||
}, {
|
||||
name: "specify ServerTLSBootstrap without enabling RotateKubeletServerCertificate",
|
||||
configure: func(conf *kubeletconfig.KubeletConfiguration) *kubeletconfig.KubeletConfiguration {
|
||||
conf.FeatureGates = map[string]bool{"RotateKubeletServerCertificate": false}
|
||||
conf.ServerTLSBootstrap = true
|
||||
return conf
|
||||
},
|
||||
{
|
||||
name: "invalid TopologyManagerPolicy",
|
||||
configure: func(conf *kubeletconfig.KubeletConfiguration) *kubeletconfig.KubeletConfiguration {
|
||||
conf.TopologyManagerPolicy = "invalid-policy"
|
||||
return conf
|
||||
},
|
||||
errMsg: "invalid configuration: topologyManagerPolicy (--topology-manager-policy) \"invalid-policy\" must be one of: [\"none\" \"best-effort\" \"restricted\" \"single-numa-node\"]",
|
||||
errMsg: "invalid configuration: serverTLSBootstrap true requires feature gate RotateKubeletServerCertificate",
|
||||
}, {
|
||||
name: "invalid TopologyManagerPolicy",
|
||||
configure: func(conf *kubeletconfig.KubeletConfiguration) *kubeletconfig.KubeletConfiguration {
|
||||
conf.TopologyManagerPolicy = "invalid-policy"
|
||||
return conf
|
||||
},
|
||||
{
|
||||
name: "invalid TopologyManagerScope",
|
||||
configure: func(conf *kubeletconfig.KubeletConfiguration) *kubeletconfig.KubeletConfiguration {
|
||||
conf.TopologyManagerScope = "invalid-scope"
|
||||
return conf
|
||||
},
|
||||
errMsg: "invalid configuration: topologyManagerScope (--topology-manager-scope) \"invalid-scope\" must be one of: \"container\", or \"pod\"",
|
||||
errMsg: "invalid configuration: topologyManagerPolicy (--topology-manager-policy) \"invalid-policy\" must be one of: [\"none\" \"best-effort\" \"restricted\" \"single-numa-node\"]",
|
||||
}, {
|
||||
name: "invalid TopologyManagerScope",
|
||||
configure: func(conf *kubeletconfig.KubeletConfiguration) *kubeletconfig.KubeletConfiguration {
|
||||
conf.TopologyManagerScope = "invalid-scope"
|
||||
return conf
|
||||
},
|
||||
{
|
||||
name: "ShutdownGracePeriodCriticalPods is greater than ShutdownGracePeriod",
|
||||
configure: func(conf *kubeletconfig.KubeletConfiguration) *kubeletconfig.KubeletConfiguration {
|
||||
conf.FeatureGates = map[string]bool{"GracefulNodeShutdown": true}
|
||||
conf.ShutdownGracePeriodCriticalPods = metav1.Duration{Duration: 2 * time.Second}
|
||||
conf.ShutdownGracePeriod = metav1.Duration{Duration: 1 * time.Second}
|
||||
return conf
|
||||
},
|
||||
errMsg: "invalid configuration: shutdownGracePeriodCriticalPods {2s} must be <= shutdownGracePeriod {1s}",
|
||||
errMsg: "invalid configuration: topologyManagerScope (--topology-manager-scope) \"invalid-scope\" must be one of: \"container\", or \"pod\"",
|
||||
}, {
|
||||
name: "ShutdownGracePeriodCriticalPods is greater than ShutdownGracePeriod",
|
||||
configure: func(conf *kubeletconfig.KubeletConfiguration) *kubeletconfig.KubeletConfiguration {
|
||||
conf.FeatureGates = map[string]bool{"GracefulNodeShutdown": true}
|
||||
conf.ShutdownGracePeriodCriticalPods = metav1.Duration{Duration: 2 * time.Second}
|
||||
conf.ShutdownGracePeriod = metav1.Duration{Duration: 1 * time.Second}
|
||||
return conf
|
||||
},
|
||||
{
|
||||
name: "ShutdownGracePeriod is less than 1 sec",
|
||||
configure: func(conf *kubeletconfig.KubeletConfiguration) *kubeletconfig.KubeletConfiguration {
|
||||
conf.FeatureGates = map[string]bool{"GracefulNodeShutdown": true}
|
||||
conf.ShutdownGracePeriod = metav1.Duration{Duration: 1 * time.Millisecond}
|
||||
return conf
|
||||
},
|
||||
errMsg: "invalid configuration: shutdownGracePeriod {1ms} must be either zero or otherwise >= 1 sec",
|
||||
errMsg: "invalid configuration: shutdownGracePeriodCriticalPods {2s} must be <= shutdownGracePeriod {1s}",
|
||||
}, {
|
||||
name: "ShutdownGracePeriod is less than 1 sec",
|
||||
configure: func(conf *kubeletconfig.KubeletConfiguration) *kubeletconfig.KubeletConfiguration {
|
||||
conf.FeatureGates = map[string]bool{"GracefulNodeShutdown": true}
|
||||
conf.ShutdownGracePeriod = metav1.Duration{Duration: 1 * time.Millisecond}
|
||||
return conf
|
||||
},
|
||||
{
|
||||
name: "ShutdownGracePeriodCriticalPods is less than 1 sec",
|
||||
configure: func(conf *kubeletconfig.KubeletConfiguration) *kubeletconfig.KubeletConfiguration {
|
||||
conf.FeatureGates = map[string]bool{"GracefulNodeShutdown": true}
|
||||
conf.ShutdownGracePeriodCriticalPods = metav1.Duration{Duration: 1 * time.Millisecond}
|
||||
return conf
|
||||
},
|
||||
errMsg: "invalid configuration: shutdownGracePeriodCriticalPods {1ms} must be either zero or otherwise >= 1 sec",
|
||||
errMsg: "invalid configuration: shutdownGracePeriod {1ms} must be either zero or otherwise >= 1 sec",
|
||||
}, {
|
||||
name: "ShutdownGracePeriodCriticalPods is less than 1 sec",
|
||||
configure: func(conf *kubeletconfig.KubeletConfiguration) *kubeletconfig.KubeletConfiguration {
|
||||
conf.FeatureGates = map[string]bool{"GracefulNodeShutdown": true}
|
||||
conf.ShutdownGracePeriodCriticalPods = metav1.Duration{Duration: 1 * time.Millisecond}
|
||||
return conf
|
||||
},
|
||||
{
|
||||
name: "specify ShutdownGracePeriod without enabling GracefulNodeShutdown",
|
||||
configure: func(conf *kubeletconfig.KubeletConfiguration) *kubeletconfig.KubeletConfiguration {
|
||||
conf.FeatureGates = map[string]bool{"GracefulNodeShutdown": false}
|
||||
conf.ShutdownGracePeriod = metav1.Duration{Duration: 1 * time.Second}
|
||||
return conf
|
||||
},
|
||||
errMsg: "invalid configuration: specifying shutdownGracePeriod or shutdownGracePeriodCriticalPods requires feature gate GracefulNodeShutdown",
|
||||
errMsg: "invalid configuration: shutdownGracePeriodCriticalPods {1ms} must be either zero or otherwise >= 1 sec",
|
||||
}, {
|
||||
name: "specify ShutdownGracePeriod without enabling GracefulNodeShutdown",
|
||||
configure: func(conf *kubeletconfig.KubeletConfiguration) *kubeletconfig.KubeletConfiguration {
|
||||
conf.FeatureGates = map[string]bool{"GracefulNodeShutdown": false}
|
||||
conf.ShutdownGracePeriod = metav1.Duration{Duration: 1 * time.Second}
|
||||
return conf
|
||||
},
|
||||
{
|
||||
name: "specify ShutdownGracePeriodCriticalPods without enabling GracefulNodeShutdown",
|
||||
configure: func(conf *kubeletconfig.KubeletConfiguration) *kubeletconfig.KubeletConfiguration {
|
||||
conf.FeatureGates = map[string]bool{"GracefulNodeShutdown": false}
|
||||
conf.ShutdownGracePeriodCriticalPods = metav1.Duration{Duration: 1 * time.Second}
|
||||
return conf
|
||||
},
|
||||
errMsg: "invalid configuration: specifying shutdownGracePeriod or shutdownGracePeriodCriticalPods requires feature gate GracefulNodeShutdown",
|
||||
errMsg: "invalid configuration: specifying shutdownGracePeriod or shutdownGracePeriodCriticalPods requires feature gate GracefulNodeShutdown",
|
||||
}, {
|
||||
name: "specify ShutdownGracePeriodCriticalPods without enabling GracefulNodeShutdown",
|
||||
configure: func(conf *kubeletconfig.KubeletConfiguration) *kubeletconfig.KubeletConfiguration {
|
||||
conf.FeatureGates = map[string]bool{"GracefulNodeShutdown": false}
|
||||
conf.ShutdownGracePeriodCriticalPods = metav1.Duration{Duration: 1 * time.Second}
|
||||
return conf
|
||||
},
|
||||
{
|
||||
name: "invalid MemorySwap.SwapBehavior",
|
||||
configure: func(conf *kubeletconfig.KubeletConfiguration) *kubeletconfig.KubeletConfiguration {
|
||||
conf.FeatureGates = map[string]bool{"NodeSwap": true}
|
||||
conf.MemorySwap.SwapBehavior = "invalid-behavior"
|
||||
return conf
|
||||
},
|
||||
errMsg: "invalid configuration: memorySwap.swapBehavior \"invalid-behavior\" must be one of: \"\", \"LimitedSwap\", or \"UnlimitedSwap\"",
|
||||
errMsg: "invalid configuration: specifying shutdownGracePeriod or shutdownGracePeriodCriticalPods requires feature gate GracefulNodeShutdown",
|
||||
}, {
|
||||
name: "invalid MemorySwap.SwapBehavior",
|
||||
configure: func(conf *kubeletconfig.KubeletConfiguration) *kubeletconfig.KubeletConfiguration {
|
||||
conf.FeatureGates = map[string]bool{"NodeSwap": true}
|
||||
conf.MemorySwap.SwapBehavior = "invalid-behavior"
|
||||
return conf
|
||||
},
|
||||
{
|
||||
name: "specify MemorySwap.SwapBehavior without enabling NodeSwap",
|
||||
configure: func(conf *kubeletconfig.KubeletConfiguration) *kubeletconfig.KubeletConfiguration {
|
||||
conf.FeatureGates = map[string]bool{"NodeSwap": false}
|
||||
conf.MemorySwap.SwapBehavior = kubetypes.LimitedSwap
|
||||
return conf
|
||||
},
|
||||
errMsg: "invalid configuration: memorySwap.swapBehavior cannot be set when NodeSwap feature flag is disabled",
|
||||
errMsg: "invalid configuration: memorySwap.swapBehavior \"invalid-behavior\" must be one of: \"\", \"LimitedSwap\", or \"UnlimitedSwap\"",
|
||||
}, {
|
||||
name: "specify MemorySwap.SwapBehavior without enabling NodeSwap",
|
||||
configure: func(conf *kubeletconfig.KubeletConfiguration) *kubeletconfig.KubeletConfiguration {
|
||||
conf.FeatureGates = map[string]bool{"NodeSwap": false}
|
||||
conf.MemorySwap.SwapBehavior = kubetypes.LimitedSwap
|
||||
return conf
|
||||
},
|
||||
{
|
||||
name: "specify SystemReservedEnforcementKey without specifying SystemReservedCgroup",
|
||||
configure: func(conf *kubeletconfig.KubeletConfiguration) *kubeletconfig.KubeletConfiguration {
|
||||
conf.EnforceNodeAllocatable = []string{kubetypes.SystemReservedEnforcementKey}
|
||||
conf.SystemReservedCgroup = ""
|
||||
return conf
|
||||
},
|
||||
errMsg: "invalid configuration: systemReservedCgroup (--system-reserved-cgroup) must be specified when \"system-reserved\" contained in enforceNodeAllocatable (--enforce-node-allocatable)",
|
||||
errMsg: "invalid configuration: memorySwap.swapBehavior cannot be set when NodeSwap feature flag is disabled",
|
||||
}, {
|
||||
name: "specify SystemReservedEnforcementKey without specifying SystemReservedCgroup",
|
||||
configure: func(conf *kubeletconfig.KubeletConfiguration) *kubeletconfig.KubeletConfiguration {
|
||||
conf.EnforceNodeAllocatable = []string{kubetypes.SystemReservedEnforcementKey}
|
||||
conf.SystemReservedCgroup = ""
|
||||
return conf
|
||||
},
|
||||
{
|
||||
name: "specify KubeReservedEnforcementKey without specifying KubeReservedCgroup",
|
||||
configure: func(conf *kubeletconfig.KubeletConfiguration) *kubeletconfig.KubeletConfiguration {
|
||||
conf.EnforceNodeAllocatable = []string{kubetypes.KubeReservedEnforcementKey}
|
||||
conf.KubeReservedCgroup = ""
|
||||
return conf
|
||||
},
|
||||
errMsg: "invalid configuration: kubeReservedCgroup (--kube-reserved-cgroup) must be specified when \"kube-reserved\" contained in enforceNodeAllocatable (--enforce-node-allocatable)",
|
||||
errMsg: "invalid configuration: systemReservedCgroup (--system-reserved-cgroup) must be specified when \"system-reserved\" contained in enforceNodeAllocatable (--enforce-node-allocatable)",
|
||||
}, {
|
||||
name: "specify KubeReservedEnforcementKey without specifying KubeReservedCgroup",
|
||||
configure: func(conf *kubeletconfig.KubeletConfiguration) *kubeletconfig.KubeletConfiguration {
|
||||
conf.EnforceNodeAllocatable = []string{kubetypes.KubeReservedEnforcementKey}
|
||||
conf.KubeReservedCgroup = ""
|
||||
return conf
|
||||
},
|
||||
{
|
||||
name: "specify NodeAllocatableNoneKey with additional enforcements",
|
||||
configure: func(conf *kubeletconfig.KubeletConfiguration) *kubeletconfig.KubeletConfiguration {
|
||||
conf.EnforceNodeAllocatable = []string{kubetypes.NodeAllocatableNoneKey, kubetypes.KubeReservedEnforcementKey}
|
||||
return conf
|
||||
},
|
||||
errMsg: "invalid configuration: enforceNodeAllocatable (--enforce-node-allocatable) may not contain additional enforcements when \"none\" is specified",
|
||||
errMsg: "invalid configuration: kubeReservedCgroup (--kube-reserved-cgroup) must be specified when \"kube-reserved\" contained in enforceNodeAllocatable (--enforce-node-allocatable)",
|
||||
}, {
|
||||
name: "specify NodeAllocatableNoneKey with additional enforcements",
|
||||
configure: func(conf *kubeletconfig.KubeletConfiguration) *kubeletconfig.KubeletConfiguration {
|
||||
conf.EnforceNodeAllocatable = []string{kubetypes.NodeAllocatableNoneKey, kubetypes.KubeReservedEnforcementKey}
|
||||
return conf
|
||||
},
|
||||
{
|
||||
name: "invalid EnforceNodeAllocatable",
|
||||
configure: func(conf *kubeletconfig.KubeletConfiguration) *kubeletconfig.KubeletConfiguration {
|
||||
conf.EnforceNodeAllocatable = []string{"invalid-enforce-node-allocatable"}
|
||||
return conf
|
||||
},
|
||||
errMsg: "invalid configuration: option \"invalid-enforce-node-allocatable\" specified for enforceNodeAllocatable (--enforce-node-allocatable). Valid options are \"pods\", \"system-reserved\", \"kube-reserved\", or \"none\"",
|
||||
errMsg: "invalid configuration: enforceNodeAllocatable (--enforce-node-allocatable) may not contain additional enforcements when \"none\" is specified",
|
||||
}, {
|
||||
name: "invalid EnforceNodeAllocatable",
|
||||
configure: func(conf *kubeletconfig.KubeletConfiguration) *kubeletconfig.KubeletConfiguration {
|
||||
conf.EnforceNodeAllocatable = []string{"invalid-enforce-node-allocatable"}
|
||||
return conf
|
||||
},
|
||||
{
|
||||
name: "invalid HairpinMode",
|
||||
configure: func(conf *kubeletconfig.KubeletConfiguration) *kubeletconfig.KubeletConfiguration {
|
||||
conf.HairpinMode = "invalid-hair-pin-mode"
|
||||
return conf
|
||||
},
|
||||
errMsg: "invalid configuration: option \"invalid-hair-pin-mode\" specified for hairpinMode (--hairpin-mode). Valid options are \"none\", \"hairpin-veth\" or \"promiscuous-bridge\"",
|
||||
errMsg: "invalid configuration: option \"invalid-enforce-node-allocatable\" specified for enforceNodeAllocatable (--enforce-node-allocatable). Valid options are \"pods\", \"system-reserved\", \"kube-reserved\", or \"none\"",
|
||||
}, {
|
||||
name: "invalid HairpinMode",
|
||||
configure: func(conf *kubeletconfig.KubeletConfiguration) *kubeletconfig.KubeletConfiguration {
|
||||
conf.HairpinMode = "invalid-hair-pin-mode"
|
||||
return conf
|
||||
},
|
||||
{
|
||||
name: "specify ReservedSystemCPUs with SystemReservedCgroup",
|
||||
configure: func(conf *kubeletconfig.KubeletConfiguration) *kubeletconfig.KubeletConfiguration {
|
||||
conf.ReservedSystemCPUs = "0-3"
|
||||
conf.SystemReservedCgroup = "/system.slice"
|
||||
return conf
|
||||
},
|
||||
errMsg: "invalid configuration: can't use reservedSystemCPUs (--reserved-cpus) with systemReservedCgroup (--system-reserved-cgroup) or kubeReservedCgroup (--kube-reserved-cgroup)",
|
||||
errMsg: "invalid configuration: option \"invalid-hair-pin-mode\" specified for hairpinMode (--hairpin-mode). Valid options are \"none\", \"hairpin-veth\" or \"promiscuous-bridge\"",
|
||||
}, {
|
||||
name: "specify ReservedSystemCPUs with SystemReservedCgroup",
|
||||
configure: func(conf *kubeletconfig.KubeletConfiguration) *kubeletconfig.KubeletConfiguration {
|
||||
conf.ReservedSystemCPUs = "0-3"
|
||||
conf.SystemReservedCgroup = "/system.slice"
|
||||
return conf
|
||||
},
|
||||
{
|
||||
name: "specify ReservedSystemCPUs with KubeReservedCgroup",
|
||||
configure: func(conf *kubeletconfig.KubeletConfiguration) *kubeletconfig.KubeletConfiguration {
|
||||
conf.ReservedSystemCPUs = "0-3"
|
||||
conf.KubeReservedCgroup = "/system.slice"
|
||||
return conf
|
||||
},
|
||||
errMsg: "invalid configuration: can't use reservedSystemCPUs (--reserved-cpus) with systemReservedCgroup (--system-reserved-cgroup) or kubeReservedCgroup (--kube-reserved-cgroup)",
|
||||
errMsg: "invalid configuration: can't use reservedSystemCPUs (--reserved-cpus) with systemReservedCgroup (--system-reserved-cgroup) or kubeReservedCgroup (--kube-reserved-cgroup)",
|
||||
}, {
|
||||
name: "specify ReservedSystemCPUs with KubeReservedCgroup",
|
||||
configure: func(conf *kubeletconfig.KubeletConfiguration) *kubeletconfig.KubeletConfiguration {
|
||||
conf.ReservedSystemCPUs = "0-3"
|
||||
conf.KubeReservedCgroup = "/system.slice"
|
||||
return conf
|
||||
},
|
||||
{
|
||||
name: "invalid ReservedSystemCPUs",
|
||||
configure: func(conf *kubeletconfig.KubeletConfiguration) *kubeletconfig.KubeletConfiguration {
|
||||
conf.ReservedSystemCPUs = "invalid-reserved-system-cpus"
|
||||
return conf
|
||||
},
|
||||
errMsg: "invalid configuration: unable to parse reservedSystemCPUs (--reserved-cpus) invalid-reserved-system-cpus, error:",
|
||||
errMsg: "invalid configuration: can't use reservedSystemCPUs (--reserved-cpus) with systemReservedCgroup (--system-reserved-cgroup) or kubeReservedCgroup (--kube-reserved-cgroup)",
|
||||
}, {
|
||||
name: "invalid ReservedSystemCPUs",
|
||||
configure: func(conf *kubeletconfig.KubeletConfiguration) *kubeletconfig.KubeletConfiguration {
|
||||
conf.ReservedSystemCPUs = "invalid-reserved-system-cpus"
|
||||
return conf
|
||||
},
|
||||
{
|
||||
name: "enable MemoryQoS without specifying MemoryThrottlingFactor",
|
||||
configure: func(conf *kubeletconfig.KubeletConfiguration) *kubeletconfig.KubeletConfiguration {
|
||||
conf.FeatureGates = map[string]bool{"MemoryQoS": true}
|
||||
conf.MemoryThrottlingFactor = nil
|
||||
return conf
|
||||
},
|
||||
errMsg: "invalid configuration: memoryThrottlingFactor is required when MemoryQoS feature flag is enabled",
|
||||
errMsg: "invalid configuration: unable to parse reservedSystemCPUs (--reserved-cpus) invalid-reserved-system-cpus, error:",
|
||||
}, {
|
||||
name: "enable MemoryQoS without specifying MemoryThrottlingFactor",
|
||||
configure: func(conf *kubeletconfig.KubeletConfiguration) *kubeletconfig.KubeletConfiguration {
|
||||
conf.FeatureGates = map[string]bool{"MemoryQoS": true}
|
||||
conf.MemoryThrottlingFactor = nil
|
||||
return conf
|
||||
},
|
||||
{
|
||||
name: "invalid MemoryThrottlingFactor",
|
||||
configure: func(conf *kubeletconfig.KubeletConfiguration) *kubeletconfig.KubeletConfiguration {
|
||||
conf.MemoryThrottlingFactor = utilpointer.Float64(1.1)
|
||||
return conf
|
||||
},
|
||||
errMsg: "invalid configuration: memoryThrottlingFactor 1.1 must be greater than 0 and less than or equal to 1.0",
|
||||
errMsg: "invalid configuration: memoryThrottlingFactor is required when MemoryQoS feature flag is enabled",
|
||||
}, {
|
||||
name: "invalid MemoryThrottlingFactor",
|
||||
configure: func(conf *kubeletconfig.KubeletConfiguration) *kubeletconfig.KubeletConfiguration {
|
||||
conf.MemoryThrottlingFactor = utilpointer.Float64(1.1)
|
||||
return conf
|
||||
},
|
||||
{
|
||||
name: "invalid Taint.TimeAdded",
|
||||
configure: func(conf *kubeletconfig.KubeletConfiguration) *kubeletconfig.KubeletConfiguration {
|
||||
now := metav1.Now()
|
||||
conf.RegisterWithTaints = []v1.Taint{{TimeAdded: &now}}
|
||||
return conf
|
||||
},
|
||||
errMsg: "invalid configuration: taint.TimeAdded is not nil",
|
||||
errMsg: "invalid configuration: memoryThrottlingFactor 1.1 must be greater than 0 and less than or equal to 1.0",
|
||||
}, {
|
||||
name: "invalid Taint.TimeAdded",
|
||||
configure: func(conf *kubeletconfig.KubeletConfiguration) *kubeletconfig.KubeletConfiguration {
|
||||
now := metav1.Now()
|
||||
conf.RegisterWithTaints = []v1.Taint{{TimeAdded: &now}}
|
||||
return conf
|
||||
},
|
||||
{
|
||||
name: "specify tracing with KubeletTracing disabled",
|
||||
configure: func(conf *kubeletconfig.KubeletConfiguration) *kubeletconfig.KubeletConfiguration {
|
||||
samplingRate := int32(99999)
|
||||
conf.FeatureGates = map[string]bool{"KubeletTracing": false}
|
||||
conf.Tracing = &tracingapi.TracingConfiguration{SamplingRatePerMillion: &samplingRate}
|
||||
return conf
|
||||
},
|
||||
errMsg: "invalid configuration: tracing should not be configured if KubeletTracing feature flag is disabled.",
|
||||
errMsg: "invalid configuration: taint.TimeAdded is not nil",
|
||||
}, {
|
||||
name: "specify tracing with KubeletTracing disabled",
|
||||
configure: func(conf *kubeletconfig.KubeletConfiguration) *kubeletconfig.KubeletConfiguration {
|
||||
samplingRate := int32(99999)
|
||||
conf.FeatureGates = map[string]bool{"KubeletTracing": false}
|
||||
conf.Tracing = &tracingapi.TracingConfiguration{SamplingRatePerMillion: &samplingRate}
|
||||
return conf
|
||||
},
|
||||
{
|
||||
name: "specify tracing invalid sampling rate",
|
||||
configure: func(conf *kubeletconfig.KubeletConfiguration) *kubeletconfig.KubeletConfiguration {
|
||||
samplingRate := int32(-1)
|
||||
conf.FeatureGates = map[string]bool{"KubeletTracing": true}
|
||||
conf.Tracing = &tracingapi.TracingConfiguration{SamplingRatePerMillion: &samplingRate}
|
||||
return conf
|
||||
},
|
||||
errMsg: "tracing.samplingRatePerMillion: Invalid value: -1: sampling rate must be positive",
|
||||
errMsg: "invalid configuration: tracing should not be configured if KubeletTracing feature flag is disabled.",
|
||||
}, {
|
||||
name: "specify tracing invalid sampling rate",
|
||||
configure: func(conf *kubeletconfig.KubeletConfiguration) *kubeletconfig.KubeletConfiguration {
|
||||
samplingRate := int32(-1)
|
||||
conf.FeatureGates = map[string]bool{"KubeletTracing": true}
|
||||
conf.Tracing = &tracingapi.TracingConfiguration{SamplingRatePerMillion: &samplingRate}
|
||||
return conf
|
||||
},
|
||||
{
|
||||
name: "specify tracing invalid endpoint",
|
||||
configure: func(conf *kubeletconfig.KubeletConfiguration) *kubeletconfig.KubeletConfiguration {
|
||||
ep := "dn%2s://localhost:4317"
|
||||
conf.FeatureGates = map[string]bool{"KubeletTracing": true}
|
||||
conf.Tracing = &tracingapi.TracingConfiguration{Endpoint: &ep}
|
||||
return conf
|
||||
},
|
||||
errMsg: "tracing.endpoint: Invalid value: \"dn%2s://localhost:4317\": parse \"dn%2s://localhost:4317\": first path segment in URL cannot contain colon",
|
||||
errMsg: "tracing.samplingRatePerMillion: Invalid value: -1: sampling rate must be positive",
|
||||
}, {
|
||||
name: "specify tracing invalid endpoint",
|
||||
configure: func(conf *kubeletconfig.KubeletConfiguration) *kubeletconfig.KubeletConfiguration {
|
||||
ep := "dn%2s://localhost:4317"
|
||||
conf.FeatureGates = map[string]bool{"KubeletTracing": true}
|
||||
conf.Tracing = &tracingapi.TracingConfiguration{Endpoint: &ep}
|
||||
return conf
|
||||
},
|
||||
{
|
||||
name: "invalid GracefulNodeShutdownBasedOnPodPriority",
|
||||
configure: func(conf *kubeletconfig.KubeletConfiguration) *kubeletconfig.KubeletConfiguration {
|
||||
conf.FeatureGates = map[string]bool{"GracefulNodeShutdownBasedOnPodPriority": true}
|
||||
conf.ShutdownGracePeriodByPodPriority = []kubeletconfig.ShutdownGracePeriodByPodPriority{
|
||||
{
|
||||
Priority: 0,
|
||||
ShutdownGracePeriodSeconds: 0,
|
||||
}}
|
||||
return conf
|
||||
},
|
||||
errMsg: "invalid configuration: Cannot specify both shutdownGracePeriodByPodPriority and shutdownGracePeriod at the same time",
|
||||
errMsg: "tracing.endpoint: Invalid value: \"dn%2s://localhost:4317\": parse \"dn%2s://localhost:4317\": first path segment in URL cannot contain colon",
|
||||
}, {
|
||||
name: "invalid GracefulNodeShutdownBasedOnPodPriority",
|
||||
configure: func(conf *kubeletconfig.KubeletConfiguration) *kubeletconfig.KubeletConfiguration {
|
||||
conf.FeatureGates = map[string]bool{"GracefulNodeShutdownBasedOnPodPriority": true}
|
||||
conf.ShutdownGracePeriodByPodPriority = []kubeletconfig.ShutdownGracePeriodByPodPriority{{
|
||||
Priority: 0,
|
||||
ShutdownGracePeriodSeconds: 0,
|
||||
}}
|
||||
return conf
|
||||
},
|
||||
{
|
||||
name: "Specifying shutdownGracePeriodByPodPriority without enable GracefulNodeShutdownBasedOnPodPriority",
|
||||
configure: func(conf *kubeletconfig.KubeletConfiguration) *kubeletconfig.KubeletConfiguration {
|
||||
conf.FeatureGates = map[string]bool{"GracefulNodeShutdownBasedOnPodPriority": false}
|
||||
conf.ShutdownGracePeriodByPodPriority = []kubeletconfig.ShutdownGracePeriodByPodPriority{
|
||||
{
|
||||
Priority: 0,
|
||||
ShutdownGracePeriodSeconds: 0,
|
||||
}}
|
||||
return conf
|
||||
},
|
||||
errMsg: "invalid configuration: Specifying shutdownGracePeriodByPodPriority requires feature gate GracefulNodeShutdownBasedOnPodPriority",
|
||||
errMsg: "invalid configuration: Cannot specify both shutdownGracePeriodByPodPriority and shutdownGracePeriod at the same time",
|
||||
}, {
|
||||
name: "Specifying shutdownGracePeriodByPodPriority without enable GracefulNodeShutdownBasedOnPodPriority",
|
||||
configure: func(conf *kubeletconfig.KubeletConfiguration) *kubeletconfig.KubeletConfiguration {
|
||||
conf.FeatureGates = map[string]bool{"GracefulNodeShutdownBasedOnPodPriority": false}
|
||||
conf.ShutdownGracePeriodByPodPriority = []kubeletconfig.ShutdownGracePeriodByPodPriority{{
|
||||
Priority: 0,
|
||||
ShutdownGracePeriodSeconds: 0,
|
||||
}}
|
||||
return conf
|
||||
},
|
||||
{
|
||||
name: "enableSystemLogQuery is enabled without NodeLogQuery feature gate",
|
||||
configure: func(conf *kubeletconfig.KubeletConfiguration) *kubeletconfig.KubeletConfiguration {
|
||||
conf.EnableSystemLogQuery = true
|
||||
return conf
|
||||
},
|
||||
errMsg: "invalid configuration: NodeLogQuery feature gate is required for enableSystemLogHandler",
|
||||
errMsg: "invalid configuration: Specifying shutdownGracePeriodByPodPriority requires feature gate GracefulNodeShutdownBasedOnPodPriority",
|
||||
}, {
|
||||
name: "enableSystemLogQuery is enabled without NodeLogQuery feature gate",
|
||||
configure: func(conf *kubeletconfig.KubeletConfiguration) *kubeletconfig.KubeletConfiguration {
|
||||
conf.EnableSystemLogQuery = true
|
||||
return conf
|
||||
},
|
||||
{
|
||||
name: "enableSystemLogQuery is enabled without enableSystemLogHandler",
|
||||
configure: func(conf *kubeletconfig.KubeletConfiguration) *kubeletconfig.KubeletConfiguration {
|
||||
conf.FeatureGates = map[string]bool{"NodeLogQuery": true}
|
||||
conf.EnableSystemLogHandler = false
|
||||
conf.EnableSystemLogQuery = true
|
||||
return conf
|
||||
},
|
||||
errMsg: "invalid configuration: enableSystemLogHandler is required for enableSystemLogQuery",
|
||||
errMsg: "invalid configuration: NodeLogQuery feature gate is required for enableSystemLogHandler",
|
||||
}, {
|
||||
name: "enableSystemLogQuery is enabled without enableSystemLogHandler",
|
||||
configure: func(conf *kubeletconfig.KubeletConfiguration) *kubeletconfig.KubeletConfiguration {
|
||||
conf.FeatureGates = map[string]bool{"NodeLogQuery": true}
|
||||
conf.EnableSystemLogHandler = false
|
||||
conf.EnableSystemLogQuery = true
|
||||
return conf
|
||||
},
|
||||
}
|
||||
errMsg: "invalid configuration: enableSystemLogHandler is required for enableSystemLogQuery",
|
||||
}}
|
||||
|
||||
for _, tc := range cases {
|
||||
t.Run(tc.name, func(t *testing.T) {
|
||||
|
Reference in New Issue
Block a user