Scheduler + Observe
This commit is contained in:
@@ -60,6 +60,10 @@ func CollectBookingResources(wf *workflow.Workflow, selectedInstances workflow.C
|
||||
if inst := r.GetSelectedInstance(idx); inst != nil {
|
||||
return inst.GetID()
|
||||
}
|
||||
case *resources.ServiceResource:
|
||||
if inst := r.GetSelectedInstance(idx); inst != nil {
|
||||
return inst.GetID()
|
||||
}
|
||||
}
|
||||
return ""
|
||||
}
|
||||
@@ -106,6 +110,39 @@ func CollectBookingResources(wf *workflow.Workflow, selectedInstances workflow.C
|
||||
}
|
||||
}
|
||||
|
||||
// HOSTED services: capacity is capped by MaxConcurrent on the LiveService.
|
||||
// The peer to watch is the creator (who operates the service).
|
||||
// DEPLOYMENT services are covered through their linked compute unit.
|
||||
for _, item := range wf.GetGraphItems(wf.Graph.IsService) {
|
||||
_, res := item.GetResource()
|
||||
if res == nil {
|
||||
continue
|
||||
}
|
||||
svc := res.(*resources.ServiceResource)
|
||||
idx := selectedInstances.Get(svc.GetID())
|
||||
inst := svc.GetSelectedInstance(idx)
|
||||
if inst == nil {
|
||||
continue
|
||||
}
|
||||
if inst.(*resources.ServiceInstance).Mode != resources.HOSTED {
|
||||
continue
|
||||
}
|
||||
id := svc.GetID()
|
||||
if seen[id] {
|
||||
continue
|
||||
}
|
||||
pid := resolvePID(svc.GetCreatorID())
|
||||
if pid == "" {
|
||||
continue
|
||||
}
|
||||
seen[id] = true
|
||||
result[pid] = BookingResource{
|
||||
ID: id,
|
||||
PeerPID: pid,
|
||||
InstanceID: resolveInstanceID(res),
|
||||
}
|
||||
}
|
||||
|
||||
return result
|
||||
}
|
||||
|
||||
@@ -147,6 +184,35 @@ func GetWorkflowPeerIDs(wfID string, request *tools.APIRequest) ([]string, error
|
||||
peerIDs = append(peerIDs, id)
|
||||
}
|
||||
}
|
||||
for _, item := range wf.GetGraphItems(wf.Graph.IsService) {
|
||||
_, res := item.GetResource()
|
||||
if res == nil {
|
||||
continue
|
||||
}
|
||||
svc := res.(*resources.ServiceResource)
|
||||
if len(svc.Instances) == 0 || svc.Instances[0].Mode != resources.HOSTED {
|
||||
continue
|
||||
}
|
||||
if id := svc.GetCreatorID(); id != "" && !seen[id] {
|
||||
seen[id] = true
|
||||
peerIDs = append(peerIDs, id)
|
||||
}
|
||||
}
|
||||
for _, item := range wf.GetGraphItems(wf.Graph.IsDynamic) {
|
||||
_, res := item.GetResource()
|
||||
if res == nil {
|
||||
continue
|
||||
}
|
||||
d := res.(*resources.DynamicResource)
|
||||
d.SetAllowedInstances(request)
|
||||
for _, creatorID := range d.PeerIds {
|
||||
if creatorID != "" && !seen[creatorID] {
|
||||
seen[creatorID] = true
|
||||
peerIDs = append(peerIDs, creatorID)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
realPeersID := []string{}
|
||||
access := oclib.NewRequestAdmin(oclib.LibDataEnum(tools.PEER), nil)
|
||||
for _, id := range peerIDs {
|
||||
|
||||
Reference in New Issue
Block a user