missing datacenter resource
This commit is contained in:
parent
6724ff38fe
commit
a39f539426
@ -195,44 +195,40 @@ func (wfa *workflowMongoAccessor) execution(id string, realData *Workflow, delet
|
|||||||
if ok, _ := realData.CheckBooking(wfa.Caller); !ok { // check the booking of the workflow
|
if ok, _ := realData.CheckBooking(wfa.Caller); !ok { // check the booking of the workflow
|
||||||
return 409, errors.New("could not book the workflow")
|
return 409, errors.New("could not book the workflow")
|
||||||
}
|
}
|
||||||
var err error
|
|
||||||
nats := tools.NewNATSCaller() // create a new nats caller because executions are sent to the nats for daemons
|
nats := tools.NewNATSCaller() // create a new nats caller because executions are sent to the nats for daemons
|
||||||
if !realData.ScheduleActive { // if the schedule is not active, delete the executions
|
|
||||||
mongo.MONGOService.DeleteMultiple(map[string]interface{}{
|
mongo.MONGOService.DeleteMultiple(map[string]interface{}{
|
||||||
"state": 1, // only delete the scheduled executions only scheduled if executions are in progress or ended, they should not be deleted for registration
|
"state": 1, // only delete the scheduled executions only scheduled if executions are in progress or ended, they should not be deleted for registration
|
||||||
"workflow_id": id,
|
"workflow_id": id,
|
||||||
}, tools.WORKFLOW_EXECUTION.String())
|
}, tools.WORKFLOW_EXECUTION.String())
|
||||||
err := wfa.book(id, realData, []*workflow_execution.WorkflowExecution{}) // delete the booking of the workflow on the peers
|
err := wfa.book(id, realData, []*workflow_execution.WorkflowExecution{}) // delete the booking of the workflow on the peers
|
||||||
|
fmt.Println("DELETE BOOKING", err)
|
||||||
nats.SetNATSPub(tools.WORKFLOW.String(), tools.REMOVE, realData) // send the deletion to the nats
|
nats.SetNATSPub(tools.WORKFLOW.String(), tools.REMOVE, realData) // send the deletion to the nats
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return 409, err
|
return 409, err
|
||||||
}
|
}
|
||||||
return 200, nil
|
|
||||||
}
|
|
||||||
accessor := (&workflow_execution.WorkflowExecution{}).GetAccessor(nil)
|
accessor := (&workflow_execution.WorkflowExecution{}).GetAccessor(nil)
|
||||||
execs, err := wfa.getExecutions(id, realData) // get the executions of the workflow
|
execs, err := wfa.getExecutions(id, realData) // get the executions of the workflow
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return 422, err
|
return 422, err
|
||||||
}
|
}
|
||||||
|
if !realData.ScheduleActive || delete { // if the schedule is not active, delete the executions
|
||||||
|
execs = []*workflow_execution.WorkflowExecution{}
|
||||||
|
}
|
||||||
err = wfa.book(id, realData, execs) // book the workflow on the peers
|
err = wfa.book(id, realData, execs) // book the workflow on the peers
|
||||||
|
fmt.Println("BOOKING", err)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return 409, err // if the booking fails, return an error for integrity between peers
|
return 409, err // if the booking fails, return an error for integrity between peers
|
||||||
}
|
}
|
||||||
|
fmt.Println("BOOKING", delete)
|
||||||
if delete { // if delete is set to true, delete the executions
|
|
||||||
return 200, nil
|
|
||||||
}
|
|
||||||
if len(execs) > 0 { // if the executions are set, store them
|
|
||||||
for _, obj := range execs {
|
for _, obj := range execs {
|
||||||
_, code, err := accessor.StoreOne(obj)
|
_, code, err := accessor.StoreOne(obj)
|
||||||
|
fmt.Println("EXEC", code, err)
|
||||||
if code != 200 {
|
if code != 200 {
|
||||||
return code, err
|
return code, err
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
nats.SetNATSPub(tools.WORKFLOW.String(), tools.CREATE, realData) // send the creation to the nats
|
nats.SetNATSPub(tools.WORKFLOW.String(), tools.CREATE, realData) // send the creation to the nats
|
||||||
} else {
|
|
||||||
return 422, err
|
|
||||||
}
|
|
||||||
return 200, nil
|
return 200, nil
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -248,6 +244,7 @@ func (wfa *workflowMongoAccessor) UpdateOne(set utils.DBObject, id string) (util
|
|||||||
if code != 200 {
|
if code != 200 {
|
||||||
return nil, code, err
|
return nil, code, err
|
||||||
}
|
}
|
||||||
|
fmt.Println("UPDATE", avoid, res.(*Workflow).ScheduleActive)
|
||||||
if !avoid { // if the schedule is not avoided, update the executions
|
if !avoid { // if the schedule is not avoided, update the executions
|
||||||
if code, err := wfa.execution(id, res.(*Workflow), false); code != 200 {
|
if code, err := wfa.execution(id, res.(*Workflow), false); code != 200 {
|
||||||
return nil, code, errors.New("could not update the executions : " + err.Error())
|
return nil, code, errors.New("could not update the executions : " + err.Error())
|
||||||
|
Loading…
Reference in New Issue
Block a user