mirror of
https://github.com/k3s-io/kubernetes.git
synced 2025-07-24 20:24:09 +00:00
Update the cpumanager to error out if an invalid policy is given
Previously, the cpumanager would simply fall back to the None() policy if an invalid policy was specified. This patch updates this to return an error when an invalid policy is passed, forcing the kubelet to fail fast when this occurs. These semantics should be preferable because an invalid policy likely indicates operator error in setting the policy flag on the kubelet correctly (e.g. misspelling 'static' as 'statiic'). In this case it is better to fail fast so the operator can detect this and correct the mistake, than to mask the error and essentially disable the cpumanager unexpectedly.
This commit is contained in:
parent
ce80aeaac5
commit
5dc5f1de06
@ -132,8 +132,7 @@ func NewManager(cpuPolicyName string, reconcilePeriod time.Duration, machineInfo
|
||||
policy = NewStaticPolicy(topo, numReservedCPUs)
|
||||
|
||||
default:
|
||||
klog.Errorf("[cpumanager] Unknown policy \"%s\", falling back to default policy \"%s\"", cpuPolicyName, PolicyNone)
|
||||
policy = NewNonePolicy()
|
||||
return nil, fmt.Errorf("unknown policy: \"%s\"", cpuPolicyName)
|
||||
}
|
||||
|
||||
stateImpl, err := state.NewCheckpointState(stateFileDirectory, cpuManagerStateFileName, policy.Name())
|
||||
|
@ -232,7 +232,7 @@ func TestCPUManagerGenerate(t *testing.T) {
|
||||
description: "invalid policy name",
|
||||
cpuPolicyName: "invalid",
|
||||
nodeAllocatableReservation: nil,
|
||||
expectedPolicy: "none",
|
||||
expectedError: fmt.Errorf("unknown policy: \"invalid\""),
|
||||
},
|
||||
{
|
||||
description: "static policy",
|
||||
|
Loading…
Reference in New Issue
Block a user