Skip to content

Conversation

@fscnick
Copy link
Collaborator

@fscnick fscnick commented Oct 30, 2025

Why are these changes needed?

Currently this pr is a draft for demonstrating the design. If it is okay, we could continue to polish it.

The operator query the job info with block operation. It might impact the efficiency of the reconciliation.

In this PR, it introduces the background goroutine to fetch the JobInfo and cache it.

implementation design:

  • When the dashboard client is initializing, it will also initialize the singleton of worker pool and cache storage along with a cache cleanup goroutine.

  • When GetJobInfo is called, it returns the cache if hit. Or, it put a placeholder and add a task to the background goroutine to update the JobInfo periodically.

  • The placeholder will be remove via calling StopJob. it might happen on retrying or deleting the RayJob.

Additionally, this pr takes the feedback in #4043 into account.

Related issue number

Closes #4087

Checks

  • I've made sure the tests are passing.
  • Testing Strategy
    • Unit tests
    • Manual tests
    • This PR is not tested :(

Comment on lines +63 to +65
time.AfterFunc(queryInterval, func() {
w.taskQueue <- task
})
Copy link
Collaborator Author

Choose a reason for hiding this comment

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

This wouldn't block the current goroutine.

Comment on lines +768 to +770
if err := rayDashboardClient.StopJob(ctx, rayJobInstance.Status.JobId); err != nil {
logger.Error(err, "Failed to stop job for RayJob")
}
Copy link
Collaborator Author

Choose a reason for hiding this comment

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

Is it okay to call StopJob to remove the cache placeholder before deleting the RayCluster because the status of retry calls deleteClusterResources?


for i := 0; i < workerSize; i++ {
// TODO: observability for these goroutine
// TODO: should we consider the stop ?
Copy link
Collaborator Author

@fscnick fscnick Oct 30, 2025

Choose a reason for hiding this comment

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

should we consider the stop? The goroutine fetches the JobInfo and keeps the copy of JobInfo in the memory not updating something. Once the program exits, all the copy are gone.

)

type RayDashboardClientInterface interface {
InitClient(client *http.Client, dashboardURL string)
Copy link
Collaborator Author

@fscnick fscnick Oct 30, 2025

Choose a reason for hiding this comment

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

Remove this method from the interface because the different implementation might have different input arguments.

keys := cacheStorage.Keys()
expiredThreshold := time.Now().Add(-cacheExpiry)
for _, key := range keys {
if cached, ok := cacheStorage.Peek(key); ok {
Copy link
Collaborator Author

Choose a reason for hiding this comment

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

Peek wouldn't update the recent-ness of cache.

@Future-Outlier Future-Outlier self-assigned this Oct 31, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

[Feature] RayJob Background Goroutine for getting job info from ray dashboard

2 participants