oc-scheduler -> scheduling + logs

This commit is contained in:
mr
2026-04-08 10:05:27 +02:00
parent f8a6e69ef3
commit 1d63d31442
21 changed files with 4605 additions and 139 deletions

View File

@@ -44,7 +44,7 @@ func (s *SessionExecutionsService) sessionIDFilter(field, id string) *dbs.Filter
func (s *SessionExecutionsService) loadSession(dt tools.DataType) []scheduling_resources.SchedulerObject {
results := oclib.NewRequestAdmin(oclib.LibDataEnum(dt), nil).Search(
s.sessionIDFilter("executions_id", s.ExecutionsSessionID), "", true)
s.sessionIDFilter("executions_id", s.ExecutionsSessionID), "", true, 0, 10000)
out := make([]scheduling_resources.SchedulerObject, 0, len(results.Data))
for _, obj := range results.Data {
out = append(out, scheduling_resources.ToSchedulerObject(dt, obj))
@@ -55,7 +55,7 @@ func (s *SessionExecutionsService) loadSession(dt tools.DataType) []scheduling_r
func (s *SessionExecutionsService) LoadSessionExecs() []*workflow_execution.WorkflowExecution {
adminReq := &tools.APIRequest{Admin: true}
results, _, _ := workflow_execution.NewAccessor(adminReq).Search(
s.sessionIDFilter("executions_id", s.ExecutionsSessionID), "", true)
s.sessionIDFilter("executions_id", s.ExecutionsSessionID), "", true, 0, 10000)
out := make([]*workflow_execution.WorkflowExecution, 0)
for _, obj := range results {
if exec, ok := obj.(*workflow_execution.WorkflowExecution); ok {
@@ -68,7 +68,7 @@ func (s *SessionExecutionsService) LoadSessionExecs() []*workflow_execution.Work
func (s *SessionExecutionsService) loadSessionOrder() *order.Order {
adminReq := &tools.APIRequest{Admin: true}
results, _, _ := order.NewAccessor(adminReq).Search(
s.sessionIDFilter("executions_id", s.ExecutionsSessionID), "", true)
s.sessionIDFilter("executions_id", s.ExecutionsSessionID), "", true, 0, 10000)
for _, obj := range results {
if o, ok := obj.(*order.Order); ok {
return o
@@ -174,8 +174,18 @@ func (s *SessionExecutionsService) upsertDrafts(
func (s *SessionExecutionsService) CleanupSession(request *tools.APIRequest) {
adminReq := &tools.APIRequest{Admin: true}
// Delete bookings and purchases directly by executions_id.
// We cannot rely on execution.Unschedule here because it uses
// exec.PeerBookByGraph which is empty during the draft/check phase.
for _, dt := range []tools.DataType{tools.BOOKING, tools.PURCHASE_RESOURCE} {
for _, obj := range s.loadSession(dt) {
scheduling_resources.GetService().Delete(dt, obj, request)
}
}
for _, exec := range s.LoadSessionExecs() {
execution.Unschedule(exec.GetID(), request)
execution.UnregisterExecLock(exec.GetID())
workflow_execution.NewAccessor(adminReq).DeleteOne(exec.GetID())
}
if o := s.loadSessionOrder(); o != nil {