-
Notifications
You must be signed in to change notification settings - Fork 262
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
Implement GenericJob interface on batchv1.Job (cherry-picked and resolved conflicts) #616
Implement GenericJob interface on batchv1.Job (cherry-picked and resolved conflicts) #616
Conversation
✅ Deploy Preview for kubernetes-sigs-kueue canceled.
|
790b086
to
c5b7344
Compare
@kerthcet we are eager to migrate the existing controllers to the library so that we can integrate Ray as well ray-project/kuberay#926. Is it ok with you if we merge this? |
6926605
to
4fecb4e
Compare
type BatchJob struct { | ||
batchv1.Job | ||
} |
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.
type BatchJob struct { | |
batchv1.Job | |
} | |
type Job batchv1.Job |
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.
I don't think this is equivalent. If I do that the extra interface functions don't compile. The idea of introducing BatchJob is so that we can implement GenericJob.
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 this equivalent? https://go.dev/play/p/N0o1sEDyJVF
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.
Interesting, the example works indeed. However, there seems to be some subtle differences.
One thing is that when doing type BatchJob struct {batchv1.Job }
the BatchJob has the Job
field, so the code didn't compile for me at some places. Also, the BatchJob.Object()
method now doesn't compile, but I guess I can make fixes.
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.
With a type rename, I think this should work, so we don't need more variables.
var job *Job
k8sClient.Get(ctx, job)
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.
type definition will not inherit the methods. In k8sClient.Get(ctx, job)
the job should be a Kubernetes Object. I considered type alias, but seems not the right scenario VS package migration.
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.
/approve
up to you if you want to proceed with this or switch totype Job batch.Job
For now, I prefer the current approach, because it reflects the conceptual distinction between the Job object and the wrapper for the framework purposes. Also, I think we will have time to return to this on the follow up PR(s).
/hold cancel
Yes plz go ahead, I got something I need to take care of. I already talked with @mimowo offline. I will be back until tomorrow or longer. Thanks guys. |
1d4a4ce
to
435284a
Compare
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.
/approve
up to you if you want to proceed with this or switch to type Job batch.Job
[APPROVALNOTIFIER] This PR is APPROVED This pull-request has been approved by: alculquicondor, mimowo The full list of commands accepted by this bot can be found here. The pull request process is described here
Needs approval from an approver in each of these files:
Approvers can indicate their approval by writing |
/lgtm |
return nil | ||
} | ||
|
||
func (b *BatchJob) Finished() (metav1.Condition, bool) { |
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.
One argu about the condition is maybe some other projects do not use v1.Condition
.
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.
I sort of agree, but I think we still have time to return to this decision as we get more info from other frameworks.
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.
If necessary, the controller implementations can translate from one object to the other. In general they should look pretty similar.
type BatchJob struct { | ||
batchv1.Job | ||
} |
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.
type definition will not inherit the methods. In k8sClient.Get(ctx, job)
the job should be a Kubernetes Object. I considered type alias, but seems not the right scenario VS package migration.
} | ||
|
||
// If there is no matching workload and the job is running, suspend it. | ||
if match == nil && !job.IsSuspend() { |
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.
I used to think about move this out of the function then we can handle the Start & Stop operation in the main reconciler loop. But when the matched workload is nil we don't know the injected nodeSelector, so I raised the issue: #518
We can leave it as it-is and discuss about it in that issue.
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.
It seems a separate issue, leaving as-is for now.
/hold |
Original commit by Kante Yin "Implement genericjob interface on batchv1.Job": kubernetes-sigs@ebf2b81 Cherry-picked and conflicts resolution by Michal Wozniak <mw219725@gmail.com> Co-authored-by: Kante Yin <kerthcet@gmail.com> Co-authored-by: Michal Wozniak <mw219725@gmail.com>
# Conflicts: # pkg/controller/workload/job/job_controller.go
435284a
to
33ff294
Compare
Done: https://github.com/kubernetes-sigs/kueue/pull/616/commits. @kerthcet please renew the LGTM. |
/hold cancel |
/lgtm |
What type of PR is this?
/kind feature
What this PR does / why we need it:
This is an addition of the GenericJob interface, in preparation for creating a library for frameworks and to commonize code between Job and MPIJob.
Which issue(s) this PR fixes:
Part of #369
Special notes for your reviewer:
This is a fork of ebf2b81 by @kerthcet aligned with the current master.