-
Notifications
You must be signed in to change notification settings - Fork 224
fix(analytics): guard long-running sandboxes and set proper report timeout #1686
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 1 commit
034ca51
991f418
a4a8314
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 |
|---|---|---|
|
|
@@ -38,8 +38,12 @@ func (o *Orchestrator) reportLongRunningSandboxes(ctx context.Context) { | |
| case <-ticker.C: | ||
| sandboxes := o.sandboxStore.Items(nil, []sandbox.State{sandbox.StateRunning}) | ||
| longRunningSandboxes := make([]sandbox.Sandbox, 0, len(sandboxes)) | ||
| now := time.Now() | ||
| for _, sandbox := range sandboxes { | ||
| if time.Since(sandbox.StartTime) > oldSandboxThreshold { | ||
| if sandbox.StartTime.IsZero() { | ||
| continue | ||
| } | ||
| if now.Sub(sandbox.StartTime) > oldSandboxThreshold { | ||
|
||
| longRunningSandboxes = append(longRunningSandboxes, sandbox) | ||
| } | ||
| } | ||
|
|
@@ -57,14 +61,14 @@ func sendAnalyticsForLongRunningSandboxes(ctx context.Context, analytics *analyt | |
| return | ||
| } | ||
|
|
||
| childCtx, cancel := context.WithTimeout(ctx, syncAnalyticsTime) | ||
| childCtx, cancel := context.WithTimeout(ctx, reportTimeout) | ||
| defer cancel() | ||
|
|
||
| instanceIds := make([]string, len(instances)) | ||
| executionIds := make([]string, len(instances)) | ||
| for idx, i := range instances { | ||
| instanceIds[idx] = i.SandboxID | ||
| executionIds[idx] = i.ExecutionID | ||
| instanceIds := make([]string, 0, len(instances)) | ||
| executionIds := make([]string, 0, len(instances)) | ||
|
||
| for _, i := range instances { | ||
| instanceIds = append(instanceIds, i.SandboxID) | ||
| executionIds = append(executionIds, i.ExecutionID) | ||
| } | ||
|
|
||
| _, err := analytics.RunningInstances(childCtx, | ||
|
|
||
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 check isn't really needed