@@ -21,14 +21,15 @@ type jobAllocationMetaData struct {
2121}
2222
2323func (t * topologyPlugin ) subSetNodesFn (
24- job * podgroup_info.PodGroupInfo , subGroupSet * subgroup_info.SubGroupSet , tasks []* pod_info.PodInfo , nodeSet node_info.NodeSet ,
24+ job * podgroup_info.PodGroupInfo , subGroup * subgroup_info.SubGroupInfo , podSets map [string ]* subgroup_info.PodSet ,
25+ tasks []* pod_info.PodInfo , nodeSet node_info.NodeSet ,
2526) ([]node_info.NodeSet , error ) {
26- topologyTree , found := t .getJobTopology (subGroupSet )
27+ topologyTree , found := t .getJobTopology (subGroup )
2728 if ! found {
2829 job .SetJobFitError (
2930 podgroup_info .PodSchedulingErrors ,
3031 fmt .Sprintf ("Matching topology %s does not exist" ,
31- subGroupSet .GetTopologyConstraint ().Topology ),
32+ subGroup .GetTopologyConstraint ().Topology ),
3233 nil )
3334 return []node_info.NodeSet {}, nil
3435 }
@@ -50,7 +51,7 @@ func (t *topologyPlugin) subSetNodesFn(
5051 return []node_info.NodeSet {}, nil
5152 }
5253
53- jobAllocatableDomains , err := t .getJobAllocatableDomains (job , subGroupSet , len (tasks ), topologyTree )
54+ jobAllocatableDomains , err := t .getJobAllocatableDomains (job , subGroup , podSets , len (tasks ), topologyTree )
5455 if err != nil {
5556 return nil , err
5657 }
@@ -67,11 +68,11 @@ func (t *topologyPlugin) subSetNodesFn(
6768 return domainNodeSets , nil
6869}
6970
70- func (t * topologyPlugin ) getJobTopology (subGroupSet * subgroup_info.SubGroupSet ) (* Info , bool ) {
71- if subGroupSet .GetTopologyConstraint () == nil {
71+ func (t * topologyPlugin ) getJobTopology (subGroup * subgroup_info.SubGroupInfo ) (* Info , bool ) {
72+ if subGroup .GetTopologyConstraint () == nil {
7273 return nil , true
7374 }
74- jobTopologyName := subGroupSet .GetTopologyConstraint ().Topology
75+ jobTopologyName := subGroup .GetTopologyConstraint ().Topology
7576 if jobTopologyName == "" {
7677 return nil , true
7778 }
@@ -188,18 +189,19 @@ func calcNextAllocationTestPodResources(previousTestResources, maxPodResources *
188189}
189190
190191func (t * topologyPlugin ) getJobAllocatableDomains (
191- job * podgroup_info.PodGroupInfo , subGroupSet * subgroup_info.SubGroupSet , taskToAllocateCount int , topologyTree * Info ,
192+ job * podgroup_info.PodGroupInfo , subGroup * subgroup_info.SubGroupInfo , podSets map [string ]* subgroup_info.PodSet ,
193+ taskToAllocateCount int , topologyTree * Info ,
192194) ([]* DomainInfo , error ) {
193- relevantLevels , err := t .calculateRelevantDomainLevels (subGroupSet , topologyTree )
195+ relevantLevels , err := t .calculateRelevantDomainLevels (subGroup , topologyTree )
194196 if err != nil {
195197 return nil , err
196198 }
197199
198200 // Validate that the domains do not clash with the chosen domain for active pods of the job
199201 var relevantDomainsByLevel domainsByLevel
200- if hasActiveAllocatedTasks (subGroupSet ) && hasTopologyRequiredConstraint (subGroupSet ) {
201- relevantDomainsByLevel = getRelevantDomainsWithAllocatedPods (subGroupSet , topologyTree ,
202- DomainLevel (subGroupSet .GetTopologyConstraint ().RequiredLevel ))
202+ if hasActiveAllocatedTasks (podSets ) && hasTopologyRequiredConstraint (subGroup ) {
203+ relevantDomainsByLevel = getRelevantDomainsWithAllocatedPods (podSets , topologyTree ,
204+ DomainLevel (subGroup .GetTopologyConstraint ().RequiredLevel ))
203205 } else {
204206 relevantDomainsByLevel = topologyTree .DomainsByLevel
205207 }
@@ -223,8 +225,8 @@ func (t *topologyPlugin) getJobAllocatableDomains(
223225 return domains , nil
224226}
225227
226- func hasActiveAllocatedTasks (subGroupSet * subgroup_info.SubGroupSet ) bool {
227- for _ , podSet := range subGroupSet . GetPodSets () {
228+ func hasActiveAllocatedTasks (podSets map [ string ] * subgroup_info.PodSet ) bool {
229+ for _ , podSet := range podSets {
228230 if podSet .GetNumActiveAllocatedTasks () > 0 {
229231 return true
230232 }
@@ -233,20 +235,20 @@ func hasActiveAllocatedTasks(subGroupSet *subgroup_info.SubGroupSet) bool {
233235}
234236
235237func getRelevantDomainsWithAllocatedPods (
236- subGroupSet * subgroup_info.SubGroupSet , topologyTree * Info , requiredLevel DomainLevel ,
238+ podSets map [ string ] * subgroup_info.PodSet , topologyTree * Info , requiredLevel DomainLevel ,
237239) domainsByLevel {
238240 relevantDomainsByLevel := domainsByLevel {}
239241 for _ , domainAtRequiredLevel := range topologyTree .DomainsByLevel [requiredLevel ] {
240- if ! hasActiveJobPodInDomain (subGroupSet , domainAtRequiredLevel ) {
242+ if ! hasActiveJobPodInDomain (podSets , domainAtRequiredLevel ) {
241243 continue // if the domain at the top level does not have any active pods, then any domains under the subtree cannot satisfy the required constraint for both active and pending pods
242244 }
243245 addSubTreeToDomainMap (domainAtRequiredLevel , relevantDomainsByLevel )
244246 }
245247 return relevantDomainsByLevel
246248}
247249
248- func hasActiveJobPodInDomain (subGroupSet * subgroup_info.SubGroupSet , domain * DomainInfo ) bool {
249- for _ , podSet := range subGroupSet . GetPodSets () {
250+ func hasActiveJobPodInDomain (podSets map [ string ] * subgroup_info.PodSet , domain * DomainInfo ) bool {
251+ for _ , podSet := range podSets {
250252 for _ , pod := range podSet .GetPodInfos () {
251253 if pod_status .IsActiveAllocatedStatus (pod .Status ) {
252254 podInDomain := domain .Nodes [pod .NodeName ] != nil
@@ -269,19 +271,19 @@ func addSubTreeToDomainMap(domain *DomainInfo, domainsMap domainsByLevel) {
269271 domainsMap [domain.Level ][domain.ID ] = domain
270272}
271273
272- func hasTopologyRequiredConstraint (subGroupSet * subgroup_info.SubGroupSet ) bool {
273- return subGroupSet .GetTopologyConstraint ().RequiredLevel != ""
274+ func hasTopologyRequiredConstraint (subGroup * subgroup_info.SubGroupInfo ) bool {
275+ return subGroup .GetTopologyConstraint ().RequiredLevel != ""
274276}
275277
276278func (* topologyPlugin ) calculateRelevantDomainLevels (
277- subGroupSet * subgroup_info.SubGroupSet , topologyTree * Info ,
279+ subGroup * subgroup_info.SubGroupInfo , topologyTree * Info ,
278280) ([]DomainLevel , error ) {
279- topologyConstraint := subGroupSet .GetTopologyConstraint ()
281+ topologyConstraint := subGroup .GetTopologyConstraint ()
280282 requiredPlacement := DomainLevel (topologyConstraint .RequiredLevel )
281283 preferredPlacement := DomainLevel (topologyConstraint .PreferredLevel )
282284 if requiredPlacement == "" && preferredPlacement == "" {
283285 return nil , fmt .Errorf ("no topology constraints were found for subgroup %s, with topology name %s" ,
284- subGroupSet .GetName (), topologyTree .Name )
286+ subGroup .GetName (), topologyTree .Name )
285287 }
286288
287289 foundRequiredLevel := false
0 commit comments