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

Do not save logs when RayJob status is missing #155

Merged
merged 1 commit into from
Nov 15, 2023
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
9 changes: 8 additions & 1 deletion tests/integration/ray_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,7 @@ import (
"net/url"
"testing"

"github.com/onsi/gomega"
. "github.com/onsi/gomega"
support "github.com/project-codeflare/codeflare-operator/test/support"
rayv1alpha1 "github.com/ray-project/kuberay/ray-operator/apis/ray/v1alpha1"
Expand Down Expand Up @@ -114,7 +115,13 @@ func TestRayCluster(t *testing.T) {
dashboardHostname := dashboard.Status.Ingress[0].Host
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Maybe an if statement the checks the status would be better than commenting out the code?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thank you @astefanutti for good tip. I've created a function which checks if RayJob status is present first. If yes it saves the logs if not it will skip saving the log.


rayClient := support.NewRayClusterClient(url.URL{Scheme: "http", Host: dashboardHostname})
defer support.WriteRayJobLogs(test, rayClient, rayJob.Namespace, rayJob.Name)
defer func() {
job, err := test.Client().Ray().RayV1alpha1().RayJobs(rayJob.Namespace).Get(test.Ctx(), rayJob.Name, metav1.GetOptions{})
test.Expect(err).NotTo(gomega.HaveOccurred())
if job.Status.JobId != "" {
support.WriteRayJobLogs(test, rayClient, rayJob.Namespace, rayJob.Name)
}
}()

test.T().Logf("Waiting for RayJob %s/%s to complete", rayJob.Namespace, rayJob.Name)
// Will be removed when RHODS-12857 is fixed
Expand Down