Skip to content

Commit

Permalink
fix: keep updating task's min available number same as creating podgroup
Browse files Browse the repository at this point in the history
fix pg not exist when get by client due to it is not added

Signed-off-by: lowang_bh <lhui_wang@163.com>
  • Loading branch information
lowang-bh committed May 26, 2023
1 parent 7a5d24e commit c4ab2d2
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 @@ -718,20 +718,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 @@ -282,6 +282,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 c4ab2d2

Please sign in to comment.