-
Notifications
You must be signed in to change notification settings - Fork 227
Fix a bug that the PodGroupCtrl can not list priorityclass #561
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Conversation
Signed-off-by: Yuki Iwai <yuki.iwai.tz@gmail.com>
2cce79a
to
a91049d
Compare
Signed-off-by: Yuki Iwai <yuki.iwai.tz@gmail.com>
a91049d
to
37e9eae
Compare
} | ||
minMember := calculateMinAvailable(mpiJob) | ||
var minResources corev1.ResourceList | ||
if origin := s.calculatePGMinResources(minMember, mpiJob); origin != nil { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
beyond the scope of this PR: why is calculatePGMinResources
returning a pointer to ResourceList? ResourceList is already a map, which is already a pointer.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
It's due to historical context... When the v1 API is designed, they designed the MinResources as *corev1.ResourceList
typed.
Honestly, I would change the *corev1.ResourceList
typed to corev1.ResourceList
typed. But we (WG Training) decided to keep using *corev1.ResourceList
because changing the API has a breaking API change.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Sounds good, let's leave it.
cmd/mpi-operator/app/server.go
Outdated
} | ||
var priorityClassInformer schedulinginformers.PriorityClassInformer | ||
if podGroupCtrl != nil { | ||
priorityClassInformer = kubeInformerFactory.Scheduling().V1().PriorityClasses() |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
When using volcano, the MPIJobController doens't need the priorityClassInformer?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yes, the controller doesn't need the priorityClassInformer.
-
volcano
mpi-operator/pkg/controller/podgroup.go
Lines 170 to 175 in 2da8e05
func (v *VolcanoCtrl) calculatePGMinResources(_ *int32, mpiJob *kubeflow.MPIJob) *corev1.ResourceList { if schedPolicy := mpiJob.Spec.RunPolicy.SchedulingPolicy; schedPolicy != nil { return schedPolicy.MinResources } return nil } -
scheduler-plugins
mpi-operator/pkg/controller/podgroup.go
Lines 297 to 315 in 2da8e05
func (s *SchedulerPluginsCtrl) calculatePGMinResources(minMember *int32, mpiJob *kubeflow.MPIJob) *corev1.ResourceList { if schedPolicy := mpiJob.Spec.RunPolicy.SchedulingPolicy; schedPolicy != nil && schedPolicy.MinResources != nil { return schedPolicy.MinResources } if minMember != nil && *minMember == 0 { return nil } var order replicasOrder for rt, replica := range mpiJob.Spec.MPIReplicaSpecs { rp := replicaPriority{ priority: 0, replicaType: rt, ReplicaSpec: *replica, } pcName := replica.Template.Spec.PriorityClassName if len(pcName) != 0 { if priorityClass, err := s.PriorityClassLister.Get(pcName); err != nil { klog.Warningf("Ignore replica %q priority class %q: %v", rt, pcName, err)
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Previously, we tried to implement calculatePGMinResources
similar to the scheduler-plugins to the podGroupCtrl for the volcano.
But, we have given up on doing that because we (@tenzen-y and @alculquicondor) aren't familiar with volcano logic.
mpi-operator/pkg/controller/podgroup.go
Lines 36 to 72 in c8045ae
// newPodGroup creates a new PodGroup for an MPIJob | |
// resource. It also sets the appropriate OwnerReferences on the resource so | |
// handleObject can discover the MPIJob resource that 'owns' it. | |
func (c *MPIJobController) newPodGroup(mpiJob *kubeflow.MPIJob) *volcanov1beta1.PodGroup { | |
minMember := workerReplicas(mpiJob) + 1 | |
queueName := mpiJob.Annotations[volcanov1beta1.QueueNameAnnotationKey] | |
var minResources *corev1.ResourceList | |
if schedulingPolicy := mpiJob.Spec.RunPolicy.SchedulingPolicy; schedulingPolicy != nil { | |
if schedulingPolicy.MinAvailable != nil { | |
minMember = *schedulingPolicy.MinAvailable | |
} | |
if len(schedulingPolicy.Queue) != 0 { | |
queueName = schedulingPolicy.Queue | |
} | |
if schedulingPolicy.MinResources != nil { | |
minResources = schedulingPolicy.MinResources | |
} | |
} | |
if minResources == nil { | |
minResources = c.calcPGMinResources(minMember, mpiJob.Spec.MPIReplicaSpecs) | |
} | |
return &volcanov1beta1.PodGroup{ | |
ObjectMeta: metav1.ObjectMeta{ | |
Name: mpiJob.Name, | |
Namespace: mpiJob.Namespace, | |
OwnerReferences: []metav1.OwnerReference{ | |
*metav1.NewControllerRef(mpiJob, kubeflow.SchemeGroupVersionKind), | |
}, | |
}, | |
Spec: volcanov1beta1.PodGroupSpec{ | |
MinMember: minMember, | |
Queue: queueName, | |
PriorityClassName: calcPriorityClassName(mpiJob.Spec.MPIReplicaSpecs, mpiJob.Spec.RunPolicy.SchedulingPolicy), | |
MinResources: minResources, | |
}, | |
} | |
} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
ref: #535
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thanks for the reference :)
Signed-off-by: Yuki Iwai <yuki.iwai.tz@gmail.com>
@alculquicondor I addressed your suggestions. PTAL. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Uhm... this approach has the downside of putting some dependencies in the mpi_job_controller code, but I think it's better than before.
/lgtm
/approve
[APPROVALNOTIFIER] This PR is APPROVED This pull-request has been approved by: alculquicondor The full list of commands accepted by this bot can be found here. The pull request process is described here
Needs approval from an approver in each of these files:
Approvers can indicate their approval by writing |
Currently, we don't pass a lister for priorityClasses to podGroup for the scheduler-plugins. So the nil pointer error happens when the podGroupCtrl for the scheduler-plugins list priorityClasses in the following:
So, I passed a lister for the priorityClass to podGroupCtrl for the scheduler-plugins.