rollback code#507
Conversation
There was a problem hiding this comment.
Pull request overview
This PR modifies the sandbox resource-mutation behavior in the workload mutating webhook, changing when sandbox resources are derived from a SandboxTemplate.
Changes:
- Simplifies sandbox handling by only calling
getResourceFromSandBoxTemplate(...)whenSpec.Resourcesis empty. - Removes the previous behavior that stripped
SandboxTemplateIdAnnotationwhenSpec.Resourceswas already provided.
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
| 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 |
There was a problem hiding this comment.
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.
| 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) |
No description provided.