fix(coderd/database): improve task status in tasks_with_status view (#20683)

This change restructures the `tasks_with_status` view query to:

- Improve debuggability by adding a `status_debug` column to better
understand the outcome
- Reduce clutter from `bool_or`, `bool_and` which are aggregate
functions that did not actually have serve a purpose (each join is 0-1
rows)
- Improve agent lifecycle state coverage, `start_timeout` and
`start_error` were omitted
- These states are easy to trigger even in a perfectly functioning
workspace/task so we now rely on app health to report whether or not
there was an issue
- Mark canceling and canceled workspace build jobs as error state
- Agent stop states were implicitly `unknown`, now there are explicit (I
initially considered `error`, could go either way)
This commit is contained in:
Mathias Fredriksson
2025-11-14 19:52:26 +02:00
committed by GitHub
parent 6067aa3aa1
commit 1483fd11ff
7 changed files with 354 additions and 55 deletions
+9
View File
@@ -106,6 +106,15 @@ sql:
# Workaround for sqlc not interpreting the left join correctly.
- column: "tasks_with_status.workspace_build_number"
go_type: "database/sql.NullInt32"
- column: "tasks_with_status.status"
go_type:
type: "TaskStatus"
- column: "tasks_with_status.workspace_agent_lifecycle_state"
go_type:
type: "NullWorkspaceAgentLifecycleState"
- column: "tasks_with_status.workspace_app_health"
go_type:
type: "NullWorkspaceAppHealth"
rename:
group_member: GroupMemberTable
group_members_expanded: GroupMember