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

fix: complete job and mark workspace as deleted when no provisioners are available#18465

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

Merged
johnstcn merged 9 commits intomainfromcj/delete-orphan-fake-complete-job
Jun 23, 2025
Merged
Show file tree
Hide file tree
Changes from1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
PrevPrevious commit
NextNext commit
check daemon last seen at
  • Loading branch information
@johnstcn
johnstcn committedJun 20, 2025
commitd46f1564eb8146659f5620b08213030ddc188956
13 changes: 11 additions & 2 deletionscoderd/wsbuilder/wsbuilder.go
View file
Open in desktop
Original file line numberDiff line numberDiff line change
Expand Up@@ -472,18 +472,27 @@ func (b *Builder) buildTx(authFunc func(action policy.Action, object rbac.Object
// There are cases where tagged provisioner daemons have been decommissioned
// without deleting the relevant workspaces, and without any provisioners
// available these workspaces cannot be deleted.
if b.state.orphan && len(provisionerDaemons) == 0 {
hasActiveEligibleProvisioner := false
for _, pd := range provisionerDaemons {
age := now.Sub(pd.ProvisionerDaemon.LastSeenAt.Time)
if age <= provisionerdserver.StaleInterval {
hasActiveEligibleProvisioner = true
break
}
}
if b.state.orphan && !hasActiveEligibleProvisioner {
// nolint: gocritic // At this moment, we are pretending to be provisionerd.
if err := store.UpdateProvisionerJobWithCompleteWithStartedAtByID(dbauthz.AsProvisionerd(b.ctx), database.UpdateProvisionerJobWithCompleteWithStartedAtByIDParams{
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others.Learn more.

Can we please log that this has occurred?

Copy link
MemberAuthor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others.Learn more.

Logging in the API handler where we do the auditing.

CompletedAt: sql.NullTime{Valid: true, Time: now},
Error: sql.NullString{Valid: true, String: "No provisioners were available to handle theorphan-deleterequest. The workspacewas marked asdeleted, but no resources were destroyed."},
Error: sql.NullString{Valid: true, String: "No provisioners were available to handle the request. The workspacehas beendeleted. No resources were destroyed."},
ErrorCode: sql.NullString{Valid: false},
ID: provisionerJob.ID,
StartedAt: sql.NullTime{Valid: true, Time: now},
UpdatedAt: now,
}); err != nil {
return BuildError{http.StatusInternalServerError, "mark orphan-delete provisioner job as completed", err}
}
// TODO: audit baggage?

if err := store.UpdateWorkspaceDeletedByID(b.ctx, database.UpdateWorkspaceDeletedByIDParams{
ID: b.workspace.ID,
Expand Down
6 changes: 4 additions & 2 deletionscoderd/wsbuilder/wsbuilder_test.go
View file
Open in desktop
Original file line numberDiff line numberDiff line change
Expand Up@@ -861,8 +861,10 @@ func TestWorkspaceBuildDeleteOrphan(t *testing.T) {
withRichParameters(nil),
withWorkspaceTags(inactiveVersionID, nil),
withProvisionerDaemons([]database.GetEligibleProvisionerDaemonsByProvisionerJobIDsRow{{
JobID: inactiveJobID,
ProvisionerDaemon: database.ProvisionerDaemon{},
JobID: inactiveJobID,
ProvisionerDaemon: database.ProvisionerDaemon{
LastSeenAt: sql.NullTime{Valid: true, Time: dbtime.Now()},
},
}}),

// Outputs
Expand Down

[8]ページ先頭

©2009-2025 Movatter.jp