Skip to content

rollback code#507

Closed
weilei0120 wants to merge 1 commit intomainfrom
feature/weilei/20260416-3
Closed

rollback code#507
weilei0120 wants to merge 1 commit intomainfrom
feature/weilei/20260416-3

Conversation

@weilei0120
Copy link
Copy Markdown
Collaborator

No description provided.

Copy link
Copy Markdown
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

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

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(...) when Spec.Resources is empty.
  • Removes the previous behavior that stripped SandboxTemplateIdAnnotation when Spec.Resources was already provided.

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

Comment on lines +268 to +272
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
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.
@weilei0120 weilei0120 closed this Apr 23, 2026
@weilei0120 weilei0120 deleted the feature/weilei/20260416-3 branch April 27, 2026 09:25
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants