-
Notifications
You must be signed in to change notification settings - Fork 351
feat(orchestrator): add sandbox duration histogram #3097
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
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -532,6 +532,8 @@ func (s *Server) Delete(ctxConn context.Context, in *orchestrator.SandboxDeleteR | |
|
|
||
| sbxlogger.E(sbx).Info(ctx, "Killing sandbox", zap.String("kill_reason", killReason)) | ||
|
|
||
| sbx.SetStopReason(sandbox.StopReasonKilled) | ||
|
|
||
| // Check health metrics before stopping the sandbox | ||
| sbx.Checks.Healthcheck(ctx, true) | ||
|
|
||
|
|
@@ -594,6 +596,14 @@ func recordSandboxKill(ctx context.Context, counter metric.Int64Counter, killRea | |
| counter.Add(ctx, 1, metric.WithAttributes(attribute.String("kill_reason", killReason))) | ||
| } | ||
|
|
||
| // recordExecutionDuration records the duration of a single sandbox execution | ||
| func (s *Server) recordExecutionDuration(ctx context.Context, sbx *sandbox.Sandbox, stopReason sandbox.StopReason) { | ||
| startedAt := sbx.GetStartedAt() | ||
|
|
||
| s.sandboxExecutionDuration.Record(ctx, time.Since(startedAt).Milliseconds(), | ||
| metric.WithAttributes(attribute.String("stop_reason", string(stopReason)))) | ||
| } | ||
|
|
||
| func (s *Server) Pause(ctx context.Context, in *orchestrator.SandboxPauseRequest) (*orchestrator.SandboxPauseResponse, error) { | ||
| ctx, childSpan := tracer.Start(ctx, "sandbox-pause") | ||
| defer childSpan.End() | ||
|
|
@@ -637,6 +647,7 @@ func (s *Server) Pause(ctx context.Context, in *orchestrator.SandboxPauseRequest | |
| } | ||
|
|
||
| sbxlogger.E(sbx).Info(ctx, "Pausing sandbox") | ||
| sbx.SetStopReason(sandbox.StopReasonPaused) | ||
|
|
||
|
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. Failed pause labeled as pauseMedium Severity
Reviewed by Cursor Bugbot for commit 0177b3c. Configure here. |
||
| // Stop the old sandbox in background after we're done | ||
| defer s.stopSandboxAsync(context.WithoutCancel(ctx), sbx) | ||
|
|
@@ -737,6 +748,7 @@ func (s *Server) Checkpoint(ctx context.Context, in *orchestrator.SandboxCheckpo | |
| defer s.stopSandboxAsync(context.WithoutCancel(ctx), sbx) | ||
|
|
||
| sbxlogger.E(sbx).Info(ctx, "Checkpointing sandbox") | ||
| sbx.SetStopReason(sandbox.StopReasonCheckpointing) | ||
|
|
||
| // Checkpoint always takes a full memory snapshot; filesystem-only checkpoint | ||
| // (resume-in-place would need to reboot) is not supported yet. | ||
|
|
@@ -821,6 +833,11 @@ func (s *Server) Checkpoint(ctx context.Context, in *orchestrator.SandboxCheckpo | |
| if err != nil { | ||
| telemetry.ReportCriticalError(ctx, "error uploading snapshot for checkpoint", err, telemetry.WithSandboxID(in.GetSandboxId())) | ||
|
|
||
| // Orchestrator-initiated teardown: the snapshot upload failed so the | ||
| // resumed sandbox is unusable and we stop it ourselves. Record the | ||
| // reason so the lifecycle doesn't mislabel this as a crash. | ||
| resumedSbx.SetStopReason(sandbox.StopReasonKilled) | ||
|
|
||
| s.sandboxFactory.Sandboxes.MarkStopping(ctx, resumedSbx.Runtime.SandboxID, resumedSbx.LifecycleID) | ||
| s.stopSandboxAsync(context.WithoutCancel(ctx), resumedSbx) | ||
|
|
||
|
|
@@ -1027,6 +1044,8 @@ func (s *Server) setupSandboxLifecycle(ctx context.Context, sbx *sandbox.Sandbox | |
| sbxlogger.I(sbx).Error(ctx, "failed to wait for sandbox, cleaning up", zap.Error(waitErr)) | ||
| } | ||
|
|
||
| s.recordExecutionDuration(ctx, sbx, sbx.GetStopReason(ctx)) | ||
|
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.
When a sandbox is paused or checkpointed, Useful? React with 👍 / 👎. |
||
|
|
||
| cleanupErr := sbx.Close(ctx) | ||
| if cleanupErr != nil { | ||
| sbxlogger.I(sbx).Error(ctx, "failed to cleanup sandbox, will remove from cache", zap.Error(cleanupErr)) | ||
|
|
||


Uh oh!
There was an error while loading. Please reload this page.