From 8c856e38cdbae8853c268f201f7a99ad1b965884 Mon Sep 17 00:00:00 2001 From: Richard LT Date: Thu, 7 May 2020 08:51:34 +0200 Subject: [PATCH] fix(api): add new application to ascode workflow (#5152) --- engine/api/workflow/execute_node_job_run.go | 8 ++++++-- sdk/hatchery/starter.go | 4 ++-- .../workflow/node/run/node.run.param.component.ts | 13 ++++++++----- 3 files changed, 16 insertions(+), 9 deletions(-) diff --git a/engine/api/workflow/execute_node_job_run.go b/engine/api/workflow/execute_node_job_run.go index 9b686f9281..aa43717bfa 100644 --- a/engine/api/workflow/execute_node_job_run.go +++ b/engine/api/workflow/execute_node_job_run.go @@ -442,11 +442,15 @@ func LoadSecrets(db gorp.SqlExecutor, store cache.Store, nodeRun *sdk.WorkflowNo // Application variables av := []sdk.Variable{} if app != nil { + // FIXME manage secret ascode + // try to retreive application from database, application can be not found for ascode run tempApp, err := application.LoadByIDWithClearVCSStrategyPassword(db, app.ID) - if err != nil { + if err != nil && !sdk.ErrorIs(err, sdk.ErrNotFound) { return nil, err } - app.RepositoryStrategy = tempApp.RepositoryStrategy + if tempApp != nil { + app.RepositoryStrategy.Password = tempApp.RepositoryStrategy.Password + } appVariables, err := application.LoadAllVariablesWithDecrytion(db, app.ID) if err != nil { diff --git a/sdk/hatchery/starter.go b/sdk/hatchery/starter.go index cd980f4962..09089f3363 100644 --- a/sdk/hatchery/starter.go +++ b/sdk/hatchery/starter.go @@ -167,8 +167,6 @@ func spawnWorkerForJob(ctx context.Context, h Interface, j workerStarterRequest) }) next() - log.Info(ctx, "hatchery> spawnWorkerForJob> SpawnWorker> starting model %s for job %d", modelName, j.id) - _, next = observability.Span(ctxJob, "hatchery.SpawnWorker") arg := SpawnArguments{ WorkerName: generateWorkerName(h.Service().Name, false, modelName), @@ -178,6 +176,8 @@ func spawnWorkerForJob(ctx context.Context, h Interface, j workerStarterRequest) HatcheryName: h.Service().Name, } + log.Info(ctx, "hatchery> spawnWorkerForJob> SpawnWorker> starting model %s for job %d with name %s", modelName, arg.JobID, arg.WorkerName) + // Get a JWT to authentified the worker jwt, err := NewWorkerToken(h.Service().Name, h.GetPrivateKey(), time.Now().Add(1*time.Hour), arg) if err != nil { diff --git a/ui/src/app/shared/workflow/node/run/node.run.param.component.ts b/ui/src/app/shared/workflow/node/run/node.run.param.component.ts index ada71b8f9f..5bdc0042fa 100644 --- a/ui/src/app/shared/workflow/node/run/node.run.param.component.ts +++ b/ui/src/app/shared/workflow/node/run/node.run.param.component.ts @@ -26,7 +26,6 @@ declare var CodeMirror: any; changeDetection: ChangeDetectionStrategy.OnPush }) @AutoUnsubscribe() - export class WorkflowNodeRunParamComponent implements AfterViewInit { @ViewChild('runWithParamModal') runWithParamModal: ModalTemplate; @@ -104,7 +103,7 @@ export class WorkflowNodeRunParamComponent implements AfterViewInit { this.currentNodeRun = this._store.selectSnapshot(WorkflowState.nodeRunSnapshot); this.currentWorkflowRun = this._store.selectSnapshot(WorkflowState.workflowRunSnapshot); this.workflow = this._store.selectSnapshot(WorkflowState.workflowSnapshot); - this.projectKey = this._store.selectSnapshot(ProjectState.projectSnapshot).key; + this.projectKey = this._store.selectSnapshot(ProjectState.projectSnapshot).key; if (this.currentNodeRun && this.currentNodeRun.workflow_node_id !== this.nodeToRun.id) { delete this.currentNodeRun; @@ -124,7 +123,11 @@ export class WorkflowNodeRunParamComponent implements AfterViewInit { } } - this.linkedToRepo = WNode.linkedToRepo(this.nodeToRun, this.workflow); + if (this.currentWorkflowRun && this.currentWorkflowRun.workflow) { + this.linkedToRepo = WNode.linkedToRepo(this.nodeToRun, this.currentWorkflowRun.workflow); + } else { + this.linkedToRepo = WNode.linkedToRepo(this.nodeToRun, this.workflow); + } let num: number; let nodeRunID: number; @@ -221,7 +224,7 @@ export class WorkflowNodeRunParamComponent implements AfterViewInit { .pipe(first(), finalize(() => this._cd.markForCheck())) .subscribe(n => { this.lastNum = n.num + 1; - this.getCommits( n.num + 1, false); + this.getCommits(n.num + 1, false); }); } else { this.getCommits(this.num, false); @@ -433,7 +436,7 @@ export class WorkflowNodeRunParamComponent implements AfterViewInit { this.refreshVCSInfos(this.payloadRemote); } - this.getCommits( num || this.lastNum, true); + this.getCommits(num || this.lastNum, true); }); } }