-
Notifications
You must be signed in to change notification settings - Fork 44
fix: fast-fail session creation on terminal sandbox failure #273
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 2 commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -133,7 +133,7 @@ | |
| response, err := s.createSandbox(c.Request.Context(), dynamicClient, sandbox, sandboxClaim, sandboxEntry, resultChan) | ||
| if err != nil { | ||
| klog.Errorf("create sandbox failed %s/%s: %v", sandbox.Namespace, sandbox.Name, err) | ||
| respondError(c, http.StatusInternalServerError, "internal server error") | ||
| respondError(c, http.StatusInternalServerError, err.Error()) | ||
| return | ||
| } | ||
|
|
||
|
|
@@ -141,7 +141,7 @@ | |
| } | ||
|
|
||
| // createSandbox performs sandbox creation and returns the response payload or an error with an HTTP status code. | ||
| func (s *Server) createSandbox(ctx context.Context, dynamicClient dynamic.Interface, sandbox *sandboxv1alpha1.Sandbox, sandboxClaim *extensionsv1alpha1.SandboxClaim, sandboxEntry *sandboxEntry, resultChan <-chan SandboxStatusUpdate) (*types.CreateSandboxResponse, error) { | ||
| // Store placeholder before creating, make sandbox/sandboxClaim GarbageCollection possible | ||
| sandboxStorePlaceHolder := buildSandboxPlaceHolder(sandbox, sandboxEntry) | ||
| if err := s.storeClient.StoreSandbox(ctx, sandboxStorePlaceHolder); err != nil { | ||
|
|
@@ -197,12 +197,25 @@ | |
| sandboxRollbackFunc() | ||
| }() | ||
|
|
||
| // Use NewTimer so we can stop it explicitly when another branch wins, | ||
| // preventing the runtime from retaining the timer until it fires. | ||
| timer := time.NewTimer(2 * time.Minute) // consistent with router settings | ||
Aman-Cool marked this conversation as resolved.
Show resolved
Hide resolved
|
||
|
|
||
| var createdSandbox *sandboxv1alpha1.Sandbox | ||
| select { | ||
| case result := <-resultChan: | ||
| timer.Stop() | ||
Aman-Cool marked this conversation as resolved.
Show resolved
Hide resolved
|
||
| if result.Err != nil { | ||
| klog.Warningf("sandbox %s/%s failed: %v", sandbox.Namespace, sandbox.Name, result.Err) | ||
| return nil, result.Err | ||
| } | ||
|
Comment on lines
+219
to
+222
Contributor
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. The error returned here contains the descriptive failure reason (e.g., |
||
| createdSandbox = result.Sandbox | ||
| klog.V(2).Infof("sandbox %s/%s running", createdSandbox.Namespace, createdSandbox.Name) | ||
| case <-time.After(2 * time.Minute): // consistent with router settings | ||
| case <-ctx.Done(): | ||
| timer.Stop() | ||
| klog.Warningf("sandbox %s/%s wait canceled: %v", sandbox.Namespace, sandbox.Name, ctx.Err()) | ||
| return nil, fmt.Errorf("sandbox creation canceled: %w", ctx.Err()) | ||
Aman-Cool marked this conversation as resolved.
Outdated
Show resolved
Hide resolved
|
||
| case <-timer.C: | ||
Aman-Cool marked this conversation as resolved.
Show resolved
Hide resolved
|
||
| klog.Warningf("sandbox %s/%s create timed out", sandbox.Namespace, sandbox.Name) | ||
| return nil, fmt.Errorf("sandbox creation timed out") | ||
Aman-Cool marked this conversation as resolved.
Show resolved
Hide resolved
|
||
| } | ||
|
|
||
Uh oh!
There was an error while loading. Please reload this page.