Skip to content

Commit

Permalink
Cherry pick 1921 (#1922)
Browse files Browse the repository at this point in the history
* save origin cunstom workflow args for task clone

Signed-off-by: guoyu <[email protected]>

* fix error msg

Signed-off-by: guoyu <[email protected]>

Signed-off-by: guoyu <[email protected]>
Co-authored-by: guoyu <[email protected]>
  • Loading branch information
dianqihanwangzi and guoyu authored Aug 18, 2022
1 parent 8efe363 commit 830ea54
Show file tree
Hide file tree
Showing 2 changed files with 29 additions and 21 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -23,26 +23,27 @@ import (
)

type WorkflowTask struct {
ID primitive.ObjectID `bson:"_id,omitempty" json:"id,omitempty"`
TaskID int64 `bson:"task_id" json:"task_id"`
WorkflowName string `bson:"workflow_name" json:"workflow_name"`
Params []*Param `bson:"params" json:"params"`
WorkflowArgs *WorkflowV4 `bson:"workflow_args" json:"workflow_args"`
KeyVals []*KeyVal `bson:"key_vals" json:"key_vals"`
GlobalContext map[string]string `bson:"global_context" json:"global_context"`
Status config.Status `bson:"status" json:"status,omitempty"`
TaskCreator string `bson:"task_creator" json:"task_creator,omitempty"`
TaskRevoker string `bson:"task_revoker,omitempty" json:"task_revoker,omitempty"`
CreateTime int64 `bson:"create_time" json:"create_time,omitempty"`
StartTime int64 `bson:"start_time" json:"start_time,omitempty"`
EndTime int64 `bson:"end_time" json:"end_time,omitempty"`
Stages []*StageTask `bson:"stages" json:"stages"`
ProjectName string `bson:"project_name,omitempty" json:"project_name,omitempty"`
IsDeleted bool `bson:"is_deleted" json:"is_deleted"`
IsArchived bool `bson:"is_archived" json:"is_archived"`
Error string `bson:"error,omitempty" json:"error,omitempty"`
IsRestart bool `bson:"is_restart" json:"is_restart"`
MultiRun bool `bson:"multi_run" json:"multi_run"`
ID primitive.ObjectID `bson:"_id,omitempty" json:"id,omitempty"`
TaskID int64 `bson:"task_id" json:"task_id"`
WorkflowName string `bson:"workflow_name" json:"workflow_name"`
Params []*Param `bson:"params" json:"params"`
WorkflowArgs *WorkflowV4 `bson:"workflow_args" json:"workflow_args"`
OriginWorkflowArgs *WorkflowV4 `bson:"origin_workflow_args" json:"origin_workflow_args"`
KeyVals []*KeyVal `bson:"key_vals" json:"key_vals"`
GlobalContext map[string]string `bson:"global_context" json:"global_context"`
Status config.Status `bson:"status" json:"status,omitempty"`
TaskCreator string `bson:"task_creator" json:"task_creator,omitempty"`
TaskRevoker string `bson:"task_revoker,omitempty" json:"task_revoker,omitempty"`
CreateTime int64 `bson:"create_time" json:"create_time,omitempty"`
StartTime int64 `bson:"start_time" json:"start_time,omitempty"`
EndTime int64 `bson:"end_time" json:"end_time,omitempty"`
Stages []*StageTask `bson:"stages" json:"stages"`
ProjectName string `bson:"project_name,omitempty" json:"project_name,omitempty"`
IsDeleted bool `bson:"is_deleted" json:"is_deleted"`
IsArchived bool `bson:"is_archived" json:"is_archived"`
Error string `bson:"error,omitempty" json:"error,omitempty"`
IsRestart bool `bson:"is_restart" json:"is_restart"`
MultiRun bool `bson:"multi_run" json:"multi_run"`
}

func (WorkflowTask) TableName() string {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -123,6 +123,13 @@ func CreateWorkflowTaskV4(user string, workflow *commonmodels.WorkflowV4, log *z
return resp, err
}
workflowTask := &commonmodels.WorkflowTask{}
// save workflow original workflow task args.
originTaskArgs := &commonmodels.WorkflowV4{}
if err := commonmodels.IToi(workflow, originTaskArgs); err != nil {
log.Errorf("save original workflow args error: %v", err)
return resp, e.ErrCreateTask.AddDesc(err.Error())
}
workflowTask.OriginWorkflowArgs = originTaskArgs
nextTaskID, err := commonrepo.NewCounterColl().GetNextSeq(fmt.Sprintf(setting.WorkflowTaskV4Fmt, workflow.Name))
if err != nil {
log.Errorf("Counter.GetNextSeq error: %v", err)
Expand Down Expand Up @@ -210,7 +217,7 @@ func CloneWorkflowTaskV4(workflowName string, taskID int64, logger *zap.SugaredL
logger.Errorf("find workflowTaskV4 error: %s", err)
return nil, e.ErrGetTask.AddErr(err)
}
return task.WorkflowArgs, nil
return task.OriginWorkflowArgs, nil
}

func UpdateWorkflowTaskV4(id string, workflowTask *commonmodels.WorkflowTask, logger *zap.SugaredLogger) error {
Expand Down

0 comments on commit 830ea54

Please sign in to comment.