chia7712 commented on code in PR #933:
URL: https://github.com/apache/yunikorn-core/pull/933#discussion_r1706683956


##########
pkg/common/resources/resources.go:
##########
@@ -364,6 +364,21 @@ func (r *Resource) SubOnlyExisting(delta *Resource) {
        }
 }
 
+// AddOnlyExisting adds delta to defined resource.
+// Ignore any type not defined in the base resource (ie receiver).
+func (r *Resource) AddOnlyExisting(delta *Resource) *Resource {

Review Comment:
   There is a similar method `SubOnlyExisting`, and it changes the receiver 
directly. Maybe we should align the behavior. I prefer to return a clone 
(`AddOnlyExisting`), as we can either reassign it to receiver or keep receiver 
immutable. WDYT? 



##########
pkg/scheduler/objects/queue.go:
##########
@@ -1017,17 +1016,18 @@ func (sq *Queue) IncAllocatedResource(alloc 
*resources.Resource, nodeReported bo
        sq.Lock()
        defer sq.Unlock()
        // all OK update this queue
-       sq.allocatedResource = newAllocated
+       sq.allocatedResource = resources.Add(sq.allocatedResource, alloc)
        sq.updateAllocatedResourceMetrics()
        return nil
 }
 
+// allocatedResFits adds the passed in resource to the allocatedResource of 
the queue and checks if it still fits in the
+// queues' maximum. If the resource fits it returns true otherwise false.
 // small helper method to access sq.maxResource+sq.allocatedResource and avoid 
Clone() call
-func (sq *Queue) allocatedResFits(res *resources.Resource) (bool, 
*resources.Resource) {
+func (sq *Queue) allocatedResFits(res *resources.Resource) bool {
        sq.RLock()
        defer sq.RUnlock()
-       newAllocated := resources.Add(sq.allocatedResource, res)

Review Comment:
   That means `allocatedResource` could be larger than `maxResource`, and in 
that case all allocations can't be fit into that queue even though they don't 
use the resource type.
   
   If above description is correct, is the situation (`allocatedResource` is 
larger than `maxResource`) acceptable in YK? or it is a temporary state? 
   
   Please correct me if I misunderstand the context :_



-- 
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