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

Commitfef8176

Browse files
committed
chore: only send 1 job event for canceled pending prebuilds
1 parentf161c82 commitfef8176

File tree

1 file changed

+11
-6
lines changed

1 file changed

+11
-6
lines changed

‎enterprise/coderd/prebuilds/reconcile.go‎

Lines changed: 11 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -788,7 +788,8 @@ func (c *StoreReconciler) provisionDelete(ctx context.Context, db database.Store
788788
// Since these jobs were never processed by a provisioner, no Terraform resources were created,
789789
// making it safe to orphan-delete the workspaces (skipping Terraform destroy).
790790
func (c*StoreReconciler)cancelAndOrphanDeletePendingPrebuilds(ctx context.Context,templateID uuid.UUID,templateVersionID uuid.UUID,presetID uuid.UUID)error {
791-
provisionerJobs:=make(map[uuid.UUID]*database.ProvisionerJob)
791+
varcanceledProvisionerJob*database.ProvisionerJob
792+
varcanceledWorkspaceID uuid.UUID
792793
err:=c.store.InTx(func(db database.Store)error {
793794
canceledJobs,err:=db.UpdatePrebuildProvisionerJobWithCancel(
794795
ctx,
@@ -823,8 +824,9 @@ func (c *StoreReconciler) cancelAndOrphanDeletePendingPrebuilds(ctx context.Cont
823824
c.logger.Error(ctx,"failed to orphan delete canceled prebuild",
824825
slog.F("workspace_id",job.WorkspaceID.String()),slog.Error(err))
825826
multiErr.Errors=append(multiErr.Errors,err)
826-
}else {
827-
provisionerJobs[job.WorkspaceID]=provisionerJob
827+
}elseifcanceledProvisionerJob==nil {
828+
canceledProvisionerJob=provisionerJob
829+
canceledWorkspaceID=job.WorkspaceID
828830
}
829831
}
830832

@@ -837,9 +839,12 @@ func (c *StoreReconciler) cancelAndOrphanDeletePendingPrebuilds(ctx context.Cont
837839
returnerr
838840
}
839841

840-
// Publish provisioner job events to notify the acquirer that new jobs were posted
841-
forworkspaceID,job:=rangeprovisionerJobs {
842-
c.publishProvisionerJob(ctx,job,workspaceID)
842+
// Job event notifications contain organization, provisioner type, and tags.
843+
// Since all canceled jobs have the same values, we only send one notification
844+
// for the first successfully canceled job, which is sufficient to trigger the
845+
// provisioner chain that processes all remaining jobs.
846+
ifcanceledProvisionerJob!=nil {
847+
c.publishProvisionerJob(ctx,canceledProvisionerJob,canceledWorkspaceID)
843848
}
844849

845850
returnnil

0 commit comments

Comments
 (0)

[8]ページ先頭

©2009-2025 Movatter.jp