pbacsko commented on code in PR #428:
URL: https://github.com/apache/yunikorn-k8shim/pull/428#discussion_r888085629


##########
pkg/cache/amprotocol_mock.go:
##########
@@ -71,16 +74,39 @@ func (m *MockedAMProtocol) RemoveApplication(appID string) 
error {
 
 func (m *MockedAMProtocol) AddTask(request *interfaces.AddTaskRequest) 
interfaces.ManagedTask {
        if app, ok := m.applications[request.Metadata.ApplicationID]; ok {
-               if existingTask, err := app.GetTask(request.Metadata.TaskID); 
err != nil {
-                       task := NewTask(request.Metadata.TaskID, app, nil, 
request.Metadata.Pod)
+               existingTask, err := app.GetTask(request.Metadata.TaskID)
+               if err != nil {
+                       var originator bool
+                       var ownerReferenceUID string
+                       // Is this task the originator of the application?
+                       // If yes, then make it as "first pod/owner/driver" of 
the application and set the task as originator
+                       for _, ownerReference := range 
app.getPlaceholderOwnerReferences() {
+                               referenceID := string(ownerReference.UID)
+                               if request.Metadata.TaskID == referenceID {
+                                       originator = true
+                                       ownerReferenceUID = referenceID
+                                       break
+                               }
+                       }
+                       task := NewFromTaskMeta(request.Metadata.TaskID, app, 
nil, request.Metadata, originator)
                        app.addTask(task)
+                       log.Logger().Info("task added",
+                               zap.String("appID", app.applicationID),
+                               zap.String("taskID", task.taskID),
+                               zap.String("taskState", task.GetTaskState()))
+                       if app.GetOriginatingTask() == nil {

Review Comment:
   Ok, this is a mock class, so my comment below might not apply, but still 
asking the same question 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: [email protected]

For queries about this service, please contact Infrastructure at:
[email protected]

Reply via email to