mirror of
https://github.com/coder/coder.git
synced 2025-07-03 16:13:58 +00:00
fix: add some missing workspace updates (#7790)
* Standardize on function to get workspace channel name There were two, now there is one. * Add some missing workspace updates There are some failure cases where we do not set the type as a workspace build which causes the workspace update to never be published. * Make build failures warnings Otherwise the associated test fails due to the logger fataling on error messages.
This commit is contained in:
@ -956,7 +956,7 @@ func (api *API) watchWorkspace(rw http.ResponseWriter, r *http.Request) {
|
||||
})
|
||||
}
|
||||
|
||||
cancelWorkspaceSubscribe, err := api.Pubsub.Subscribe(watchWorkspaceChannel(workspace.ID), sendUpdate)
|
||||
cancelWorkspaceSubscribe, err := api.Pubsub.Subscribe(codersdk.WorkspaceNotifyChannel(workspace.ID), sendUpdate)
|
||||
if err != nil {
|
||||
_ = sendEvent(ctx, codersdk.ServerSentEvent{
|
||||
Type: codersdk.ServerSentEventTypeError,
|
||||
@ -1243,12 +1243,8 @@ func validWorkspaceSchedule(s *string) (sql.NullString, error) {
|
||||
}, nil
|
||||
}
|
||||
|
||||
func watchWorkspaceChannel(id uuid.UUID) string {
|
||||
return fmt.Sprintf("workspace:%s", id)
|
||||
}
|
||||
|
||||
func (api *API) publishWorkspaceUpdate(ctx context.Context, workspaceID uuid.UUID) {
|
||||
err := api.Pubsub.Publish(watchWorkspaceChannel(workspaceID), []byte{})
|
||||
err := api.Pubsub.Publish(codersdk.WorkspaceNotifyChannel(workspaceID), []byte{})
|
||||
if err != nil {
|
||||
api.Logger.Warn(ctx, "failed to publish workspace update",
|
||||
slog.F("workspace_id", workspaceID), slog.Error(err))
|
||||
|
Reference in New Issue
Block a user