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


##########
pkg/scheduler/objects/preemption.go:
##########
@@ -635,6 +636,9 @@ func (p *Preemptor) TryPreemption() (*AllocationResult, 
bool) {
                                zap.String("victimNodeID", victim.GetNodeID()),
                                zap.String("victimQueue", victimQueue.Name),
                        )
+                       // send event
+                       message := fmt.Sprintf("Preempted by %v from 
application %v in %v", p.ask.GetTag("kubernetes.io/meta/podName"), 
p.ask.applicationID, p.application.queuePath)

Review Comment:
   1. Message creation should be in the Send* method
   2. We usually don't refer to pod names in the "core", since it's a generic 
scheduler and we try to stay away from K8s-specific concepts. We use 
`allocationKey`.
   3. We need a test to validate that the event is generated in case of a 
preemption. Use a `MockEventSystem` to do that. Just replace the 
`Application.appEvents` with:
   ```
   mockEvents := mock.NewEventSystem()
   app.appEvents = schedEvt.NewApplicationEvents(mockEvents)
   ```
   You can re-use an already existing test which triggers preemption and check 
the contents of `mockEvents.Events`.



##########
pkg/scheduler/objects/events/application_events.go:
##########
@@ -79,6 +79,14 @@ func (ae *ApplicationEvents) 
SendRemoveAllocationEvent(appID, allocKey string, a
        ae.eventSystem.AddEvent(event)
 }
 
+func (ae *ApplicationEvents) SendPreemptAllocationEvent(appID, allocKey 
string, allocated *resources.Resource, message string) {
+       if !ae.eventSystem.IsEventTrackingEnabled() {
+               return
+       }
+       event := events.CreateAppEventRecord(appID, message, allocKey, 
si.EventRecord_REMOVE, si.EventRecord_ALLOC_PREEMPT, allocated)

Review Comment:
   This must be a `REQUEST` type. That will result in a real K8s event being 
sent to the target pod.
   
   The removal of the allocation will be a natural consequence of that, which 
will flow through the scheduler, so an app-specific event is not needed here.



-- 
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-unsubscr...@yunikorn.apache.org

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

Reply via email to