mirror of
https://github.com/k3s-io/kubernetes.git
synced 2025-07-22 03:11:40 +00:00
Merge pull request #58574 from yastij/fix-kubelet-podRequest
Automatic merge from submit-queue. If you want to cherry-pick this change to another branch, please follow the instructions <a href="https://github.com/kubernetes/community/blob/master/contributors/devel/cherry-picks.md">here</a>. fixing array out of bound by checking initContainers instead of containers **What this PR does / why we need it**: **Which issue(s) this PR fixes** : Fixes #58541 **Special notes for your reviewer**: **Release note**: ```release-note None ```
This commit is contained in:
commit
b6824afaad
@ -590,7 +590,7 @@ func memory(stats statsFunc) cmpFunc {
|
||||
}
|
||||
|
||||
// podRequest returns the total resource request of a pod which is the
|
||||
// max(sum of init container requests, sum of container requests)
|
||||
// max(max of init container requests, sum of container requests)
|
||||
func podRequest(pod *v1.Pod, resourceName v1.ResourceName) resource.Quantity {
|
||||
containerValue := resource.Quantity{Format: resource.BinarySI}
|
||||
if resourceName == resourceDisk && !utilfeature.DefaultFeatureGate.Enabled(features.LocalStorageCapacityIsolation) {
|
||||
@ -609,9 +609,13 @@ func podRequest(pod *v1.Pod, resourceName v1.ResourceName) resource.Quantity {
|
||||
for i := range pod.Spec.InitContainers {
|
||||
switch resourceName {
|
||||
case v1.ResourceMemory:
|
||||
containerValue.Add(*pod.Spec.Containers[i].Resources.Requests.Memory())
|
||||
if initValue.Cmp(*pod.Spec.InitContainers[i].Resources.Requests.Memory()) < 0 {
|
||||
initValue = *pod.Spec.InitContainers[i].Resources.Requests.Memory()
|
||||
}
|
||||
case resourceDisk:
|
||||
containerValue.Add(*pod.Spec.Containers[i].Resources.Requests.StorageEphemeral())
|
||||
if initValue.Cmp(*pod.Spec.InitContainers[i].Resources.Requests.StorageEphemeral()) < 0 {
|
||||
initValue = *pod.Spec.InitContainers[i].Resources.Requests.StorageEphemeral()
|
||||
}
|
||||
}
|
||||
}
|
||||
if containerValue.Cmp(initValue) > 0 {
|
||||
|
Loading…
Reference in New Issue
Block a user