Skip to content

Commit

Permalink
fix: global rank error (#25)
Browse files Browse the repository at this point in the history
  • Loading branch information
konnase authored Jul 21, 2022
1 parent 8f46fd5 commit 8b050e7
Showing 1 changed file with 2 additions and 6 deletions.
8 changes: 2 additions & 6 deletions pkg/controllers/dijob.go
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,6 @@ package controllers

import (
"context"
"errors"
"fmt"
"strconv"

Expand Down Expand Up @@ -315,7 +314,7 @@ func (r *DIJobReconciler) createMissedReplicas(ctx context.Context, job *div2alp
}
func (r *DIJobReconciler) findMaxGlobalRank(job *div2alpha1.DIJob, pods []*corev1.Pod) (int, error) {
log := r.ctx.Log.WithName("findMaxGlobalRank").WithValues("job", diutil.NamespacedName(job.Namespace, job.Name))
maxGlobalRank := -1
maxGlobalRank := 0
for _, pod := range pods {
globalRank, err := strconv.Atoi(pod.Annotations[dicommon.AnnotationRank])
if err != nil {
Expand All @@ -327,10 +326,7 @@ func (r *DIJobReconciler) findMaxGlobalRank(job *div2alpha1.DIJob, pods []*corev
maxGlobalRank = globalRank
}
}
if maxGlobalRank < 0 {
err := errors.New("max global rank is a invalid number")
return -1, err
}

return maxGlobalRank, nil
}

Expand Down

0 comments on commit 8b050e7

Please sign in to comment.