Added logging for debug
This commit is contained in:
parent
b57f050b81
commit
522c66653b
@ -53,6 +53,8 @@ func NewScheduler(start string, end string, durationInS float64, cron string) *W
|
|||||||
}
|
}
|
||||||
|
|
||||||
func (ws *WorkflowSchedule) CheckBooking(wfID string, request *tools.APIRequest) (bool, *workflow.Workflow, []*WorkflowExecution, []*booking.Booking, error) {
|
func (ws *WorkflowSchedule) CheckBooking(wfID string, request *tools.APIRequest) (bool, *workflow.Workflow, []*WorkflowExecution, []*booking.Booking, error) {
|
||||||
|
l := logs.GetLogger().With().Str("SchedulerID",ws.UUID).Logger()
|
||||||
|
l.Debug().Msg("Checking booking")
|
||||||
if request.Caller == nil && request.Caller.URLS == nil && request.Caller.URLS[tools.BOOKING] == nil || request.Caller.URLS[tools.BOOKING][tools.GET] == "" {
|
if request.Caller == nil && request.Caller.URLS == nil && request.Caller.URLS[tools.BOOKING] == nil || request.Caller.URLS[tools.BOOKING][tools.GET] == "" {
|
||||||
return false, nil, []*WorkflowExecution{}, []*booking.Booking{}, errors.New("no caller defined")
|
return false, nil, []*WorkflowExecution{}, []*booking.Booking{}, errors.New("no caller defined")
|
||||||
}
|
}
|
||||||
@ -71,12 +73,14 @@ func (ws *WorkflowSchedule) CheckBooking(wfID string, request *tools.APIRequest)
|
|||||||
if ws.End != nil && ws.Start.Add(time.Duration(longest)*time.Second).After(*ws.End) {
|
if ws.End != nil && ws.Start.Add(time.Duration(longest)*time.Second).After(*ws.End) {
|
||||||
ws.Warning = "The workflow may be too long to be executed in the given time frame, we will try to book it anyway\n"
|
ws.Warning = "The workflow may be too long to be executed in the given time frame, we will try to book it anyway\n"
|
||||||
}
|
}
|
||||||
|
l.Debug().Msg("Getting executions")
|
||||||
execs, err := ws.getExecutions(wf)
|
execs, err := ws.getExecutions(wf)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return false, wf, []*WorkflowExecution{}, []*booking.Booking{}, err
|
return false, wf, []*WorkflowExecution{}, []*booking.Booking{}, err
|
||||||
}
|
}
|
||||||
bookings := []*booking.Booking{}
|
bookings := []*booking.Booking{}
|
||||||
for _, exec := range execs {
|
for _, exec := range execs {
|
||||||
|
l.Debug().Msg("looping throughs execs")
|
||||||
bookings = append(bookings, exec.Book(ws.UUID, wfID, priceds)...)
|
bookings = append(bookings, exec.Book(ws.UUID, wfID, priceds)...)
|
||||||
for _, b := range bookings {
|
for _, b := range bookings {
|
||||||
meth := request.Caller.URLS[tools.BOOKING][tools.GET]
|
meth := request.Caller.URLS[tools.BOOKING][tools.GET]
|
||||||
@ -84,7 +88,9 @@ func (ws *WorkflowSchedule) CheckBooking(wfID string, request *tools.APIRequest)
|
|||||||
meth = strings.ReplaceAll(meth, ":start_date", b.ExpectedStartDate.Format("2006-01-02T15:04:05"))
|
meth = strings.ReplaceAll(meth, ":start_date", b.ExpectedStartDate.Format("2006-01-02T15:04:05"))
|
||||||
meth = strings.ReplaceAll(meth, ":end_date", b.ExpectedEndDate.Format("2006-01-02T15:04:05"))
|
meth = strings.ReplaceAll(meth, ":end_date", b.ExpectedEndDate.Format("2006-01-02T15:04:05"))
|
||||||
request.Caller.URLS[tools.BOOKING][tools.GET] = meth
|
request.Caller.URLS[tools.BOOKING][tools.GET] = meth
|
||||||
|
l.Debug().Msg("Get booking on" + b.DestPeerID)
|
||||||
_, err := (&peer.Peer{}).LaunchPeerExecution(b.DestPeerID, b.ResourceID, tools.BOOKING, tools.GET, nil, request.Caller)
|
_, err := (&peer.Peer{}).LaunchPeerExecution(b.DestPeerID, b.ResourceID, tools.BOOKING, tools.GET, nil, request.Caller)
|
||||||
|
l.Debug().Msg("Received response from Get booking on" + b.DestPeerID)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return false, wf, execs, bookings, err
|
return false, wf, execs, bookings, err
|
||||||
}
|
}
|
||||||
@ -113,10 +119,11 @@ func (ws *WorkflowSchedule) Schedules(wfID string, request *tools.APIRequest) (*
|
|||||||
}
|
}
|
||||||
ws.Workflow = wf
|
ws.Workflow = wf
|
||||||
for _, booking := range bookings {
|
for _, booking := range bookings {
|
||||||
l := logs.GetLogger()
|
l := logs.GetLogger().With().Str("SchedulerID",ws.UUID).Logger()
|
||||||
l.Info().Msg("Booking on " + booking.DestPeerID)
|
l.Info().Msg("Booking on " + booking.DestPeerID)
|
||||||
_, err := (&peer.Peer{}).LaunchPeerExecution(booking.DestPeerID, "",
|
_, err := (&peer.Peer{}).LaunchPeerExecution(booking.DestPeerID, "",
|
||||||
tools.BOOKING, tools.POST, booking.Serialize(booking), request.Caller)
|
tools.BOOKING, tools.POST, booking.Serialize(booking), request.Caller)
|
||||||
|
l.Debug().Msg("Received answer for booking on " + booking.DestPeerID)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return ws, wf, executions, errors.New("could not launch the peer execution : " + fmt.Sprintf("%v", err))
|
return ws, wf, executions, errors.New("could not launch the peer execution : " + fmt.Sprintf("%v", err))
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user