Skip to content

Commit

Permalink
fix(api): concat logs (#4616)
Browse files Browse the repository at this point in the history
Signed-off-by: Yvonnick Esnault <[email protected]>
  • Loading branch information
yesnault authored and sguiheux committed Sep 24, 2019
1 parent 83a05f8 commit 0289c06
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 24 deletions.
13 changes: 1 addition & 12 deletions engine/api/workflow/execute_node_job_run.go
Original file line number Diff line number Diff line change
Expand Up @@ -557,18 +557,7 @@ func AddLog(db gorp.SqlExecutor, job *sdk.WorkflowNodeJobRun, logs *sdk.Log, max
return sdk.WrapError(insertLog(db, logs), "cannot insert log")
}

existingLogs, err := LoadStepLogs(db, logs.PipelineBuildJobID, logs.StepOrder)
if err != nil {
return sdk.WrapError(err, "cannot load existing logs")
}

logbuf := bytes.NewBufferString(existingLogs.Val)
logbuf.WriteString(logs.Val)
existingLogs.Val = logbuf.String()
existingLogs.LastModified = logs.LastModified
existingLogs.Done = logs.Done

return sdk.WrapError(updateLog(db, existingLogs), "cannot update log")
return sdk.WrapError(updateLog(db, logs), "cannot update log")
}

//AddServiceLog adds a service log
Expand Down
20 changes: 8 additions & 12 deletions engine/api/workflow/execute_node_job_run_log.go
Original file line number Diff line number Diff line change
Expand Up @@ -142,14 +142,12 @@ func updateLog(db gorp.SqlExecutor, logs *sdk.Log) error {

query := `
UPDATE workflow_node_run_job_logs set
workflow_node_run_job_id = $1,
workflow_node_run_id = $2,
start = $3,
last_modified = $4,
done = $5,
step_order = $6,
value = $7
where id = $8`
workflow_node_run_id = $3,
start = $4,
last_modified = $5,
done = $6,
value = value || $7
WHERE workflow_node_run_job_id = $1 AND step_order = $2`

s, errs := ptypes.Timestamp(logs.Start)
if errs != nil {
Expand All @@ -164,8 +162,6 @@ func updateLog(db gorp.SqlExecutor, logs *sdk.Log) error {
return errd
}

if _, err := db.Exec(query, logs.PipelineBuildJobID, logs.PipelineBuildID, s, m, d, logs.StepOrder, logs.Val, logs.Id); err != nil {
return err
}
return nil
_, err := db.Exec(query, logs.PipelineBuildJobID, logs.StepOrder, logs.PipelineBuildID, s, m, d, logs.Val)
return sdk.WrapError(err, "unable to update log")
}

0 comments on commit 0289c06

Please sign in to comment.