- Notifications
You must be signed in to change notification settings - Fork1k
fix: prevent activity bump for prebuilt workspaces#19263
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 ourterms of service andprivacy statement. We’ll occasionally send you account related emails.
Already on GitHub?Sign in to your account
Uh oh!
There was an error while loading.Please reload this page.
Changes fromall commits
d8843b7
188b303
556d80d
bfb07ff
b21d13f
7e24b85
107ed41
c07ad55
d8bd099
File filter
Filter by extension
Conversations
Uh oh!
There was an error while loading.Please reload this page.
Jump to
Uh oh!
There was an error while loading.Please reload this page.
Diff view
Diff view
There are no files selected for viewing
Some generated files are not rendered by default. Learn more abouthow customized files appear on GitHub.
Uh oh!
There was an error while loading.Please reload this page.
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -149,33 +149,36 @@ func (r *Reporter) ReportAgentStats(ctx context.Context, now time.Time, workspac | ||
return nil | ||
} | ||
// Prebuilds are not subject to activity-based deadline bumps | ||
if !workspace.IsPrebuild() { | ||
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. suggestion: invert the logic and continue / return early ContributorAuthor
| ||
// check next autostart | ||
var nextAutostart time.Time | ||
if workspace.AutostartSchedule.String != "" { | ||
templateSchedule, err := (*(r.opts.TemplateScheduleStore.Load())).Get(ctx, r.opts.Database, workspace.TemplateID) | ||
// If the template schedule fails to load, just default to bumping | ||
// without the next transition and log it. | ||
switch { | ||
case err == nil: | ||
next, allowed := schedule.NextAutostart(now, workspace.AutostartSchedule.String, templateSchedule) | ||
if allowed { | ||
nextAutostart = next | ||
} | ||
case database.IsQueryCanceledError(err): | ||
r.opts.Logger.Debug(ctx, "query canceled while loading template schedule", | ||
slog.F("workspace_id", workspace.ID), | ||
slog.F("template_id", workspace.TemplateID)) | ||
default: | ||
r.opts.Logger.Error(ctx, "failed to load template schedule bumping activity, defaulting to bumping by 60min", | ||
slog.F("workspace_id", workspace.ID), | ||
slog.F("template_id", workspace.TemplateID), | ||
slog.Error(err), | ||
) | ||
} | ||
} | ||
// bump workspace activity | ||
ActivityBumpWorkspace(ctx, r.opts.Logger.Named("activity_bump"), r.opts.Database, workspace.ID, nextAutostart) | ||
} | ||
// bump workspace last_used_at | ||
r.opts.UsageTracker.Add(workspace.ID) | ||
Uh oh!
There was an error while loading.Please reload this page.