-
Notifications
You must be signed in to change notification settings - Fork 909
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
support job scheduling #898
Conversation
will #899 cover this case? |
I'm not sure. Do you have any ideas? @RainbowMango |
Not sure, let me take a look. |
I wonder how to aggregate status of job. We collect job status in detector before: https://github.com/karmada-io/karmada/blob/master/pkg/detector/aggregate_status.go#L193. We will set |
Hi @mrlihanbo, this is an interesting question. Should we need more adaption? I thought the aggregation does not need any more changes. When we divide replicas, we still mark job completed after all jobs in member clusters succeed right? Could you please give more details? |
Leave a user story here. |
Well, I think the |
Hi, @Garrybest my fault, it seems like we can still mark job completed after all jobs in member clusters succeed. |
Hi, @mrlihanbo. I was just about to reply😄. I found the relevant code here. If |
Hi, @Garrybest. I just wonder if there exists a scenario that |
Got it. I guess this scenario rarely happens. I'd prefer to consider this situation as |
/assign @mrlihanbo |
Generlly looks good. diff --git a/pkg/controllers/binding/common.go b/pkg/controllers/binding/common.go
index 422efde5..21b00e9a 100644
--- a/pkg/controllers/binding/common.go
+++ b/pkg/controllers/binding/common.go
@@ -84,12 +84,13 @@ func ensureWork(c client.Client, workload *unstructured.Unstructured, overrideMa
var jobCompletions []workv1alpha2.TargetCluster
var jobHasCompletions = false
if workload.GetKind() == util.JobKind {
- completions, ok, err := unstructured.NestedInt64(workload.Object, util.SpecField, util.CompletionsField)
+ completions, found, err := unstructured.NestedInt64(workload.Object, util.SpecField, util.CompletionsField)
if err != nil {
return err
}
- if jobHasCompletions = ok; jobHasCompletions {
+ if found {
jobCompletions = util.DivideReplicasByTargetCluster(targetClusters, int32(completions))
+ jobHasCompletions = true
}
}
@@ -125,6 +126,9 @@ func ensureWork(c client.Client, workload *unstructured.Unstructured, overrideMa
clonedWorkload.GetKind(), clonedWorkload.GetNamespace(), clonedWorkload.GetName(), targetCluster.Name, err)
return err
}
+
+ // For a work queue Job that usually leaves .spec.completions unset, in that case, we skip setting this field.
+ // Refer to: https://kubernetes.io/docs/concepts/workloads/controllers/job/#parallel-jobs.
if jobHasCompletions {
err = applyReplicaSchedulingPolicy(clonedWorkload, int64(jobCompletions[i].Replicas), util.CompletionsField)
if err != nil { |
Signed-off-by: Garrybest <[email protected]>
@mrlihanbo Do you have any questions or comments? |
/lgtm |
[APPROVALNOTIFIER] This PR is APPROVED This pull-request has been approved by: RainbowMango 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 |
Signed-off-by: Garrybest [email protected]
What type of PR is this?
/kind feature
What this PR does / why we need it:
Add Job scheduling in scheduler. We divide replicas by
spec.parallelism
. And thespec.completions
could be divided weighted by scheduling result.Which issue(s) this PR fixes:
Fixes #893
Special notes for your reviewer:
Does this PR introduce a user-facing change?: