Movatterモバイル変換


[0]ホーム

URL:


Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

Commitd8843b7

Browse files
committed
fix: prevent activity bump for prebuilt workspaces
1 parentafb54f6 commitd8843b7

File tree

3 files changed

+37
-26
lines changed

3 files changed

+37
-26
lines changed

‎coderd/database/queries.sql.go‎

Lines changed: 5 additions & 1 deletion
Some generated files are not rendered by default. Learn more aboutcustomizing how changed files appear on GitHub.

‎coderd/database/queries/activitybump.sql‎

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -52,7 +52,11 @@ WITH latest AS (
5252
ONworkspaces.id=workspace_builds.workspace_id
5353
JOIN templates
5454
ONtemplates.id=workspaces.template_id
55-
WHEREworkspace_builds.workspace_id= @workspace_id::uuid
55+
WHERE
56+
workspace_builds.workspace_id= @workspace_id::uuid
57+
-- Prebuilt workspaces (identified by having the prebuilds system user as owner_id)
58+
-- are managed by the reconciliation loop and not subject to activity bumping
59+
ANDworkspaces.owner_id!='c42fdf75-3097-471c-8c33-fb52454d81c0'::UUID
5660
ORDER BYworkspace_builds.build_numberDESC
5761
LIMIT1
5862
)

‎coderd/workspacestats/reporter.go‎

Lines changed: 27 additions & 24 deletions
Original file line numberDiff line numberDiff line change
@@ -149,33 +149,36 @@ func (r *Reporter) ReportAgentStats(ctx context.Context, now time.Time, workspac
149149
returnnil
150150
}
151151

152-
// check next autostart
153-
varnextAutostart time.Time
154-
ifworkspace.AutostartSchedule.String!="" {
155-
templateSchedule,err:= (*(r.opts.TemplateScheduleStore.Load())).Get(ctx,r.opts.Database,workspace.TemplateID)
156-
// If the template schedule fails to load, just default to bumping
157-
// without the next transition and log it.
158-
switch {
159-
caseerr==nil:
160-
next,allowed:=schedule.NextAutostart(now,workspace.AutostartSchedule.String,templateSchedule)
161-
ifallowed {
162-
nextAutostart=next
152+
// Prebuilds are not subject to activity-based deadline bumps
153+
if!workspace.IsPrebuild() {
154+
// check next autostart
155+
varnextAutostart time.Time
156+
ifworkspace.AutostartSchedule.String!="" {
157+
templateSchedule,err:= (*(r.opts.TemplateScheduleStore.Load())).Get(ctx,r.opts.Database,workspace.TemplateID)
158+
// If the template schedule fails to load, just default to bumping
159+
// without the next transition and log it.
160+
switch {
161+
caseerr==nil:
162+
next,allowed:=schedule.NextAutostart(now,workspace.AutostartSchedule.String,templateSchedule)
163+
ifallowed {
164+
nextAutostart=next
165+
}
166+
casedatabase.IsQueryCanceledError(err):
167+
r.opts.Logger.Debug(ctx,"query canceled while loading template schedule",
168+
slog.F("workspace_id",workspace.ID),
169+
slog.F("template_id",workspace.TemplateID))
170+
default:
171+
r.opts.Logger.Error(ctx,"failed to load template schedule bumping activity, defaulting to bumping by 60min",
172+
slog.F("workspace_id",workspace.ID),
173+
slog.F("template_id",workspace.TemplateID),
174+
slog.Error(err),
175+
)
163176
}
164-
casedatabase.IsQueryCanceledError(err):
165-
r.opts.Logger.Debug(ctx,"query canceled while loading template schedule",
166-
slog.F("workspace_id",workspace.ID),
167-
slog.F("template_id",workspace.TemplateID))
168-
default:
169-
r.opts.Logger.Error(ctx,"failed to load template schedule bumping activity, defaulting to bumping by 60min",
170-
slog.F("workspace_id",workspace.ID),
171-
slog.F("template_id",workspace.TemplateID),
172-
slog.Error(err),
173-
)
174177
}
175-
}
176178

177-
// bump workspace activity
178-
ActivityBumpWorkspace(ctx,r.opts.Logger.Named("activity_bump"),r.opts.Database,workspace.ID,nextAutostart)
179+
// bump workspace activity
180+
ActivityBumpWorkspace(ctx,r.opts.Logger.Named("activity_bump"),r.opts.Database,workspace.ID,nextAutostart)
181+
}
179182

180183
// bump workspace last_used_at
181184
r.opts.UsageTracker.Add(workspace.ID)

0 commit comments

Comments
 (0)

[8]ページ先頭

©2009-2025 Movatter.jp