mirror of
https://github.com/yunionio/cloudpods.git
synced 2026-08-29 03:51:54 +08:00
fix(region): add finish for DependencyTopoGraph (#23707)
This commit is contained in:
@@ -61,6 +61,11 @@ func (t *PodStartContainerInDependencyOrderTask) requestContainersStart(ctx cont
|
||||
return
|
||||
}
|
||||
|
||||
if dep.Finish != nil && *dep.Finish {
|
||||
t.taskComplete(ctx, pod)
|
||||
return
|
||||
}
|
||||
|
||||
fetchById := func(uuid string) models.SContainer {
|
||||
pctr, err := models.GetContainerManager().FetchById(uuid)
|
||||
if err != nil {
|
||||
@@ -70,10 +75,8 @@ func (t *PodStartContainerInDependencyOrderTask) requestContainersStart(ctx cont
|
||||
return *pctr.(*models.SContainer)
|
||||
}
|
||||
currentBatch := dep.GetNextBatch(fetchById)
|
||||
if currentBatch == nil {
|
||||
t.taskComplete(ctx, pod)
|
||||
return
|
||||
}
|
||||
|
||||
// log.Infof("After GetNextBatch, dep.Leafs: %s\n dep: %s", dep.Leafs, jsonutils.Marshal(dep).String())
|
||||
|
||||
// start current Batch
|
||||
t.SetStage("OnContainerStarted", jsonutils.Marshal(dep).(*jsonutils.JSONDict))
|
||||
|
||||
@@ -63,9 +63,10 @@ func TopologicalSortContainers[T any](objs []T, getName GetObjIdName[T], getDepe
|
||||
}
|
||||
|
||||
type DependencyTopoGraph[T any] struct {
|
||||
Graph map[string][]string
|
||||
Degree map[string]int
|
||||
Leafs []string // containers whose in-degree is zero
|
||||
Graph map[string][]string `json:"graph,omitempty"`
|
||||
Degree map[string]int `json:"degree,omitempty"`
|
||||
Leafs []string `json:"leafs"` // containers whose in-degree is zero
|
||||
Finish *bool `json:"finish,omitempty"`
|
||||
}
|
||||
|
||||
func NewDependencyTopoGraph[T any](
|
||||
@@ -129,9 +130,14 @@ func (dep *DependencyTopoGraph[T]) GetNextBatch(fetchById FetchObjById[T]) []T {
|
||||
}
|
||||
}
|
||||
|
||||
// log.Infof("Get next batch: %s", dep.Leafs)
|
||||
// log.Infof("Get next batch:\n Leafs: %s\n nextLeafs: %s", dep.Leafs, nextLeafs)
|
||||
|
||||
dep.Leafs = nextLeafs
|
||||
|
||||
if len(nextLeafs) == 0 {
|
||||
finish := true
|
||||
dep.Finish = &finish
|
||||
}
|
||||
|
||||
return objs
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user