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

Commit10fcd6e

Browse files
committed
fix: exclude prebuilt workspaces from template-level lifecycle updates
1 parent92d505c commit10fcd6e

File tree

3 files changed

+29
-6
lines changed

3 files changed

+29
-6
lines changed

‎coderd/database/queries.sql.go‎

Lines changed: 9 additions & 2 deletions
Some generated files are not rendered by default. Learn more aboutcustomizing how changed files appear on GitHub.

‎coderd/database/queries/workspaces.sql‎

Lines changed: 10 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -570,7 +570,11 @@ UPDATE
570570
SET
571571
ttl= $2
572572
WHERE
573-
template_id= $1;
573+
template_id= $1
574+
-- Prebuilt workspaces (identified by having the prebuilds system user as owner_id)
575+
-- should not have their TTL updated, as they are handled by the prebuilds
576+
-- reconciliation loop.
577+
ANDworkspaces.owner_id!='c42fdf75-3097-471c-8c33-fb52454d81c0'::UUID;
574578

575579
-- name: UpdateWorkspaceLastUsedAt :exec
576580
UPDATE
@@ -821,8 +825,11 @@ SET
821825
dormant_at= CASE WHEN @dormant_at::timestamptz>'0001-01-01 00:00:00+00'::timestamptz THEN @dormant_at::timestamptz ELSE dormant_at END
822826
WHERE
823827
template_id= @template_id
824-
AND
825-
dormant_atIS NOT NULL
828+
AND dormant_atIS NOT NULL
829+
-- Prebuilt workspaces (identified by having the prebuilds system user as owner_id)
830+
-- should not have their dormant or deleting at set, as these are handled by the
831+
-- prebuilds reconciliation loop.
832+
ANDworkspaces.owner_id!='c42fdf75-3097-471c-8c33-fb52454d81c0'::UUID
826833
RETURNING*;
827834

828835
-- name: UpdateTemplateWorkspacesLastUsedAt :exec

‎enterprise/coderd/schedule/template.go‎

Lines changed: 10 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -242,6 +242,10 @@ func (s *EnterpriseTemplateScheduleStore) Set(ctx context.Context, db database.S
242242
nextStartAts:= []time.Time{}
243243

244244
for_,workspace:=rangeworkspaces {
245+
// Skip prebuilt workspaces
246+
ifworkspace.IsPrebuild() {
247+
continue
248+
}
245249
nextStartAt:= time.Time{}
246250
ifworkspace.AutostartSchedule.Valid {
247251
next,err:=agpl.NextAllowedAutostart(s.now(),workspace.AutostartSchedule.String,templateSchedule)
@@ -254,7 +258,7 @@ func (s *EnterpriseTemplateScheduleStore) Set(ctx context.Context, db database.S
254258
nextStartAts=append(nextStartAts,nextStartAt)
255259
}
256260

257-
//nolint:gocritic // We need to be able to update information aboutall workspaces.
261+
//nolint:gocritic // We need to be able to update information aboutregular user workspaces.
258262
iferr:=db.BatchUpdateWorkspaceNextStartAt(dbauthz.AsSystemRestricted(ctx), database.BatchUpdateWorkspaceNextStartAtParams{
259263
IDs:workspaceIDs,
260264
NextStartAts:nextStartAts,
@@ -334,6 +338,11 @@ func (s *EnterpriseTemplateScheduleStore) updateWorkspaceBuild(ctx context.Conte
334338
returnxerrors.Errorf("get workspace %q: %w",build.WorkspaceID,err)
335339
}
336340

341+
// Skip lifecycle updates for prebuilt workspaces
342+
ifworkspace.IsPrebuild() {
343+
returnnil
344+
}
345+
337346
job,err:=db.GetProvisionerJobByID(ctx,build.JobID)
338347
iferr!=nil {
339348
returnxerrors.Errorf("get provisioner job %q: %w",build.JobID,err)

0 commit comments

Comments
 (0)

[8]ページ先頭

©2009-2025 Movatter.jp