mirror of
https://github.com/onepanelio/onepanel.git
synced 2025-10-05 21:56:50 +08:00
append statistics template if there is an existing handler
This commit is contained in:
@@ -1315,19 +1315,34 @@ func InjectExitHandlerWorkflowExecutionStatistic(wf *wfv1.Workflow, namespace st
|
|||||||
if err != nil {
|
if err != nil {
|
||||||
return err
|
return err
|
||||||
}
|
}
|
||||||
if exitHandlerStepTemplate != "" {
|
|
||||||
exitHandler := wfv1.Template{
|
dagTask := wfv1.DAGTask{
|
||||||
|
Name: exitHandlerStepName, Template: exitHandlerStepTemplate, When: exitHandlerStepWhen,
|
||||||
|
}
|
||||||
|
|
||||||
|
wf.Spec.Templates = append(wf.Spec.Templates, exitHandlerTemplate)
|
||||||
|
if wf.Spec.OnExit != "" {
|
||||||
|
for _, t := range wf.Spec.Templates {
|
||||||
|
if t.Name == wf.Spec.OnExit {
|
||||||
|
lasTaskIndex := len(t.DAG.Tasks) - 1
|
||||||
|
dagTask.Dependencies = []string{t.DAG.Tasks[lasTaskIndex].Name}
|
||||||
|
|
||||||
|
t.DAG.Tasks = append(t.DAG.Tasks, dagTask)
|
||||||
|
|
||||||
|
break
|
||||||
|
}
|
||||||
|
}
|
||||||
|
} else {
|
||||||
|
exitHandlerDAG := wfv1.Template{
|
||||||
Name: "exit-handler",
|
Name: "exit-handler",
|
||||||
Steps: []wfv1.ParallelSteps{
|
DAG: &wfv1.DAGTemplate{
|
||||||
{
|
Tasks: []wfv1.DAGTask{
|
||||||
Steps: []wfv1.WorkflowStep{
|
dagTask,
|
||||||
{Name: exitHandlerStepName, Template: exitHandlerStepTemplate, When: exitHandlerStepWhen},
|
|
||||||
},
|
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
}
|
}
|
||||||
wf.Spec.OnExit = "exit-handler"
|
wf.Spec.OnExit = "exit-handler"
|
||||||
wf.Spec.Templates = append(wf.Spec.Templates, exitHandler, exitHandlerTemplate)
|
wf.Spec.Templates = append(wf.Spec.Templates, exitHandlerDAG)
|
||||||
}
|
}
|
||||||
return nil
|
return nil
|
||||||
}
|
}
|
||||||
|
Reference in New Issue
Block a user