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


##########
pkg/scheduler/objects/allocation_ask.go:
##########
@@ -79,7 +79,7 @@ func NewAllocationAsk(allocationKey string, applicationID 
string, allocatedResou
                resKeyPerNode:     make(map[string]string),
        }
        aa.resKeyWithoutNode = reservationKeyWithoutNode(applicationID, 
allocationKey)
-       aa.askEvents = newAskEvents(aa, events.GetEventSystem())
+       aa.askEvents = newAskEvents(events.GetEventSystem())
        return aa

Review Comment:
   It seems we can simplify the code now.
   ```go
   func NewAllocationAsk(allocationKey string, applicationID string, 
allocatedResource *resources.Resource) *AllocationAsk {
        return &AllocationAsk{
                allocationKey:     allocationKey,
                applicationID:     applicationID,
                allocatedResource: allocatedResource,
                allocLog:          make(map[string]*AllocationLogEntry),
                resKeyPerNode:     make(map[string]string),
                resKeyWithoutNode: reservationKeyWithoutNode(applicationID, 
allocationKey),
                askEvents:         newAskEvents(events.GetEventSystem()),
        }
   }
   ```



##########
pkg/scheduler/objects/allocation_ask.go:
##########
@@ -108,7 +108,7 @@ func NewAllocationAskFromSI(ask *si.AllocationAsk) 
*AllocationAsk {
                return nil
        }
        saa.resKeyWithoutNode = reservationKeyWithoutNode(ask.ApplicationID, 
ask.AllocationKey)
-       saa.askEvents = newAskEvents(saa, events.GetEventSystem())
+       saa.askEvents = newAskEvents(events.GetEventSystem())

Review Comment:
   ditto
   
   ```go
   func NewAllocationAskFromSI(ask *si.AllocationAsk) *AllocationAsk {
        // this is a safety check placeholder and task group name must be set 
as a combo
        // order is important as task group can be set without placeholder but 
not the other way around
        if ask.Placeholder && ask.TaskGroupName == "" {
                log.Log(log.SchedAllocation).Debug("ask cannot be a placeholder 
without a TaskGroupName",
                        zap.Stringer("SI ask", ask))
                return nil
        }
        return &AllocationAsk{
                allocationKey:     ask.AllocationKey,
                allocatedResource: 
resources.NewResourceFromProto(ask.ResourceAsk),
                applicationID:     ask.ApplicationID,
                tags:              CloneAllocationTags(ask.Tags),
                createTime:        time.Now(),
                priority:          ask.Priority,
                placeholder:       ask.Placeholder,
                taskGroupName:     ask.TaskGroupName,
                requiredNode:      common.GetRequiredNodeFromTag(ask.Tags),
                allowPreemptSelf:  
common.IsAllowPreemptSelf(ask.PreemptionPolicy),
                allowPreemptOther: 
common.IsAllowPreemptOther(ask.PreemptionPolicy),
                originator:        ask.Originator,
                allocLog:          make(map[string]*AllocationLogEntry),
                resKeyPerNode:     make(map[string]string),
                resKeyWithoutNode: reservationKeyWithoutNode(ask.ApplicationID, 
ask.AllocationKey),
                askEvents: newAskEvents(events.GetEventSystem()),
        }
   }
   ```



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