- Notifications
You must be signed in to change notification settings - Fork939
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
Changes from1 commit
9d3ea6f
d46f156
dba9fce
f312292
2eea932
459ce5c
92a4b99
5a896ed
cb2b000
File filter
Filter by extension
Conversations
Uh oh!
There was an error while loading.Please reload this page.
Jump to
Uh oh!
There was an error while loading.Please reload this page.
Diff view
Diff view
- Loading branch information
Uh oh!
There was an error while loading.Please reload this page.
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -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. | ||
hasActiveEligibleProvisioner := false | ||
dannykopping marked this conversation as resolved. Show resolvedHide resolvedUh oh!There was an error while loading.Please reload this page. | ||
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{ | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others.Learn more. Can we please log that this has occurred? There was a problem hiding this comment. Choose a reason for hiding this commentThe 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 the request. The workspacehas beendeleted. No resources were destroyed."}, | ||
johnstcn marked this conversation as resolved. Show resolvedHide resolvedUh oh!There was an error while loading.Please reload this page. | ||
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, | ||