fix(region): add finish for DependencyTopoGraph (#23707)

This commit is contained in:
cwz_eikoh
2025-11-07 10:20:22 +08:00
committed by GitHub
parent c414ef4eda
commit a82f436d2b
2 changed files with 17 additions and 8 deletions
@@ -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
}