mirror of
https://github.com/onepanelio/onepanel.git
synced 2025-10-13 01:13:40 +08:00
update: cron workflows to use new labels
This commit is contained in:
@@ -565,29 +565,18 @@ func (c *Client) createWorkflowExecutionDB(namespace string, workflowExecution *
|
||||
}
|
||||
|
||||
func (c *Client) FinishWorkflowExecutionStatisticViaExitHandler(namespace, name string, workflowTemplateID int64, phase wfv1.NodePhase, startedAt time.Time) (err error) {
|
||||
tx, err := c.DB.Begin()
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
defer tx.Rollback()
|
||||
|
||||
updateMap := sq.Eq{
|
||||
"started_at": startedAt.UTC(),
|
||||
"name": name,
|
||||
"namespace": namespace,
|
||||
"finished_at": time.Now().UTC(),
|
||||
"phase": phase,
|
||||
}
|
||||
|
||||
_, err = sb.Update("workflow_executions").
|
||||
SetMap(updateMap).Where(sq.Eq{"name": name}).RunWith(tx).Exec()
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
err = tx.Commit()
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
SetMap(sq.Eq{
|
||||
"started_at": startedAt.UTC(),
|
||||
"name": name,
|
||||
"namespace": namespace,
|
||||
"finished_at": time.Now().UTC(),
|
||||
"phase": phase,
|
||||
}).
|
||||
Where(sq.Eq{"name": name}).
|
||||
RunWith(c.DB).
|
||||
Exec()
|
||||
|
||||
return err
|
||||
}
|
||||
|
||||
@@ -609,12 +598,6 @@ func (c *Client) CronStartWorkflowExecutionStatisticInsert(namespace, uid string
|
||||
return err
|
||||
}
|
||||
|
||||
tx, err := c.DB.Begin()
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
defer tx.Rollback()
|
||||
|
||||
parametersJSON, err := cronWorkflow.GetParametersFromWorkflowSpecJSON()
|
||||
if err != nil {
|
||||
return err
|
||||
@@ -631,26 +614,16 @@ func (c *Client) CronStartWorkflowExecutionStatisticInsert(namespace, uid string
|
||||
"started_at": time.Now().UTC(),
|
||||
"cron_workflow_id": cronWorkflow.ID,
|
||||
"parameters": string(parametersJSON),
|
||||
"labels": cronWorkflow.Labels,
|
||||
}).
|
||||
Suffix("RETURNING id").
|
||||
RunWith(tx).
|
||||
RunWith(c.DB).
|
||||
QueryRow().
|
||||
Scan(&workflowExecutionID)
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
|
||||
cronLabels, err := c.GetDBLabelsMapped(TypeCronWorkflow, cronWorkflow.ID)
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
labelsMapped := cronLabels[cronWorkflow.ID]
|
||||
if _, err := c.InsertLabelsRunner(tx, TypeWorkflowExecution, workflowExecutionID, labelsMapped); err != nil {
|
||||
return err
|
||||
}
|
||||
|
||||
err = tx.Commit()
|
||||
|
||||
return err
|
||||
}
|
||||
|
||||
|
Reference in New Issue
Block a user