Skip to content

Commit

Permalink
Merge pull request volcano-sh#2802 from lowang-bh/Hotfix
Browse files Browse the repository at this point in the history
Hotfix: keep updating task's min available number same as creating podgroup
  • Loading branch information
volcano-sh-bot authored Aug 8, 2023
2 parents 39c6f02 + c4ab2d2 commit d57f9f3
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 5 deletions.
11 changes: 6 additions & 5 deletions pkg/controllers/job/job_controller_actions.go
Original file line number Diff line number Diff line change
Expand Up @@ -724,20 +724,21 @@ func (cc *jobcontroller) createOrUpdatePodGroup(job *batch.Job) error {
}

for _, task := range job.Spec.Tasks {
if task.MinAvailable == nil {
continue
cnt := task.Replicas
if task.MinAvailable != nil {
cnt = *task.MinAvailable
}

if taskMember, ok := pg.Spec.MinTaskMember[task.Name]; !ok {
pgShouldUpdate = true
pg.Spec.MinTaskMember[task.Name] = *task.MinAvailable
pg.Spec.MinTaskMember[task.Name] = cnt
} else {
if taskMember == *task.MinAvailable {
if taskMember == cnt {
continue
}

pgShouldUpdate = true
pg.Spec.MinTaskMember[task.Name] = *task.MinAvailable
pg.Spec.MinTaskMember[task.Name] = cnt
}
}

Expand Down
1 change: 1 addition & 0 deletions pkg/controllers/job/job_controller_actions_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -384,6 +384,7 @@ func TestSyncJobFunc(t *testing.T) {
testcase.JobInfo.Job.Spec.Plugins = jobPlugins

fakeController.pgInformer.Informer().GetIndexer().Add(testcase.PodGroup)
fakeController.vcClient.SchedulingV1beta1().PodGroups(testcase.PodGroup.Namespace).Create(context.TODO(), testcase.PodGroup, metav1.CreateOptions{})

for _, pod := range testcase.Pods {
_, err := fakeController.kubeClient.CoreV1().Pods(namespace).Create(context.TODO(), pod, metav1.CreateOptions{})
Expand Down

0 comments on commit d57f9f3

Please sign in to comment.