Kubelet: node allocatable resources: negative quantities should not be allowed

When setting kube/system-resources for a node, negative quantities can result in
node's allocatable being higher then node's capacity.
Let's check the quantity and return error if it is negative.
This commit is contained in:
Jan Chaloupka 2016-03-23 16:00:01 +01:00
parent 050980b472
commit 663fbce3a0

View File

@ -902,6 +902,9 @@ func parseResourceList(m utilconfig.ConfigurationMap) (api.ResourceList, error)
if err != nil {
return nil, err
}
if q.Amount.Sign() == -1 {
return nil, fmt.Errorf("resource quantity for %q cannot be negative: %v", k, v)
}
rl[api.ResourceName(k)] = *q
default:
return nil, fmt.Errorf("cannot reserve %q resource", k)