Scheduler + Observe
This commit is contained in:
@@ -13,6 +13,7 @@ import (
|
||||
"cloud.o-forge.io/core/oc-lib/models/booking"
|
||||
"cloud.o-forge.io/core/oc-lib/models/common/enum"
|
||||
"cloud.o-forge.io/core/oc-lib/models/common/pricing"
|
||||
"cloud.o-forge.io/core/oc-lib/models/resources"
|
||||
"cloud.o-forge.io/core/oc-lib/models/utils"
|
||||
"cloud.o-forge.io/core/oc-lib/models/workflow"
|
||||
"cloud.o-forge.io/core/oc-lib/models/workflow_execution"
|
||||
@@ -40,12 +41,14 @@ type WorkflowSchedule struct {
|
||||
DurationS float64 `json:"duration_s" default:"-1"`
|
||||
Cron string `json:"cron,omitempty"`
|
||||
|
||||
BookingMode booking.BookingMode `json:"booking_mode,omitempty"`
|
||||
SelectedInstances workflow.ConfigItem `json:"selected_instances"`
|
||||
SelectedPartnerships workflow.ConfigItem `json:"selected_partnerships"`
|
||||
SelectedBuyings workflow.ConfigItem `json:"selected_buyings"`
|
||||
SelectedStrategies workflow.ConfigItem `json:"selected_strategies"`
|
||||
SelectedBillingStrategy pricing.BillingStrategy `json:"selected_billing_strategy"`
|
||||
BookingMode booking.BookingMode `json:"booking_mode,omitempty"`
|
||||
SelectedInstances workflow.ConfigItem `json:"selected_instances"`
|
||||
SelectedPartnerships workflow.ConfigItem `json:"selected_partnerships"`
|
||||
SelectedBuyings workflow.ConfigItem `json:"selected_buyings"`
|
||||
SelectedStrategies workflow.ConfigItem `json:"selected_strategies"`
|
||||
SelectedPaymentType workflow.ConfigItem `json:"selected_payment_type"`
|
||||
SelectedBillingStrategy pricing.BillingStrategy `json:"selected_billing_strategy"`
|
||||
SelectedEmbeddedStorages map[string]*resources.EmbeddedStorageSelection `json:"selected_embedded_storages,omitempty"`
|
||||
|
||||
// Confirm, when true, triggers Schedule() to confirm the drafts held by this session.
|
||||
Confirm bool `json:"confirm,omitempty"`
|
||||
@@ -119,6 +122,28 @@ func (ws *WorkflowSchedule) Check(wfID string, asap bool, preemption bool, reque
|
||||
checkables := infUtils.CollectBookingResources(wf, ws.SelectedInstances)
|
||||
start, end, available, preemptible, warnings := planner.GetPlannerService().FindDate(wfID, checkables, start, end, preemption, asap)
|
||||
|
||||
// Dynamic resources are resolved separately: their peer planners are fetched
|
||||
// and the sorted instance list is walked until an available one is found.
|
||||
var dynamics []*resources.DynamicResource
|
||||
for _, item := range wf.GetGraphItems(wf.Graph.IsDynamic) {
|
||||
_, res := item.GetResource()
|
||||
if res == nil {
|
||||
continue
|
||||
}
|
||||
d := res.(*resources.DynamicResource)
|
||||
d.SetAllowedInstances(request)
|
||||
dynamics = append(dynamics, d)
|
||||
}
|
||||
if len(dynamics) > 0 {
|
||||
didToPID := planner.GetPlannerService().FillDynamic(dynamics, wfID)
|
||||
for _, d := range dynamics {
|
||||
if !planner.GetPlannerService().ResolveDynamic(d, didToPID, start, end) {
|
||||
available = false
|
||||
warnings = append(warnings, "no available instance for dynamic resource "+d.GetName())
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
return &CheckResult{
|
||||
Start: start,
|
||||
End: end,
|
||||
@@ -197,12 +222,17 @@ func (ws *WorkflowSchedule) GenerateExecutions(wf *workflow.Workflow, isPreempti
|
||||
UUID: uuid.New().String(),
|
||||
Name: wf.Name + " execution " + date.Start.Format("2006-01-02 15:04"),
|
||||
},
|
||||
Priority: 1,
|
||||
ExecutionsID: ws.UUID,
|
||||
ExecDate: date.Start,
|
||||
EndDate: date.End,
|
||||
State: enum.DRAFT,
|
||||
WorkflowID: wf.GetID(),
|
||||
SelectedInstances: ws.SelectedInstances,
|
||||
SelectedPartnerships: ws.SelectedPartnerships,
|
||||
SelectedBuyings: ws.SelectedBuyings,
|
||||
SelectedStrategies: ws.SelectedStrategies,
|
||||
SelectedEmbeddedStorages: ws.SelectedEmbeddedStorages,
|
||||
Priority: 1,
|
||||
ExecutionsID: ws.UUID,
|
||||
ExecDate: date.Start,
|
||||
EndDate: date.End,
|
||||
State: enum.DRAFT,
|
||||
WorkflowID: wf.GetID(),
|
||||
}
|
||||
if ws.BookingMode != booking.PLANNED {
|
||||
obj.Priority = 0
|
||||
|
||||
Reference in New Issue
Block a user