-
Notifications
You must be signed in to change notification settings - Fork 288
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
Create PodTemplate before ProvisioningRequest #4086
base: main
Are you sure you want to change the base?
Create PodTemplate before ProvisioningRequest #4086
Conversation
Skipping CI for Draft Pull Request. |
[APPROVALNOTIFIER] This PR is NOT APPROVED This pull-request has been approved by: mbobrovskyi The full list of commands accepted by this bot can be found here.
Needs approval from an approver in each of these files:
Approvers can indicate their approval by writing |
✅ Deploy Preview for kubernetes-sigs-kueue canceled.
|
f66cc05
to
3aa0a49
Compare
3aa0a49
to
0c0efc0
Compare
/cc @PBundyra |
0c0efc0
to
08ad38a
Compare
newPt := &corev1.PodTemplate{ | ||
ObjectMeta: metav1.ObjectMeta{ | ||
Name: ptKey.Name, | ||
Namespace: ptKey.Namespace, | ||
Labels: map[string]string{ | ||
constants.ManagedByKueueLabel: "true", | ||
}, | ||
}, | ||
Template: ps.Template, | ||
} | ||
|
||
// apply the admission node selectors to the Template | ||
psi, err := podset.FromAssignment(ctx, c.client, psaMap[psName], podSet.Count) | ||
if err != nil { | ||
return nil, err | ||
} | ||
|
||
err = podset.Merge(&newPt.Template.ObjectMeta, &newPt.Template.Spec, psi) | ||
if err != nil { | ||
return nil, err | ||
} | ||
|
||
// copy limits to requests if needed | ||
workload.UseLimitsAsMissingRequestsInPod(&newPt.Template.Spec) | ||
|
||
if err = c.client.Create(ctx, newPt); err != nil { | ||
msg := fmt.Sprintf("Error creating PodTemplate %q: %v", newPt.Name, err) | ||
ac.Message = api.TruncateConditionMessage(msg) | ||
workload.SetAdmissionCheckState(&wl.Status.AdmissionChecks, *ac, c.clock) | ||
|
||
c.record.Eventf(wl, corev1.EventTypeWarning, "FailedCreate", api.TruncateEventMessage(msg)) | ||
return nil, err | ||
} |
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.
Could we make a separate function for PodTemplate creation?
if err != nil { | ||
// it's a not found, so create it | ||
newPt := &corev1.PodTemplate{ | ||
ObjectMeta: metav1.ObjectMeta{ | ||
Name: ptKey.Name, | ||
Namespace: ptKey.Namespace, | ||
Labels: map[string]string{ | ||
constants.ManagedByKueueLabel: "true", | ||
}, | ||
}, | ||
Template: ps.Template, | ||
} | ||
|
||
// apply the admission node selectors to the Template | ||
psi, err := podset.FromAssignment(ctx, c.client, psaMap[psName], reqPS.Count) | ||
if err != nil { | ||
return err | ||
} | ||
|
||
err = podset.Merge(&newPt.Template.ObjectMeta, &newPt.Template.Spec, psi) | ||
if err != nil { | ||
return err | ||
} | ||
|
||
// copy limits to requests if needed | ||
workload.UseLimitsAsMissingRequestsInPod(&newPt.Template.Spec) |
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 we moved this part to different place, can we name the function accordingly?
@@ -371,7 +421,7 @@ func (c *Controller) syncProvisionRequestsPodTemplates(ctx context.Context, wl * | |||
for i := range request.Spec.PodSets { | |||
reqPS := &request.Spec.PodSets[i] | |||
psName, refFound := podsetRefsMap[reqPS.PodTemplateRef.Name] |
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.
Do we need those check? Is there any risk of race condition? We are already checking that in the syncOwnedProvisionRequest
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 wonder if we need to check if the PodSets are the same in Workload and ProvReq:
https://github.com/kubernetes-sigs/kueue/pull/4086/files#diff-d5b88e9a8af6b97ce61788f1307ec9ba1f4e3581a9c0634a151ce310c9ca3d91R412-R416
Since we set them a few lines above. Could you evaluate if there are any scenarios where such a need indeed occurs?
What type of PR is this?
/kind bug
What this PR does / why we need it:
Create
PodTemplate
beforeProvisioningRequest
.Which issue(s) this PR fixes:
Fixes #3957
Special notes for your reviewer:
Does this PR introduce a user-facing change?