You are viewing a plain text version of this content. The canonical link for it is here.
Posted to reviews@yunikorn.apache.org by "pbacsko (via GitHub)" <gi...@apache.org> on 2023/06/16 12:56:16 UTC

[GitHub] [yunikorn-core] pbacsko commented on a diff in pull request #571: [YUNIKORN-1801] add allocation events

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


##########
pkg/scheduler/objects/events.go:
##########
@@ -50,6 +51,87 @@ func (evt *applicationEvents) sendPlaceholderLargerEvent(ph *Allocation, request
 	evt.eventSystem.AddEvent(event)
 }
 
+func (evt *applicationEvents) sendSuccessfulAllocationEvent(alloc *Allocation) {
+	if !evt.enabled {
+		return
+	}
+
+	message := fmt.Sprintf("Allocation '%s' in application '%s' is successfully allocated to node '%s'", alloc.GetUUID(), alloc.GetApplicationID(), alloc.GetNodeID())
+	event := events.CreateAppEventRecord(evt.app.ApplicationID, message, alloc.GetUUID(), si.EventRecord_ADD, si.EventRecord_APP_ALLOC, alloc.GetAllocatedResource())
+	evt.eventSystem.AddEvent(event)
+}
+
+func (evt *applicationEvents) sendIncomingAllocationAskEvent(request *AllocationAsk) {
+	if !evt.enabled {
+		return
+	}
+
+	message := fmt.Sprintf("Incoming allocation ask '%s' for application '%s'", request.GetAllocationKey(), request.GetApplicationID())
+	event := events.CreateAppEventRecord(evt.app.ApplicationID, message, request.GetAllocationKey(), si.EventRecord_ADD, si.EventRecord_APP_REQUEST, request.GetAllocatedResource())
+	evt.eventSystem.AddEvent(event)
+}
+
+func (evt *applicationEvents) sendTerminateAllocationEvent(alloc *Allocation, terminationType si.TerminationType) {
+	if !evt.enabled {
+		return
+	}
+
+	var message string
+	var event *si.EventRecord
+	switch terminationType {
+	case si.TerminationType_UNKNOWN_TERMINATION_TYPE:
+		message = fmt.Sprintf("Allocation '%s' in application '%s' is removed. Reason: node is removed", alloc.GetUUID(), alloc.GetApplicationID())

Review Comment:
   Message is not needed, we have event details, that should suffice.



##########
pkg/scheduler/objects/events.go:
##########
@@ -50,6 +51,87 @@ func (evt *applicationEvents) sendPlaceholderLargerEvent(ph *Allocation, request
 	evt.eventSystem.AddEvent(event)
 }
 
+func (evt *applicationEvents) sendSuccessfulAllocationEvent(alloc *Allocation) {
+	if !evt.enabled {
+		return
+	}
+
+	message := fmt.Sprintf("Allocation '%s' in application '%s' is successfully allocated to node '%s'", alloc.GetUUID(), alloc.GetApplicationID(), alloc.GetNodeID())
+	event := events.CreateAppEventRecord(evt.app.ApplicationID, message, alloc.GetUUID(), si.EventRecord_ADD, si.EventRecord_APP_ALLOC, alloc.GetAllocatedResource())
+	evt.eventSystem.AddEvent(event)
+}
+
+func (evt *applicationEvents) sendIncomingAllocationAskEvent(request *AllocationAsk) {
+	if !evt.enabled {
+		return
+	}
+
+	message := fmt.Sprintf("Incoming allocation ask '%s' for application '%s'", request.GetAllocationKey(), request.GetApplicationID())
+	event := events.CreateAppEventRecord(evt.app.ApplicationID, message, request.GetAllocationKey(), si.EventRecord_ADD, si.EventRecord_APP_REQUEST, request.GetAllocatedResource())
+	evt.eventSystem.AddEvent(event)
+}
+
+func (evt *applicationEvents) sendTerminateAllocationEvent(alloc *Allocation, terminationType si.TerminationType) {
+	if !evt.enabled {
+		return
+	}
+
+	var message string
+	var event *si.EventRecord
+	switch terminationType {
+	case si.TerminationType_UNKNOWN_TERMINATION_TYPE:
+		message = fmt.Sprintf("Allocation '%s' in application '%s' is removed. Reason: node is removed", alloc.GetUUID(), alloc.GetApplicationID())
+		event = events.CreateAppEventRecord(evt.app.ApplicationID, message, alloc.GetUUID(), si.EventRecord_REMOVE, si.EventRecord_ALLOC_NODEREMOVED, alloc.GetAllocatedResource())
+	case si.TerminationType_STOPPED_BY_RM:
+		message = fmt.Sprintf("Allocation '%s' in application '%s' is removed. Reason: stopped by RM", alloc.GetUUID(), alloc.GetApplicationID())
+		event = events.CreateAppEventRecord(evt.app.ApplicationID, message, alloc.GetUUID(), si.EventRecord_REMOVE, si.EventRecord_ALLOC_CANCEL, alloc.GetAllocatedResource())
+	case si.TerminationType_TIMEOUT:
+		message = fmt.Sprintf("Allocation'%s' in application '%s' is removed. Reason: timeout", alloc.GetUUID(), alloc.GetApplicationID())
+		event = events.CreateAppEventRecord(evt.app.ApplicationID, message, alloc.GetUUID(), si.EventRecord_REMOVE, si.EventRecord_ALLOC_TIMEOUT, alloc.GetAllocatedResource())
+	case si.TerminationType_PREEMPTED_BY_SCHEDULER:
+		message = fmt.Sprintf("Allocation '%s' in application '%s' is removed. Reason: preempted", alloc.GetUUID(), alloc.GetApplicationID())
+		event = events.CreateAppEventRecord(evt.app.ApplicationID, message, alloc.GetUUID(), si.EventRecord_REMOVE, si.EventRecord_ALLOC_PREEMPT, alloc.GetAllocatedResource())
+	case si.TerminationType_PLACEHOLDER_REPLACED:
+		message := fmt.Sprintf("Placeholder '%s' in application '%s' is removed. Reason: replaced", alloc.GetUUID(), alloc.GetApplicationID())
+		event = events.CreateAppEventRecord(evt.app.ApplicationID, message, alloc.GetUUID(), si.EventRecord_REMOVE, si.EventRecord_ALLOC_REPLACED, alloc.GetAllocatedResource())
+	}
+
+	if event != nil {
+		evt.eventSystem.AddEvent(event)
+	}
+}
+
+func (evt *applicationEvents) sendTerminateAllocationAskEvent(request *AllocationAsk, terminationType si.TerminationType) {
+	if !evt.enabled {
+		return
+	}
+
+	var message string
+	var event *si.EventRecord
+	switch terminationType {
+	case si.TerminationType_TIMEOUT:
+		message = fmt.Sprintf("Allocation ask '%s' in application '%s' is removed. Reason: timeout", request.GetAllocationKey(), request.GetApplicationID())

Review Comment:
   Message 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: reviews-unsubscribe@yunikorn.apache.org

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