-
Notifications
You must be signed in to change notification settings - Fork 64
feat: added shutdownTime to extensions CRs #124
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
base: main
Are you sure you want to change the base?
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -267,6 +267,7 @@ func (r *SandboxClaimReconciler) createSandbox(ctx context.Context, claim *exten | |
| sandbox.Spec.PodTemplate.Spec.AutomountServiceAccountToken = &automount | ||
| } | ||
|
|
||
| sandbox.Spec.ShutdownTime = claim.Spec.ShutdownTime | ||
| if err := controllerutil.SetControllerReference(claim, sandbox, r.Scheme); err != nil { | ||
| err = fmt.Errorf("failed to set controller reference for sandbox: %w", err) | ||
| logger.Error(err, "Error creating sandbox for claim: %q", claim.Name) | ||
|
|
@@ -315,12 +316,36 @@ func (r *SandboxClaimReconciler) getOrCreateSandbox(ctx context.Context, claim * | |
| } | ||
|
|
||
| if sandbox != nil { | ||
| logger.Info("sandbox already exists, skipping update", "name", sandbox.Name) | ||
| if !r.isControlledByClaim(sandbox, claim) { | ||
| err := fmt.Errorf("sandbox %q is not controlled by claim %q. Please use a different claim name or delete the sandbox manually", sandbox.Name, claim.Name) | ||
| logger.Error(err, "Sandbox controller mismatch") | ||
| return nil, err | ||
| } | ||
|
|
||
| needsUpdate := false | ||
|
|
||
| claimTime := claim.Spec.ShutdownTime | ||
| sandboxTime := sandbox.Spec.ShutdownTime | ||
|
|
||
| if claimTime == nil && sandboxTime != nil { | ||
|
Member
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I'm not sure why we are reconciling the claim time against the live sandbox here. What's the intention here? Claim doesn't support updating sandbox currently.
Contributor
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. So i saw that the |
||
| // Claim wants infinity, Sandbox has a limit -> UPDATE | ||
| needsUpdate = true | ||
| } else if claimTime != nil && sandboxTime == nil { | ||
| // Claim has a limit, Sandbox is infinite -> UPDATE | ||
| needsUpdate = true | ||
| } else if claimTime != nil && sandboxTime != nil && !claimTime.Equal(sandboxTime) { | ||
| // Both have limits, but they are different -> UPDATE | ||
| needsUpdate = true | ||
| } | ||
|
|
||
| if needsUpdate { | ||
| logger.Info("Updating Sandbox ShutdownTime", "old", sandboxTime, "new", claimTime) | ||
| sandbox.Spec.ShutdownTime = claimTime | ||
| if err := r.Update(ctx, sandbox); err != nil { | ||
| return nil, fmt.Errorf("failed to update sandbox shutdownTime: %w", err) | ||
| } | ||
| } | ||
|
|
||
| return sandbox, nil | ||
| } | ||
|
|
||
|
|
||
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.
This behavior is different from what's documented in the API 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.
Ohh true, i forgot to update the API spec comments.