From faf86f10f9563da241fe1f4a83b59bed62017a0c Mon Sep 17 00:00:00 2001 From: Jian Zhu <36154065+zhujian7@users.noreply.github.com> Date: Tue, 15 Oct 2019 13:08:18 +0800 Subject: [PATCH] feat: record workflow topology to workflow run (#1312) If the topology of a workflow changed, the old workflowRun's running status can not display, So we need to record workflow's topology at workflowRun running time to workflowRun status. --- pkg/apis/cyclone/v1alpha1/workflow_run.go | 6 ++++++ pkg/workflow/workflowrun/operator.go | 4 +++- 2 files changed, 9 insertions(+), 1 deletion(-) diff --git a/pkg/apis/cyclone/v1alpha1/workflow_run.go b/pkg/apis/cyclone/v1alpha1/workflow_run.go index cf5b026e0..0ed27ee6b 100644 --- a/pkg/apis/cyclone/v1alpha1/workflow_run.go +++ b/pkg/apis/cyclone/v1alpha1/workflow_run.go @@ -134,6 +134,12 @@ type StageStatus struct { Status Status `json:"status"` // Key-value outputs of this stage Outputs []KeyValue `json:"outputs"` + // Stages that this stage depends on. + Depends []string `json:"depends"` + // Trivial indicates whether this stage is critical in the workflow. If set to true, it means the workflow + // can tolerate failure of this stage. In this case, all other stages can continue to execute and the overall + // status of the workflow execution can still be succeed. + Trivial bool `json:"trivial"` } // StatusPhase represents the phase of stage status or workflowrun status. diff --git a/pkg/workflow/workflowrun/operator.go b/pkg/workflow/workflowrun/operator.go index 10765ff1c..9caf89c29 100644 --- a/pkg/workflow/workflowrun/operator.go +++ b/pkg/workflow/workflowrun/operator.go @@ -119,7 +119,7 @@ func (o *operator) GetRecorder() record.EventRecorder { return o.recorder } -// InitStagesStatus initializes all missing stages' status to pending. +// InitStagesStatus initializes all missing stages' status to pending, and record workflow topology at this time to workflowRun status. func (o *operator) InitStagesStatus() { if o.wfr.Status.Stages == nil { o.wfr.Status.Stages = make(map[string]*v1alpha1.StageStatus) @@ -131,6 +131,8 @@ func (o *operator) InitStagesStatus() { Status: v1alpha1.Status{ Phase: v1alpha1.StatusPending, }, + Depends: stg.Depends, + Trivial: stg.Trivial, } } }