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 Pytorjob status inaccuracy when task replica scale down #1593

Merged
merged 1 commit into from
Jun 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
7 changes: 4 additions & 3 deletions pkg/controller.v1/pytorch/pytorchjob_controller.go
Original file line number Diff line number Diff line change
Expand Up @@ -355,9 +355,10 @@ func (r *PyTorchJobReconciler) UpdateJobStatus(job interface{},
expected := *(spec.Replicas) - succeeded
running := status.Active
failed := status.Failed
specReplicas := *spec.Replicas

logrus.Infof("PyTorchJob=%s, ReplicaType=%s expected=%d, running=%d, succeeded=%d , failed=%d",
pytorchjob.Name, rtype, expected, running, succeeded, failed)
logrus.Infof("PyTorchJob=%s, ReplicaType=%s expected=%d, running=%d, succeeded=%d, failed=%d, Replicas=%d",
pytorchjob.Name, rtype, expected, running, succeeded, failed, specReplicas)

if ContainsMasterSpec(replicas) {
if rtype == commonv1.ReplicaType(pytorchv1.PyTorchReplicaTypeMaster) {
Expand Down Expand Up @@ -418,7 +419,7 @@ func (r *PyTorchJobReconciler) UpdateJobStatus(job interface{},
}
}

if failed > 0 {
if failed > 0 && (specReplicas > succeeded+running) {
if spec.RestartPolicy != commonv1.RestartPolicyNever {
msg := fmt.Sprintf("PyTorchJob %s is restarting because %d %s replica(s) failed.", pytorchjob.Name, failed, rtype)
r.Recorder.Event(pytorchjob, corev1.EventTypeWarning, commonutil.JobRestartingReason, msg)
Expand Down