mirror of
https://github.com/coder/coder.git
synced 2026-06-03 13:08:25 +00:00
e4dc2d9418
This PR sets a constraint of 1MB on the provisioner job logs written to the database. This is consistent with the constraint we place on workspace agent logs: https://github.com/coder/coder/blob/4ac6be6d835dc36c242e35a26b584b784040bf28/coderd/database/dump.sql#L2030 It also adds a message printed to the front end about the provisioner log overflow, and updates the message printed to the front end when workspace startup logs exceed the max, as it was causing some customers to think their startup script had failed to run.
38 lines
762 B
SQL
38 lines
762 B
SQL
-- name: GetProvisionerLogsAfterID :many
|
|
SELECT
|
|
*
|
|
FROM
|
|
provisioner_job_logs
|
|
WHERE
|
|
job_id = @job_id
|
|
AND (
|
|
id > @created_after
|
|
) ORDER BY id ASC;
|
|
|
|
-- name: InsertProvisionerJobLogs :many
|
|
INSERT INTO
|
|
provisioner_job_logs
|
|
SELECT
|
|
@job_id :: uuid AS job_id,
|
|
unnest(@created_at :: timestamptz [ ]) AS created_at,
|
|
unnest(@source :: log_source [ ]) AS source,
|
|
unnest(@level :: log_level [ ]) AS LEVEL,
|
|
unnest(@stage :: VARCHAR(128) [ ]) AS stage,
|
|
unnest(@output :: VARCHAR(1024) [ ]) AS output RETURNING *;
|
|
|
|
-- name: UpdateProvisionerJobLogsOverflowed :exec
|
|
UPDATE
|
|
provisioner_jobs
|
|
SET
|
|
logs_overflowed = $2
|
|
WHERE
|
|
id = $1;
|
|
|
|
-- name: UpdateProvisionerJobLogsLength :exec
|
|
UPDATE
|
|
provisioner_jobs
|
|
SET
|
|
logs_length = logs_length + $2
|
|
WHERE
|
|
id = $1;
|