From bdf18917fa135d919326cef47d4edba491272b42 Mon Sep 17 00:00:00 2001 From: Coenen Benjamin Date: Thu, 14 Jun 2018 11:25:01 +0200 Subject: [PATCH] fix(api): fix load run error (#2883) Signed-off-by: Benjamin Coenen --- engine/api/workflow/execute_node_job_run.go | 18 +++++++++--------- .../pipeline/show/pipeline.show.component.ts | 2 +- 2 files changed, 10 insertions(+), 10 deletions(-) diff --git a/engine/api/workflow/execute_node_job_run.go b/engine/api/workflow/execute_node_job_run.go index 72d267bf53..a620e9c8a2 100644 --- a/engine/api/workflow/execute_node_job_run.go +++ b/engine/api/workflow/execute_node_job_run.go @@ -178,20 +178,20 @@ func UpdateNodeJobRunStatus(ctx context.Context, dbCopy *gorp.DbMap, db gorp.Sql var errReport error report, errReport = report.Merge(execute(ctx, dbCopy, db, store, proj, node)) + wr, err := LoadRunByID(db, node.WorkflowRunID, LoadRunOptions{DisableDetailledNodeRun: true}) + if err != nil { + return report, sdk.WrapError(err, "workflow.UpdateNodeJobRunStatus> Cannot load run by ID %d", node.WorkflowRunID) + } + //Start a goroutine to update commit statuses in repositories manager - go func() { - wr, err := LoadRunByID(dbCopy, node.WorkflowRunID, LoadRunOptions{}) - if err != nil { - log.Error("workflow.UpdateNodeJobRunStatus> Cannot load run by ID %d", node.WorkflowRunID) - return - } - if sdk.StatusIsTerminated(wr.Status) { + go func(wfRun *sdk.WorkflowRun) { + if sdk.StatusIsTerminated(wfRun.Status) { wr.LastExecution = time.Now() - if err := ResyncCommitStatus(ctx, dbCopy, store, proj, wr); err != nil { + if err := ResyncCommitStatus(ctx, dbCopy, store, proj, wfRun); err != nil { log.Error("workflow.UpdateNodeJobRunStatus> %v", err) } } - }() + }(wr) return report, errReport } diff --git a/ui/src/app/views/pipeline/show/pipeline.show.component.ts b/ui/src/app/views/pipeline/show/pipeline.show.component.ts index 5c76453e3d..7449ce7ee2 100644 --- a/ui/src/app/views/pipeline/show/pipeline.show.component.ts +++ b/ui/src/app/views/pipeline/show/pipeline.show.component.ts @@ -86,7 +86,7 @@ export class PipelineShowComponent implements OnInit, OnDestroy { this.asCodeEditorSubscription = this._pipCoreService.getAsCodeEditor() .subscribe((state) => { - if (state != null && !state.save && !state.open) { + if (state != null && !state.save && !state.open && this.pipeline) { let pipName = this.pipeline.name; this.pipeline = null; this.refreshDatas(this.project.key, pipName);