Skip to content
Closed
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
14 changes: 5 additions & 9 deletions SaFE/webhooks/pkg/workload_webhook.go
Original file line number Diff line number Diff line change
Expand Up @@ -265,15 +265,11 @@ func (m *WorkloadMutator) mutatePriority(workload *v1.Workload) {

// mutateResources sets GPU name, shared memory and default ephemeral storage.
func (m *WorkloadMutator) mutateResources(ctx context.Context, workload *v1.Workload, workspace *v1.Workspace) error {
if commonworkload.IsSandBox(workload) {
if len(workload.Spec.Resources) > 0 {
v1.RemoveAnnotation(workload, v1.SandboxTemplateIdAnnotation)
} else {
var err error
workload.Spec.Resources, err = m.getResourceFromSandBoxTemplate(ctx, workload)
if err != nil {
return err
}
if commonworkload.IsSandBox(workload) && len(workload.Spec.Resources) == 0 {
var err error
workload.Spec.Resources, err = m.getResourceFromSandBoxTemplate(ctx, workload)
if err != nil {
return err
Comment on lines +268 to +272
Copy link

Copilot AI Apr 16, 2026

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Behavior change: this no longer removes SandboxTemplateIdAnnotation when a sandbox workload already specifies Spec.Resources. Downstream DispatcherReconciler.updateSandbox applies the sandbox template whenever this annotation is present, so sandboxes with explicit resources can unexpectedly have their podTemplate overridden, and can also fail dispatch if templateId is stale/nonexistent (previously it would have been stripped). Consider restoring the prior logic (strip the annotation when resources are provided) or gate template application/validation on len(Spec.Resources)==0 so templateId remains purely a compatibility shim for resource defaults.

Suggested change
if commonworkload.IsSandBox(workload) && len(workload.Spec.Resources) == 0 {
var err error
workload.Spec.Resources, err = m.getResourceFromSandBoxTemplate(ctx, workload)
if err != nil {
return err
if commonworkload.IsSandBox(workload) {
if len(workload.Spec.Resources) == 0 {
var err error
workload.Spec.Resources, err = m.getResourceFromSandBoxTemplate(ctx, workload)
if err != nil {
return err
}
} else if workload.Annotations != nil {
delete(workload.Annotations, v1.SandboxTemplateIdAnnotation)

Copilot uses AI. Check for mistakes.
}
}

Expand Down
Loading