-
Notifications
You must be signed in to change notification settings - Fork 251
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
Add PriorityClass in Workload api #104
Add PriorityClass in Workload api #104
Conversation
/assign @ahg-g |
9572a80
to
6730672
Compare
/test pull-kueue-test-integration-main |
1 similar comment
/test pull-kueue-test-integration-main |
func ConstructWorkloadFor(ctx context.Context, client client.Client, | ||
job *batchv1.Job, scheme *runtime.Scheme) (w *kueue.QueuedWorkload, err error) { | ||
var p int32 | ||
pcName := job.Spec.Template.Spec.PriorityClassName |
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.
What will be do for workloads that have multiple pod specs?
Should we do this in the queued_workload controller instead?
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 rarely see people setting different priorities in a single workload. But in this case, we need a fixed treatment and clear understanding for the user: like choosing the highest one as the priority of the workload?
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.
What will be do for workloads that have multiple pod specs?
It is up to the custom workloads to decide from where to set it (e.g., based on the driver).
Should we do this in the queued_workload controller instead?
how? queuedworkload_controller is not aware of the custom workload CRD.
That makes me think, since order is done at the ClusterQueue level and Queue is simply a pointer to it; what if we have the priority on the Queue, and workloads simply inherit it from the Queue they are submitted to, and so users don't need to set it on the custom workload directly and we avoid those issues altogether.
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 do this in the queued_workload controller instead?
how? queuedworkload_controller is not aware of the custom workload CRD.
I'm thinking that workloads should have a priority independent of the pod priority, although it might be confusing. Also that would mean that users have to set an annotation for it in the Job or something like that. Having it in the Queue is certainly a cleaner option.
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 also agree that workloads have a separate priority independent of the pod priority. In fact here it already is kubeflow
https://github.com/kubeflow/common/blob/2b40c8f8991e302920ee5536c0ad49dec6724c66/pkg/apis/common/v1/types.go#L208
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 see. Do you know what they do with it? Perhaps insert it in the pod specs?
6730672
to
e4ca343
Compare
/test pull-kueue-test-integration-main |
e4ca343
to
1d39c30
Compare
/test pull-kueue-test-integration-main |
/test pull-kueue-test-integration-main |
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.
what is populating the PriorityClassName now?
// keywords which indicate the highest priorities with the former being | ||
// the highest priority. Any other name must be defined by creating a | ||
// PriorityClass object with that name. If not specified, the queuedWorkload | ||
// priority will be default or zero if there is no default. |
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.
where is this default defined?
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.
in the constant
DefaultPriority = 0
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.
Since it wouldn't change by external factors, you should just say that the default priority is zero.
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.
btw, I'm referring to If not specified, the queuedWorkload priority will be default
Is this referring to the default priority class defined for the cluster?
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.
Yes. It's the default priority class defined for the cluster. But if there is no default. It will be 0.
Keep the comments as
https://github.com/kubernetes/kubernetes/blob/ca2cd3b18ef145c34311ba7fd9d389fe8233fae8/pkg/apis/core/types.go#L2902
pkg/queue/queue.go
Outdated
heap.Push(&cq.heap, *info) | ||
return true | ||
} | ||
|
||
func (cq *ClusterQueue) PushOrUpdate(w *kueue.QueuedWorkload) { | ||
func (cq *ClusterQueue) PushOrUpdate(w *kueue.QueuedWorkload) bool { | ||
item := cq.heap.items[workload.Key(w)] | ||
info := *workload.NewInfo(w) |
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.
why not calculate the value in NewInfo
?
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 was initially hoping to calculate in NewInfo. But I find WorkloadInfo is a basic data struct which is invoked in other places like cache. It's hard and unclean if I pass the log/ctx/client to everywhere I want to invoke New.
/retest |
6b14068
to
89b35c3
Compare
I am sorry for the back and forth, this plumbing doesn't look "right". I am pretty sure there will be places where we will miss to set I coming back to having the priority int on the QueuedWorkload and having it populated by the job-controller. Thinking more about how to prevent users from circumventing priority classes: users shouldn't be creating QueuedWorkload instances directly, and so they really can't set the QueuedWorkload priority (at least in our MVP). Alex, I am pretty sure this is frustrating to you, sorry about that, I am happy to make the change myself if you don't have the time. |
Shall we only have Priority in QueuedWorkload or both PriorityClass and Priority?
It doesn't matter. It's worth putting in some effort before making the right decision. I will try to finish refactor the code today and tomorrow. |
Both, the job-controller populates it just like we do for pods. Initially I was concerned that there was no path for Admins to block usage of higher priority classes or preventing users from setting directly a high priority on the workload. But that is actually not true because admins could prevent users from creating QW directly and only allow them to create v1.Job. I still think we want to have priority class on the Queue object but we can leave that as a followup.
Thank you, and I am sorry again for the back and forth, but indeed this was an informative exercise, at least for me. |
edacea0
to
9215ca6
Compare
Since this is very similar to my first version of the implementation, so I finish it quickly 😄 pls take a look again. Thanks. @ahg-g |
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.
thanks, good for squash
It would be nice if we can add a scheduler integration test in a separate |
// keywords which indicate the highest priorities with the former being | ||
// the highest priority. Any other name must be defined by creating a | ||
// PriorityClass object with that name. If not specified, the queuedWorkload | ||
// priority will be default or zero if there is no default. |
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.
btw, I'm referring to If not specified, the queuedWorkload priority will be default
Is this referring to the default priority class defined for the cluster?
@@ -35,6 +35,7 @@ import ( | |||
|
|||
kueue "sigs.k8s.io/kueue/api/v1alpha1" | |||
"sigs.k8s.io/kueue/pkg/constants" | |||
utilpriority "sigs.k8s.io/kueue/pkg/util/priority" |
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.
nit: remove the alias. Use just priority
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.
utilpriority
is auto add by auto import
. I suggest keeping as utilpriority
.
pkg/queue/queue_test.go
Outdated
@@ -24,6 +24,10 @@ import ( | |||
kueue "sigs.k8s.io/kueue/api/v1alpha1" | |||
) | |||
|
|||
var ( | |||
lowPriority, highPriority = int32(0), int32(1000) |
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.
make it 2 lines
@@ -83,3 +87,98 @@ func TestFIFOClusterQueue(t *testing.T) { | |||
t.Errorf("Queue is not empty, poped workload %q", got.Obj.Name) | |||
} | |||
} | |||
|
|||
func TestStrictFIFO(t *testing.T) { |
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.
For a follow up, we should find a way to merge the 2 tests #72
pkg/util/priority/priority.go
Outdated
) | ||
|
||
// Priority returns priority of the given workload. | ||
func Priority(w workload.Info) int32 { |
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.
why not make this a method of workload.Info
?
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.
No special reason. Just keep it as k/k.
And I also think it's not suitable as a member function. But I can change the input as kueue.workload
to make it can be used other place in the future.
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.
No special reason. Just keep it as k/k.
And I also think it's not suitable as a member function. But I can change the input as kueue.workload
to make it can be used other place in the future.
@@ -1,3 +1,19 @@ | |||
/* |
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.
Oops, I wonder if we can make a verify step for this.
Signed-off-by: Alex Wang <wangqingcan1990@gmail.com>
9215ca6
to
e2c2e8c
Compare
Added integration test for scheduler and job-controller in the second commit @ahg-g |
e2c2e8c
to
43a56b3
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.
Thanks! this is looking great!
/require-retest |
/retest-required |
Signed-off-by: Alex Wang <wangqingcan1990@gmail.com>
43a56b3
to
39e9333
Compare
Updated base on the review comments. @ahg-g |
/retest-required |
/lgtm |
[APPROVALNOTIFIER] This PR is APPROVED This pull-request has been approved by: ahg-g, denkensk 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 |
What type of PR is this?
/kind feature
What this PR does / why we need it:
Which issue(s) this PR fixes:
The first part of #82