Skip to content

Commit

Permalink
api: rest: Delete workflow when failed to finish of creating the work…
Browse files Browse the repository at this point in the history
…flow
  • Loading branch information
ish-hcc committed Nov 15, 2024
1 parent 2046054 commit a2b3be3
Showing 1 changed file with 7 additions and 0 deletions.
7 changes: 7 additions & 0 deletions pkg/api/rest/controller/workflow.go
Original file line number Diff line number Diff line change
Expand Up @@ -179,12 +179,18 @@ func CreateWorkflow(c echo.Context) error {
workflow.Name = createWorkflowReq.Name
workflow.Data = workflowData

var success bool
_, err = dao.WorkflowCreate(&workflow)
if err != nil {
{
return common.ReturnErrorMsg(c, err.Error())
}
}
defer func() {
if !success {
_ = dao.WorkflowDelete(&workflow)
}
}()

client, err := airflow.GetClient()
if err != nil {
Expand Down Expand Up @@ -218,6 +224,7 @@ func CreateWorkflow(c echo.Context) error {
}
}
}
success = true

return c.JSONPretty(http.StatusOK, workflow, " ")
}
Expand Down

0 comments on commit a2b3be3

Please sign in to comment.