Skip to content
This repository has been archived by the owner on Sep 12, 2023. It is now read-only.

Commit

Permalink
fix comment
Browse files Browse the repository at this point in the history
  • Loading branch information
zw0610 committed Feb 3, 2022
1 parent 9569def commit 1aef17b
Show file tree
Hide file tree
Showing 4 changed files with 9 additions and 9 deletions.
2 changes: 1 addition & 1 deletion pkg/controller.v1/common/job.go
Original file line number Diff line number Diff line change
Expand Up @@ -241,7 +241,7 @@ func (jc *JobController) ReconcileJobs(
minResources = jc.calcPGMinResources(minMember, replicas)
}

var pgSpecFill PGFillSpecFunc = nil
var pgSpecFill FillPodGroupSpecFunc = nil
switch jc.Config.GangScheduling {
case GangSchedulerVolcano:
pgSpecFill = func(pg metav1.Object) error {
Expand Down
4 changes: 2 additions & 2 deletions pkg/controller.v1/common/pod.go
Original file line number Diff line number Diff line change
Expand Up @@ -421,7 +421,7 @@ func (jc *JobController) createNewPod(job interface{}, rt string, index int, spe
// 1. if user has specified other scheduler, we report a warning without overriding any fields.
// 2. if no SchedulerName is set for pods, then we set the SchedulerName to "volcano" or "scheduler-plugins-scheduler".
if jc.Config.EnableGangScheduling() {
if isAnotherGangSchedulerSet(replicas, jc.PodGroupControl.GetSchedulerName()) {
if isCustomSchedulerSet(replicas, jc.PodGroupControl.GetSchedulerName()) {
errMsg := "Another scheduler is specified when gang-scheduling is enabled and it will not be overwritten"
logger.Warning(errMsg)
jc.Recorder.Event(runtimeObject, v1.EventTypeWarning, podTemplateSchedulerNameReason, errMsg)
Expand Down Expand Up @@ -456,7 +456,7 @@ func (jc *JobController) createNewPod(job interface{}, rt string, index int, spe
return nil
}

func isAnotherGangSchedulerSet(replicas map[apiv1.ReplicaType]*apiv1.ReplicaSpec, gangSchedulerName string) bool {
func isCustomSchedulerSet(replicas map[apiv1.ReplicaType]*apiv1.ReplicaSpec, gangSchedulerName string) bool {
for _, spec := range replicas {
if spec.Template.Spec.SchedulerName != "" && spec.Template.Spec.SchedulerName != gangSchedulerName {
return true
Expand Down
8 changes: 4 additions & 4 deletions pkg/controller.v1/common/pod_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -67,10 +67,10 @@ func TestSetRestartPolicy(t *testing.T) {
}
}

func TestIsAnotherGangSchedulerSet(t *testing.T) {
func TestIsCustomSchedulerSet(t *testing.T) {
gangSchedulerName := "test-gang-scheduler"
replicaSpecs := map[apiv1.ReplicaType]*apiv1.ReplicaSpec{}
assert.False(t, isAnotherGangSchedulerSet(replicaSpecs, gangSchedulerName))
assert.False(t, isCustomSchedulerSet(replicaSpecs, gangSchedulerName))

replicaSpecs[apiv1.ReplicaType(testjobv1.TestReplicaTypeWorker)] = &apiv1.ReplicaSpec{
Template: v1.PodTemplateSpec{
Expand All @@ -79,7 +79,7 @@ func TestIsAnotherGangSchedulerSet(t *testing.T) {
},
},
}
assert.False(t, isAnotherGangSchedulerSet(replicaSpecs, gangSchedulerName))
assert.False(t, isCustomSchedulerSet(replicaSpecs, gangSchedulerName))

replicaSpecs[apiv1.ReplicaType(testjobv1.TestReplicaTypeWorker)] = &apiv1.ReplicaSpec{
Template: v1.PodTemplateSpec{
Expand All @@ -88,7 +88,7 @@ func TestIsAnotherGangSchedulerSet(t *testing.T) {
},
},
}
assert.True(t, isAnotherGangSchedulerSet(replicaSpecs, gangSchedulerName))
assert.True(t, isCustomSchedulerSet(replicaSpecs, gangSchedulerName))
}

func TestCalculatePodSliceSize(t *testing.T) {
Expand Down
4 changes: 2 additions & 2 deletions pkg/controller.v1/common/scheduling.go
Original file line number Diff line number Diff line change
Expand Up @@ -28,9 +28,9 @@ import (
"k8s.io/apimachinery/pkg/util/intstr"
)

type PGFillSpecFunc func(object metav1.Object) error
type FillPodGroupSpecFunc func(object metav1.Object) error

func (jc *JobController) SyncPodGroup(job metav1.Object, specFunc PGFillSpecFunc) (metav1.Object, error) {
func (jc *JobController) SyncPodGroup(job metav1.Object, specFunc FillPodGroupSpecFunc) (metav1.Object, error) {

pgctl := jc.PodGroupControl
// Check whether podGroup exists or not
Expand Down

0 comments on commit 1aef17b

Please sign in to comment.