Skip to content
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

fix: support MxNet single host training when update mxJob status #1644

Merged
merged 1 commit into from
Aug 10, 2022
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
24 changes: 21 additions & 3 deletions pkg/controller.v1/mxnet/mxjob_controller.go
Original file line number Diff line number Diff line change
Expand Up @@ -336,6 +336,9 @@ func (r *MXJobReconciler) UpdateJobStatus(job interface{}, replicas map[commonv1
}
}

//check whether mxnet singleHost training
singleTraining := r.isSingleWorker(replicas)

for rtype, spec := range replicas {
status := jobStatus.ReplicaStatuses[rtype]

Expand All @@ -345,10 +348,10 @@ func (r *MXJobReconciler) UpdateJobStatus(job interface{}, replicas map[commonv1
running := status.Active
failed := status.Failed

r.Log.Info(fmt.Sprintf("MXJob=%s, ReplicaType=%s expected=%d, running=%d, succeeded=%d , failed=%d",
mxjob.Name, rtype, expected, running, succeeded, failed))
r.Log.Info(fmt.Sprintf("MXJob=%s, ReplicaType=%s expected=%d, running=%d, succeeded=%d, failed=%d, singleTraining=%t",
mxjob.Name, rtype, expected, running, succeeded, failed, singleTraining))

if rtype == commonv1.ReplicaType(kubeflowv1.MXJobReplicaTypeScheduler) {
if rtype == commonv1.ReplicaType(kubeflowv1.MXJobReplicaTypeScheduler) || singleTraining {
if running > 0 {
msg := fmt.Sprintf("MXJob %s is running.", mxjob.Name)
err := commonutil.UpdateJobConditions(jobStatus, commonv1.JobRunning, mxJobRunningReason, msg)
Expand Down Expand Up @@ -465,3 +468,18 @@ func (r *MXJobReconciler) onOwnerCreateFunc() func(event.CreateEvent) bool {
return true
}
}

func (r *MXJobReconciler) isSingleWorker(replicas map[commonv1.ReplicaType]*commonv1.ReplicaSpec) bool {
var workerNum, scheNum, svrNum int32 = 0, 0, 0

for rtype, spec := range replicas {
if rtype == commonv1.ReplicaType(kubeflowv1.MXJobReplicaTypeScheduler) {
scheNum += *spec.Replicas
} else if rtype == commonv1.ReplicaType(kubeflowv1.MXJobReplicaTypeServer) {
svrNum += *spec.Replicas
} else if rtype == commonv1.ReplicaType(kubeflowv1.MXJobReplicaTypeWorker) {
workerNum += *spec.Replicas
}
}
return workerNum == 1 && scheNum == 0 && svrNum == 0
}