You are viewing a plain text version of this content. The canonical link for it is here.
Posted to reviews@yunikorn.apache.org by GitBox <gi...@apache.org> on 2021/09/27 11:24:58 UTC

[GitHub] [incubator-yunikorn-core] kingamarton commented on a change in pull request #314: [YUNIKORN-813] The capacity of undefined resource should NOT be consi…

kingamarton commented on a change in pull request #314:
URL: https://github.com/apache/incubator-yunikorn-core/pull/314#discussion_r716597916



##########
File path: pkg/scheduler/objects/queue.go
##########
@@ -910,12 +910,31 @@ func (sq *Queue) internalHeadRoom(parentHeadRoom *resources.Resource) *resources
 	if headRoom == nil {
 		return parentHeadRoom
 	}
+
+	// we will replace all incorrect values, which are caused by undefined resources, by resources of parent headroom after headRoom
+	// get the unused resources by calling SubFrom
+	undefinedResources := make(map[string]resources.Quantity)
+	if parentHeadRoom != nil {
+		for k, v := range parentHeadRoom.Resources {
+			if _, ok := headRoom.Resources[k]; !ok {
+				undefinedResources[k] = v
+			}
+		}
+	}
+
 	// calculate unused
 	headRoom.SubFrom(sq.allocatedResource)
+
 	// check the minimum of the two: parentHeadRoom is nil for root
 	if parentHeadRoom == nil {
 		return headRoom
 	}
+
+	// replace the incorrect result by resources of parent headroom
+	for k, v := range undefinedResources {
+		headRoom.Resources[k] = v
+	}
+

Review comment:
       Shouldn't this be mooved before we are substracting the allocated resources at line 926?




-- 
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: reviews-unsubscribe@yunikorn.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org