craigcondit commented on code in PR #854:
URL: https://github.com/apache/yunikorn-core/pull/854#discussion_r1576826919
##########
pkg/scheduler/objects/application.go:
##########
@@ -695,44 +697,60 @@ func (sa *Application) addAllocationAskInternal(ask
*AllocationAsk) {
}
}
-func (sa *Application) UpdateAskRepeat(allocKey string, delta int32)
(*resources.Resource, error) {
+func (sa *Application) AllocateAsk(allocKey string) (*resources.Resource,
error) {
sa.Lock()
defer sa.Unlock()
if ask := sa.requests[allocKey]; ask != nil {
+ return sa.allocateAsk(ask)
+ }
+ return nil, fmt.Errorf("failed to locate ask with key %s", allocKey)
+}
- return sa.updateAskRepeatInternal(ask, delta)
+func (sa *Application) DeallocateAsk(allocKey string) (*resources.Resource,
error) {
+ sa.Lock()
+ defer sa.Unlock()
+ if ask := sa.requests[allocKey]; ask != nil {
+ return sa.deallocateAsk(ask)
}
return nil, fmt.Errorf("failed to locate ask with key %s", allocKey)
}
-func (sa *Application) updateAskRepeatInternal(ask *AllocationAsk, delta
int32) (*resources.Resource, error) {
- // updating with delta does error checking internally
- if !ask.updatePendingAskRepeat(delta) {
- return nil, fmt.Errorf("ask repaeat not updated resulting
repeat less than zero for ask %s on app %s", ask.GetAllocationKey(),
sa.ApplicationID)
+func (sa *Application) allocateAsk(ask *AllocationAsk) (*resources.Resource,
error) {
+ if !ask.allocate() {
+ return nil, fmt.Errorf("unable to allocate previously allocated
ask %s on app %s", ask.GetAllocationKey(), sa.ApplicationID)
+ }
+
+ if ask.GetPriority() >= sa.askMaxPriority {
Review Comment:
Because if we're removing an ask (by allocating it), the max priority of the
app may decrease. If the priority is < the app's current max, then another ask
exists that is of greater priority, so that calculation is not needed.
--
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]