You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@devlake.apache.org by GitBox <gi...@apache.org> on 2023/01/09 09:57:17 UTC

[GitHub] [incubator-devlake] klesh opened a new pull request, #4158: feat: add TASK_PARTIAL for skip-on-fail pipelines

klesh opened a new pull request, #4158:
URL: https://github.com/apache/incubator-devlake/pull/4158

   ### Summary
   
   Added `TASK_PARTIAL` if SkipOnFail was enabled and not all tasks succeeded.
   
   ### Does this close any open issues?
   Closes #4153 
   


-- 
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: commits-unsubscribe@devlake.apache.org

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


[GitHub] [incubator-devlake] mindlesscloud commented on a diff in pull request #4158: feat: add TASK_PARTIAL for skip-on-fail pipelines

Posted by GitBox <gi...@apache.org>.
mindlesscloud commented on code in PR #4158:
URL: https://github.com/apache/incubator-devlake/pull/4158#discussion_r1064551593


##########
services/pipeline_runner.go:
##########
@@ -126,18 +127,81 @@ func runPipeline(pipelineId uint64) errors.Error {
 		dbPipeline.SpentSeconds = int(finishedAt.Unix() - dbPipeline.BeganAt.Unix())
 	}
 	if err != nil {
-		dbPipeline.Status = models.TASK_FAILED
 		dbPipeline.Message = err.Error()
 		dbPipeline.ErrorName = err.Messages().Format()
-	} else {
-		dbPipeline.Status = models.TASK_COMPLETED
-		dbPipeline.Message = ""
+	}
+	dbPipeline.Status, err = computePipelineStatus(dbPipeline)
+	if err != nil {
+		globalPipelineLog.Error(err, "compute pipeline status failed")
+		return err
 	}
 	err = db.Update(dbPipeline)
 	if err != nil {
 		globalPipelineLog.Error(err, "update pipeline state failed")
-		return errors.Convert(err)
+		return err
 	}
 	// notify external webhook
 	return NotifyExternal(pipelineId)
 }
+
+// computePipelineStatus determines pipleline status by its latest(rerun included) tasks statuses
+// 1. TASK_COMPLETED: all tasks were executed sucessfully
+// 2. TASK_FAILED: SkipOnFail=false with failed task(s)
+// 3. TASK_PARTIAL: SkipOnFail=true with failed task(s)
+func computePipelineStatus(pipeline *models.DbPipeline) (string, errors.Error) {
+	tasks, err := GetLatestTasksOfPipeline(pipeline)
+	if err != nil {
+		return "", err
+	}
+	succeeded, failed := 0, 0
+
+	for _, task := range tasks {
+		if task.Status == models.TASK_COMPLETED {
+			succeeded += 1
+		} else if task.Status == models.TASK_FAILED || task.Status == models.TASK_CANCELLED {
+			failed += 1
+		} else {
+			return "", errors.Default.New("unexpected status, did you call computePipelineStatus at a wrong timing?")

Review Comment:
   some tasks may have a status of `TASK_CREATED` and `TASK_RERUN`



-- 
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: commits-unsubscribe@devlake.apache.org

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


[GitHub] [incubator-devlake] mindlesscloud merged pull request #4158: feat: add TASK_PARTIAL for skip-on-fail pipelines

Posted by GitBox <gi...@apache.org>.
mindlesscloud merged PR #4158:
URL: https://github.com/apache/incubator-devlake/pull/4158


-- 
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: commits-unsubscribe@devlake.apache.org

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