mirror of
https://github.com/coder/coder.git
synced 2026-09-22 05:05:20 +08:00
feat: add workspace restart functionality to API (#25757)
This models restart as durable orchestration of existing stop and start workspace builds instead of adding a new restart transition. Keeping restart as two existing transitions preserves the current build/provisioner model. The child start build is created only after the parent stop build succeeds, rather than being inserted immediately in a pending state. That keeps `workspace_builds` aligned with actual provisioner-ready work and avoids introducing a second pending-build lifecycle that the provisioner and build acquisition paths would need to understand. Refs: https://linear.app/codercom/issue/PLAT-143
This commit is contained in:
+1
-14
@@ -3030,20 +3030,7 @@ func validWorkspaceSchedule(s *string) (sql.NullString, error) {
|
||||
}
|
||||
|
||||
func (api *API) publishWorkspaceUpdate(ctx context.Context, ownerID uuid.UUID, event wspubsub.WorkspaceEvent) {
|
||||
err := event.Validate()
|
||||
if err != nil {
|
||||
api.Logger.Warn(ctx, "invalid workspace update event",
|
||||
slog.F("workspace_id", event.WorkspaceID),
|
||||
slog.F("event_kind", event.Kind), slog.Error(err))
|
||||
return
|
||||
}
|
||||
msg, err := json.Marshal(event)
|
||||
if err != nil {
|
||||
api.Logger.Warn(ctx, "failed to marshal workspace update",
|
||||
slog.F("workspace_id", event.WorkspaceID), slog.Error(err))
|
||||
return
|
||||
}
|
||||
err = api.Pubsub.Publish(wspubsub.WorkspaceEventChannel(ownerID), msg)
|
||||
err := wspubsub.PublishWorkspaceEvent(ctx, api.Pubsub, ownerID, event)
|
||||
if err != nil {
|
||||
api.Logger.Warn(ctx, "failed to publish workspace update",
|
||||
slog.F("workspace_id", event.WorkspaceID), slog.Error(err))
|
||||
|
||||
Reference in New Issue
Block a user