mirror of
https://github.com/k3s-io/kubernetes.git
synced 2025-08-01 07:47:56 +00:00
Merge pull request #34503 from derekwaynecarr/fix-qos
Automatic merge from submit-queue Fix edge case in qos evaluation If a pod has a container C1 and C2, where sum(C1.requests, C2.requests) equals (C1.Limits), the code was reporting that the pod had "Guaranteed" qos, when it should have been Burstable. /cc @vishh @dchen1107
This commit is contained in:
commit
5ff8829b32
@ -68,11 +68,13 @@ func GetPodQOS(pod *api.Pod) QOSClass {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
// process limits
|
// process limits
|
||||||
|
qosLimitsFound := sets.NewString()
|
||||||
for name, quantity := range container.Resources.Limits {
|
for name, quantity := range container.Resources.Limits {
|
||||||
if !supportedQoSComputeResources.Has(string(name)) {
|
if !supportedQoSComputeResources.Has(string(name)) {
|
||||||
continue
|
continue
|
||||||
}
|
}
|
||||||
if quantity.Cmp(zeroQuantity) == 1 {
|
if quantity.Cmp(zeroQuantity) == 1 {
|
||||||
|
qosLimitsFound.Insert(string(name))
|
||||||
delta := quantity.Copy()
|
delta := quantity.Copy()
|
||||||
if _, exists := limits[name]; !exists {
|
if _, exists := limits[name]; !exists {
|
||||||
limits[name] = *delta
|
limits[name] = *delta
|
||||||
@ -82,7 +84,8 @@ func GetPodQOS(pod *api.Pod) QOSClass {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
if len(limits) != len(supportedQoSComputeResources) {
|
|
||||||
|
if len(qosLimitsFound) != len(supportedQoSComputeResources) {
|
||||||
isGuaranteed = false
|
isGuaranteed = false
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -135,6 +135,12 @@ func TestGetPodQOS(t *testing.T) {
|
|||||||
}),
|
}),
|
||||||
expected: Burstable,
|
expected: Burstable,
|
||||||
},
|
},
|
||||||
|
{
|
||||||
|
pod: newPod("burstable-no-limits", []api.Container{
|
||||||
|
newContainer("burstable", getResourceList("100m", "100Mi"), getResourceList("", "")),
|
||||||
|
}),
|
||||||
|
expected: Burstable,
|
||||||
|
},
|
||||||
{
|
{
|
||||||
pod: newPod("burstable-guaranteed", []api.Container{
|
pod: newPod("burstable-guaranteed", []api.Container{
|
||||||
newContainer("burstable", getResourceList("1", "100Mi"), getResourceList("2", "100Mi")),
|
newContainer("burstable", getResourceList("1", "100Mi"), getResourceList("2", "100Mi")),
|
||||||
@ -142,6 +148,13 @@ func TestGetPodQOS(t *testing.T) {
|
|||||||
}),
|
}),
|
||||||
expected: Burstable,
|
expected: Burstable,
|
||||||
},
|
},
|
||||||
|
{
|
||||||
|
pod: newPod("burstable-unbounded-but-requests-match-limits", []api.Container{
|
||||||
|
newContainer("burstable", getResourceList("100m", "100Mi"), getResourceList("200m", "200Mi")),
|
||||||
|
newContainer("burstable-unbounded", getResourceList("100m", "100Mi"), getResourceList("", "")),
|
||||||
|
}),
|
||||||
|
expected: Burstable,
|
||||||
|
},
|
||||||
{
|
{
|
||||||
pod: newPod("burstable-1", []api.Container{
|
pod: newPod("burstable-1", []api.Container{
|
||||||
newContainer("burstable", getResourceList("10m", "100Mi"), getResourceList("100m", "200Mi")),
|
newContainer("burstable", getResourceList("10m", "100Mi"), getResourceList("100m", "200Mi")),
|
||||||
|
Loading…
Reference in New Issue
Block a user