pospt prep
This commit is contained in:
@@ -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
|
||||
|
||||
Reference in New Issue
Block a user