@@ -144,28 +144,17 @@ func podLimits(pod *corev1.Pod) corev1.ResourceList {
144
144
// determineContainerReqs will return a copy of the container requests based on if resizing is feasible or not.
145
145
func determineContainerReqs (pod * corev1.Pod , container * corev1.Container , cs * corev1.ContainerStatus ) corev1.ResourceList {
146
146
if helpers .IsPodResizeInfeasible (pod ) {
147
- return cs .Resources .Requests . DeepCopy ( )
147
+ return max ( cs .Resources .Requests , cs . AllocatedResources )
148
148
}
149
- return max (container .Resources .Requests , cs .Resources .Requests )
149
+ return max (container .Resources .Requests , cs .Resources .Requests , cs . AllocatedResources )
150
150
}
151
151
152
- // max returns the result of max(a, b) for each named resource and is only used if we can't
152
+ // max returns the result of max(a, b... ) for each named resource and is only used if we can't
153
153
// accumulate into an existing resource list
154
- func max (a corev1.ResourceList , b corev1.ResourceList ) corev1.ResourceList {
155
- result := corev1.ResourceList {}
156
- for key , value := range a {
157
- if other , found := b [key ]; found {
158
- if value .Cmp (other ) <= 0 {
159
- result [key ] = other .DeepCopy ()
160
- continue
161
- }
162
- }
163
- result [key ] = value .DeepCopy ()
164
- }
165
- for key , value := range b {
166
- if _ , found := result [key ]; ! found {
167
- result [key ] = value .DeepCopy ()
168
- }
154
+ func max (a corev1.ResourceList , b ... corev1.ResourceList ) corev1.ResourceList {
155
+ result := a .DeepCopy ()
156
+ for _ , other := range b {
157
+ maxResourceList (result , other )
169
158
}
170
159
return result
171
160
}
0 commit comments