diff --git a/pkg/util/status.go b/pkg/util/status.go index c6ed594810..56d9c8d2ce 100644 --- a/pkg/util/status.go +++ b/pkg/util/status.go @@ -39,20 +39,20 @@ func IsFinished(status apiv1.JobStatus) bool { // IsSucceeded checks if the job is succeeded func IsSucceeded(status apiv1.JobStatus) bool { - return hasCondition(status, apiv1.JobSucceeded) + return isStatusConditionTrue(status, apiv1.JobSucceeded) } // IsFailed checks if the job is failed func IsFailed(status apiv1.JobStatus) bool { - return hasCondition(status, apiv1.JobFailed) + return isStatusConditionTrue(status, apiv1.JobFailed) } func IsRunning(status apiv1.JobStatus) bool { - return hasCondition(status, apiv1.JobRunning) + return isStatusConditionTrue(status, apiv1.JobRunning) } func IsSuspended(status apiv1.JobStatus) bool { - return hasCondition(status, apiv1.JobSuspended) + return isStatusConditionTrue(status, apiv1.JobSuspended) } // UpdateJobConditions adds to the jobStatus a new condition if needed, with the conditionType, reason, and message @@ -67,7 +67,7 @@ func UpdateJobConditions( return nil } -func hasCondition(status apiv1.JobStatus, condType apiv1.JobConditionType) bool { +func isStatusConditionTrue(status apiv1.JobStatus, condType apiv1.JobConditionType) bool { for _, condition := range status.Conditions { if condition.Type == condType && condition.Status == v1.ConditionTrue { return true diff --git a/pkg/util/status_test.go b/pkg/util/status_test.go index c1945f5584..aa3bcc69f1 100644 --- a/pkg/util/status_test.go +++ b/pkg/util/status_test.go @@ -3,9 +3,10 @@ package util import ( "testing" - apiv1 "github.com/kubeflow/training-operator/pkg/apis/kubeflow.org/v1" "github.com/stretchr/testify/assert" corev1 "k8s.io/api/core/v1" + + apiv1 "github.com/kubeflow/training-operator/pkg/apis/kubeflow.org/v1" ) func TestIsFinished(t *testing.T) {