mirror of
https://github.com/k3s-io/kubernetes.git
synced 2025-08-31 16:46:54 +00:00
Remove type validation in resource.Quantity.Add
The type validation is unnecessary for add and will cause problem. Type will always keep unchanged after new amount is added.
This commit is contained in:
@@ -323,9 +323,6 @@ func (q *Quantity) Cmp(y Quantity) int {
|
||||
}
|
||||
|
||||
func (q *Quantity) Add(y Quantity) error {
|
||||
if q.Format != y.Format {
|
||||
return fmt.Errorf("format mismatch: %v vs. %v", q.Format, y.Format)
|
||||
}
|
||||
q.Amount.Add(q.Amount, y.Amount)
|
||||
return nil
|
||||
}
|
||||
|
@@ -127,6 +127,14 @@ func TestIncrementUsagePodResources(t *testing.T) {
|
||||
hard: resource.MustParse("500Mi"),
|
||||
expectedError: true,
|
||||
},
|
||||
{
|
||||
testName: "memory-not-allowed-with-different-format",
|
||||
existing: validPod("a", 1, getResourceRequirements(getResourceList("", "100M"), getResourceList("", ""))),
|
||||
input: validPod("b", 1, getResourceRequirements(getResourceList("", "450Mi"), getResourceList("", ""))),
|
||||
resourceName: api.ResourceMemory,
|
||||
hard: resource.MustParse("500Mi"),
|
||||
expectedError: true,
|
||||
},
|
||||
{
|
||||
testName: "memory-no-request",
|
||||
existing: validPod("a", 1, getResourceRequirements(getResourceList("", "100Mi"), getResourceList("", ""))),
|
||||
|
Reference in New Issue
Block a user