-
Notifications
You must be signed in to change notification settings - Fork 647
[draft] background goroutine get job info #4160
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
base: master
Are you sure you want to change the base?
[draft] background goroutine get job info #4160
Conversation
Signed-off-by: fscnick <[email protected]>
Signed-off-by: fscnick <[email protected]>
| time.AfterFunc(queryInterval, func() { | ||
| w.taskQueue <- task | ||
| }) |
There was a problem hiding this comment.
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.
| if err := rayDashboardClient.StopJob(ctx, rayJobInstance.Status.JobId); err != nil { | ||
| logger.Error(err, "Failed to stop job for RayJob") | ||
| } |
There was a problem hiding this comment.
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 ? |
There was a problem hiding this comment.
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) |
There was a problem hiding this comment.
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 { |
There was a problem hiding this comment.
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.
Signed-off-by: fscnick <[email protected]>
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
JobInfoand 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
GetJobInfois 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