manirajv06 commented on code in PR #999:
URL: https://github.com/apache/yunikorn-k8shim/pull/999#discussion_r2730792121


##########
pkg/common/resource.go:
##########
@@ -162,37 +162,33 @@ func updateMax(left *si.Resource, right *si.Resource) {
 }
 
 func checkInitContainerRequest(pod *v1.Pod, containersResources *si.Resource, 
containerStatuses map[string]*v1.ContainerStatus) *si.Resource {
-       updatedRes := containersResources
-
-       // update total pod resource usage with sidecar containers
-       for _, c := range pod.Spec.InitContainers {
-               if isSideCarContainer(&c) {
-                       sideCarResources := computeContainerResource(pod, &c, 
containerStatuses)
-                       updatedRes = Add(updatedRes, sideCarResources)
-               }
-       }
-
+       initMax := NewResourceBuilder().Build()
        var sideCarRequests *si.Resource // cumulative value of sidecar 
requests so far
        for _, c := range pod.Spec.InitContainers {
                ICResource := computeContainerResource(pod, &c, 
containerStatuses)
+               // Add this container's resources to the resources for native 
sidecars that are already running
+               currentIC := Add(ICResource, sideCarRequests)
+               // if this is a native sidecar it keeps running: track it like 
that for the next init container
                if isSideCarContainer(&c) {
                        sideCarRequests = Add(sideCarRequests, ICResource)
                }
-               ICResource = Add(ICResource, sideCarRequests)
-               for resourceName, ICRequest := range ICResource.Resources {
-                       containersRequests, exist := 
updatedRes.Resources[resourceName]
+               for resourceName, ICRequest := range currentIC.Resources {

Review Comment:
   Can we replace this `for` block with
   
   updateMax(initMax, currentIC) ?
   



-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: [email protected]

For queries about this service, please contact Infrastructure at:
[email protected]

Reply via email to