pbacsko commented on code in PR #563:
URL: https://github.com/apache/yunikorn-core/pull/563#discussion_r1228203762


##########
pkg/scheduler/ugm/queue_tracker.go:
##########
@@ -48,20 +49,36 @@ func newQueueTracker(queueName string) *QueueTracker {
                queueName:           queueName,
                resourceUsage:       resources.NewResource(),
                runningApplications: make(map[string]bool),
+               maxResourceUsage:    resources.NewResource(),
+               maxRunningApps:      0,
                childQueueTrackers:  make(map[string]*QueueTracker),
        }
        return queueTracker
 }
 
-func (qt *QueueTracker) increaseTrackedResource(queuePath string, 
applicationID string, usage *resources.Resource) error {
+func (qt *QueueTracker) increaseTrackedResource(queuePath string, 
applicationID string, usage *resources.Resource) bool {
        log.Logger().Debug("Increasing resource usage",
                zap.String("queue path", queuePath),
                zap.String("application", applicationID),
                zap.Stringer("resource", usage))
        if queuePath == "" || applicationID == "" || usage == nil {
-               return fmt.Errorf("mandatory parameters are missing. queuepath: 
%s, application id: %s, resource usage: %s",
-                       queuePath, applicationID, usage.String())
+               return false
+       }

Review Comment:
   This is something I've been thinking about - do we really need these checks? 
It's similar to what I observed in YUNIKORN-1807. I'm not sure that being so 
defensive is needed if everything comes from our code. It's not like a method 
which is called from all kinds of places. We have unit tests in place which 
verify this. Calls to increase/decrease go though `Manager`, which is only 
called by the `Application`. If `usage` somehow becomes `nil` at any point, we 
already have a pretty nasty bug and we should just bail out and let YK crash. 
   Same for the strings - that does not cause panic, but it's a bug, we don't 
gain anything by returning it to the caller. 
   Instead of having these kinds of `if` branches, IMO it's much better to 
ensure proper test coverage. For example, you can add a test to 
`application_test.go` which makes sure that we call these methods with the 
right values and it's a valid path.
   
   Another thing is that even if `queuePath` is not empty, it can still be an 
invalid string that completely messes up 
`qt.childQueueTrackers[immediateChildQueueName].increaseTrackedResource(...)` 
because the map will return a `nil` tracker. So we only defend against a 
special case to begin with.



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