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

Reuse the core kubernetes API reason for the BackoffLimitExceeded #667

Merged
merged 1 commit into from
Oct 16, 2024
Merged
Show file tree
Hide file tree
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
6 changes: 1 addition & 5 deletions pkg/controller/mpi_job_controller.go
Original file line number Diff line number Diff line change
Expand Up @@ -111,10 +111,6 @@
// From: k8s.io/kubernetes/pkg/apis/core/validation/events.go
eventMessageLimit = 1024

// jobBackoffLimitExceededReason is the reason that the k8s job controller
// uses when the backoff limit is exceeded.
jobBackoffLimitExceededReason = "BackoffLimitExceeded"

openMPISlotsEnv = "OMPI_MCA_orte_set_default_slots"
intelMPISlotsEnv = "I_MPI_PERHOST"
)
Expand Down Expand Up @@ -733,7 +729,7 @@
if !metav1.IsControlledBy(launcher, mpiJob) {
msg := fmt.Sprintf(MessageResourceExists, launcher.Name, launcher.Kind)
c.recorder.Event(mpiJob, corev1.EventTypeWarning, ErrResourceExists, msg)
return launcher, fmt.Errorf(msg)

Check failure on line 732 in pkg/controller/mpi_job_controller.go

View workflow job for this annotation

GitHub Actions / CodeQL-Build

printf: non-constant format string in call to fmt.Errorf (govet)
}

return launcher, nil
Expand All @@ -758,7 +754,7 @@
if !metav1.IsControlledBy(podGroup, mpiJob) {
msg := fmt.Sprintf(MessageResourceExists, podGroup.GetName(), "PodGroup")
c.recorder.Event(mpiJob, corev1.EventTypeWarning, ErrResourceExists, msg)
return nil, fmt.Errorf(msg)

Check failure on line 757 in pkg/controller/mpi_job_controller.go

View workflow job for this annotation

GitHub Actions / CodeQL-Build

printf: non-constant format string in call to fmt.Errorf (govet)
}

if !c.PodGroupCtrl.pgSpecsAreEqual(podGroup, newPodGroup) {
Expand All @@ -782,7 +778,7 @@
if !metav1.IsControlledBy(podGroup, mpiJob) {
msg := fmt.Sprintf(MessageResourceExists, podGroup.GetName(), "PodGroup")
c.recorder.Event(mpiJob, corev1.EventTypeWarning, ErrResourceExists, msg)
return fmt.Errorf(msg)

Check failure on line 781 in pkg/controller/mpi_job_controller.go

View workflow job for this annotation

GitHub Actions / CodeQL-Build

printf: non-constant format string in call to fmt.Errorf (govet)
}

// If the PodGroup exist, we'll delete it.
Expand Down Expand Up @@ -1149,7 +1145,7 @@
if msg == "" {
msg = fmt.Sprintf("MPIJob %s/%s has failed", mpiJob.Namespace, mpiJob.Name)
}
if reason == jobBackoffLimitExceededReason {
if reason == batchv1.JobReasonBackoffLimitExceeded {
// Concatenate the reason and message from the last failed Pod.
var lastFailedPod *corev1.Pod
for _, p := range launcherPods {
Expand Down
4 changes: 2 additions & 2 deletions pkg/controller/mpi_job_controller_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -635,7 +635,7 @@ func TestLauncherFailed(t *testing.T) {
launcher.Status.Conditions = append(launcher.Status.Conditions, batchv1.JobCondition{
Type: batchv1.JobFailed,
Status: corev1.ConditionTrue,
Reason: jobBackoffLimitExceededReason,
Reason: batchv1.JobReasonBackoffLimitExceeded,
Message: "Job has reached the specified backoff limit",
})
launcher.Status.Failed = 2
Expand Down Expand Up @@ -668,7 +668,7 @@ func TestLauncherFailed(t *testing.T) {
msg := fmt.Sprintf("MPIJob %s/%s is created.", mpiJob.Namespace, mpiJob.Name)
updateMPIJobConditions(mpiJobCopy, kubeflow.JobCreated, corev1.ConditionTrue, mpiJobCreatedReason, msg)
msg = "Job has reached the specified backoff limit: second message"
updateMPIJobConditions(mpiJobCopy, kubeflow.JobFailed, corev1.ConditionTrue, jobBackoffLimitExceededReason+"/FailedReason2", msg)
updateMPIJobConditions(mpiJobCopy, kubeflow.JobFailed, corev1.ConditionTrue, batchv1.JobReasonBackoffLimitExceeded+"/FailedReason2", msg)

f.expectUpdateMPIJobStatusAction(mpiJobCopy)

Expand Down
Loading