Skip to content

Commit

Permalink
add debug logs
Browse files Browse the repository at this point in the history
Signed-off-by: Min Min <[email protected]>
  • Loading branch information
jamsman94 committed Feb 21, 2025
1 parent 1f62d5b commit 0723f22
Show file tree
Hide file tree
Showing 3 changed files with 25 additions and 0 deletions.
9 changes: 9 additions & 0 deletions pkg/microservice/aslan/core/release_plan/service/execute.go
Original file line number Diff line number Diff line change
Expand Up @@ -131,12 +131,18 @@ func (e *WorkflowReleaseJobExecutor) Execute(plan *models.ReleasePlan) error {
return errors.Errorf("job %s status %s can't execute", job.Name, job.Status)
}

dbStartTime := time.Now().Unix()
log.Infof(">>>>>>>>>>>>>>> [execute release plan] db query for original workflow started: time: %d <<<<<<<<<<<<<<<<", dbStartTime)
originalWorkflow, err := mongodb.NewWorkflowV4Coll().Find(spec.Workflow.Name)
if err != nil {
log.Errorf("Failed to find WorkflowV4: %s, the error is: %v", spec.Workflow.Name, err)
return fmt.Errorf("failed to find WorkflowV4: %s, the error is: %v", spec.Workflow.Name, err)
}
log.Infof(">>>>>>>>>>>>>>> [execute release plan] db query for original workflow ended: time: %d <<<<<<<<<<<<<<<<", time.Now().Unix())
log.Infof(">>>>>>>>>>>>>>> [execute release plan] db query for original workflow time used: %d <<<<<<<<<<<<<<<<", time.Now().Unix()-dbStartTime)

processStartTime := time.Now().Unix()
log.Infof(">>>>>>>>>>>>>>> [execute release plan] processing workflow execution parameter started: time: %d <<<<<<<<<<<<<<<<", processStartTime)
if err := jobctl.MergeArgs(originalWorkflow, spec.Workflow); err != nil {
errMsg := fmt.Sprintf("merge workflow args error: %v", err)
log.Error(errMsg)
Expand All @@ -162,6 +168,9 @@ func (e *WorkflowReleaseJobExecutor) Execute(plan *models.ReleasePlan) error {
}
}

log.Infof(">>>>>>>>>>>>>>> [execute release plan] processing workflow execution parameter ended: time: %d <<<<<<<<<<<<<<<<", time.Now().Unix())
log.Infof(">>>>>>>>>>>>>>> [execute release plan] processing workflow execution parameter time used: %d <<<<<<<<<<<<<<<<", time.Now().Unix()-processStartTime)

ctx := e.Ctx
result, err := workflow.CreateWorkflowTaskV4(&workflow.CreateWorkflowTaskV4Args{
Name: ctx.UserName,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -433,10 +433,14 @@ func ExecuteReleaseJob(c *handler.Context, planID string, args *ExecuteReleaseJo

ctx, cancel := context.WithTimeout(context.Background(), defaultTimeout)
defer cancel()
dbStartTime := time.Now().Unix()
log.Infof(">>>>>>>>>>>>>>> [execute release plan] db query for plan started: time: %d <<<<<<<<<<<<<<<<", dbStartTime)
plan, err := mongodb.NewReleasePlanColl().GetByID(ctx, planID)
if err != nil {
return errors.Wrap(err, "get plan")
}
log.Infof(">>>>>>>>>>>>>>> [execute release plan] db query for plan ended: time: %d <<<<<<<<<<<<<<<<", time.Now().Unix())
log.Infof(">>>>>>>>>>>>>>> [execute release plan] db query for plan time used: %d <<<<<<<<<<<<<<<<", time.Now().Unix()-dbStartTime)

if plan.Status != config.StatusExecuting {
return errors.Errorf("plan status is %s, can not execute", plan.Status)
Expand Down Expand Up @@ -475,9 +479,13 @@ func ExecuteReleaseJob(c *handler.Context, planID string, args *ExecuteReleaseJo
plan.Status = config.StatusSuccess
}

dbStartTime = time.Now().Unix()
log.Infof(">>>>>>>>>>>>>>> [execute release plan] db query for updating plan started: time: %d <<<<<<<<<<<<<<<<", dbStartTime)
if err = mongodb.NewReleasePlanColl().UpdateByID(ctx, planID, plan); err != nil {
return errors.Wrap(err, "update plan")
}
log.Infof(">>>>>>>>>>>>>>> [execute release plan] db query for updating plan ended: time: %d <<<<<<<<<<<<<<<<", time.Now().Unix())
log.Infof(">>>>>>>>>>>>>>> [execute release plan] db query for updating plan time used: %d <<<<<<<<<<<<<<<<", time.Now().Unix()-dbStartTime)

go func() {
if err := mongodb.NewReleasePlanLogColl().Create(&models.ReleasePlanLog{
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -1058,12 +1058,18 @@ func ListWorkflowTaskV4ByFilter(filter *TaskHistoryFilter, filterList []string,
ProjectName: filter.ProjectName,
}
}
dbStartTime := time.Now().Unix()
logger.Infof(">>>>>>>>>>>>>>> [list v4 workflow task] db query started: time: %d <<<<<<<<<<<<<<<<", dbStartTime)
tasks, total, err := commonrepo.NewworkflowTaskv4Coll().ListByFilter(listTaskOpt, filter.PageNum, filter.PageSize)
if err != nil {
logger.Errorf("list workflowTaskV4 error: %s", err)
return nil, total, err
}
logger.Infof(">>>>>>>>>>>>>>> [list v4 workflow task] db query ended: time: %d <<<<<<<<<<<<<<<<", time.Now().Unix())
logger.Infof(">>>>>>>>>>>>>>> [list v4 workflow task] db query time used: %d <<<<<<<<<<<<<<<<", time.Now().Unix()-dbStartTime)

processStartTime := time.Now().Unix()
logger.Infof(">>>>>>>>>>>>>>> [list v4 workflow task] data processing started: time: %d <<<<<<<<<<<<<<<<", processStartTime)
taskPreviews := make([]*commonmodels.WorkflowTaskPreview, 0)
for _, task := range tasks {
preview := &commonmodels.WorkflowTaskPreview{
Expand Down Expand Up @@ -1207,6 +1213,8 @@ func ListWorkflowTaskV4ByFilter(filter *TaskHistoryFilter, filterList []string,
taskPreviews = append(taskPreviews, preview)
}
cleanWorkflowV4TasksPreviews(taskPreviews)
logger.Infof(">>>>>>>>>>>>>>> [list v4 workflow task] data processing ended: time: %d <<<<<<<<<<<<<<<<", time.Now().Unix())
logger.Infof(">>>>>>>>>>>>>>> [list v4 workflow task] data processing time used: %d <<<<<<<<<<<<<<<<", time.Now().Unix()-processStartTime)
return taskPreviews, total, nil
}

Expand Down

0 comments on commit 0723f22

Please sign in to comment.