Skip to content

Commit

Permalink
parse job min member info
Browse files Browse the repository at this point in the history
Signed-off-by: lowang_bh <[email protected]>
  • Loading branch information
lowang-bh committed Aug 14, 2023
1 parent 04a3b1b commit fce3a1f
Showing 1 changed file with 13 additions and 6 deletions.
19 changes: 13 additions & 6 deletions pkg/scheduler/api/job_info.go
Original file line number Diff line number Diff line change
Expand Up @@ -383,12 +383,7 @@ func (ji *JobInfo) SetPodGroup(pg *PodGroup) {
ji.RevocableZone = ji.extractRevocableZone(pg)
ji.Budget = ji.extractBudget(pg)

taskMinAvailableTotal := int32(0)
for task, member := range pg.Spec.MinTaskMember {
ji.TaskMinAvailable[TaskID(task)] = member
taskMinAvailableTotal += member
}
ji.TaskMinAvailableTotal = taskMinAvailableTotal
ji.ParseMinMemberInfo(pg)

ji.PodGroup = pg
}
Expand Down Expand Up @@ -475,6 +470,18 @@ func (ji *JobInfo) extractBudget(pg *PodGroup) *DisruptionBudget {
return NewDisruptionBudget("", "")
}

// ParseMinMemberInfo set the information about job's min member
// 1. set number of each role to TaskMinAvailable
// 2. calculate sum of all roles' min members and set to TaskMinAvailableTotal
func (ji *JobInfo) ParseMinMemberInfo(pg *PodGroup) {
taskMinAvailableTotal := int32(0)
for task, member := range pg.Spec.MinTaskMember {
ji.TaskMinAvailable[TaskID(task)] = member
taskMinAvailableTotal += member
}
ji.TaskMinAvailableTotal = taskMinAvailableTotal
}

// GetMinResources return the min resources of podgroup.
func (ji *JobInfo) GetMinResources() *Resource {
if ji.PodGroup.Spec.MinResources == nil {
Expand Down

0 comments on commit fce3a1f

Please sign in to comment.