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

Commitb08282a

Browse files
committed
fix: exclude prebuilt workspaces from template-level lifecycle updates
1 parent155c7bb commitb08282a

File tree

3 files changed

+34
-11
lines changed

3 files changed

+34
-11
lines changed

‎coderd/database/queries.sql.go‎

Lines changed: 12 additions & 5 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: 12 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -554,11 +554,15 @@ WHERE
554554

555555
-- name: UpdateWorkspacesTTLByTemplateID :exec
556556
UPDATE
557-
workspaces
557+
workspaces
558558
SET
559-
ttl= $2
559+
ttl= $2
560560
WHERE
561-
template_id= $1;
561+
template_id= $1
562+
-- Prebuilt workspaces (identified by having the prebuilds system user as owner_id)
563+
-- should not have their TTL updated, as they are handled by the prebuilds
564+
-- reconciliation loop.
565+
ANDworkspaces.owner_id!='c42fdf75-3097-471c-8c33-fb52454d81c0'::UUID;
562566

563567
-- name: UpdateWorkspaceLastUsedAt :exec
564568
UPDATE
@@ -805,8 +809,11 @@ SET
805809
dormant_at= CASE WHEN @dormant_at::timestamptz>'0001-01-01 00:00:00+00'::timestamptz THEN @dormant_at::timestamptz ELSE dormant_at END
806810
WHERE
807811
template_id= @template_id
808-
AND
809-
dormant_atIS NOT NULL
812+
AND dormant_atIS NOT NULL
813+
-- Prebuilt workspaces (identified by having the prebuilds system user as owner_id)
814+
-- should not have their dormant or deleting at set, as these are handled by the
815+
-- prebuilds reconciliation loop.
816+
ANDworkspaces.owner_id!='c42fdf75-3097-471c-8c33-fb52454d81c0'::UUID
810817
RETURNING*;
811818

812819
-- name: UpdateTemplateWorkspacesLastUsedAt :exec

‎enterprise/coderd/schedule/template.go‎

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

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

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

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

0 commit comments

Comments
 (0)

[8]ページ先頭

©2009-2025 Movatter.jp