pospt prep

This commit is contained in:
mr
2026-03-26 11:15:02 +01:00
parent 12eba65a01
commit f8a6e69ef3
3 changed files with 32 additions and 9 deletions

View File

@@ -3,6 +3,7 @@ package scheduler
import (
"errors"
"fmt"
"oc-scheduler/conf"
"oc-scheduler/infrastructure/planner"
"oc-scheduler/infrastructure/scheduling_resources"
infUtils "oc-scheduler/infrastructure/utils"
@@ -20,8 +21,6 @@ import (
"github.com/robfig/cron"
)
const asapBuffer = 2 * time.Minute
// Schedule holds a resolved start/end pair for a single execution slot.
type Schedule struct {
Start time.Time
@@ -80,9 +79,18 @@ func (ws *WorkflowSchedule) Check(wfID string, asap bool, preemption bool, reque
}
wf := obj.(*workflow.Workflow)
prepLead := conf.GetConfig().PrepLead()
start := ws.Start
if asap || start.IsZero() {
start = time.Now().UTC().Add(asapBuffer)
start = time.Now().UTC().Add(prepLead)
} else if start.Before(time.Now().UTC().Add(prepLead)) {
// Explicit date is within the prep window — impossible to guarantee on time.
return nil, fmt.Errorf(
"start date %s is too soon: minimum lead time is %s (earliest: %s)",
start.Format(time.RFC3339),
prepLead,
time.Now().UTC().Add(prepLead).Format(time.RFC3339),
)
}
end := ws.End