mirror of
https://github.com/coder/coder.git
synced 2026-09-24 15:04:27 +08:00
feat: purge old provisioner daemons (#10949)
This commit is contained in:
@@ -11,7 +11,18 @@ INSERT INTO
|
||||
created_at,
|
||||
"name",
|
||||
provisioners,
|
||||
tags
|
||||
tags,
|
||||
updated_at
|
||||
)
|
||||
VALUES
|
||||
($1, $2, $3, $4, $5) RETURNING *;
|
||||
($1, $2, $3, $4, $5, $6) RETURNING *;
|
||||
|
||||
-- name: DeleteOldProvisionerDaemons :exec
|
||||
-- Delete provisioner daemons that have been created at least a week ago
|
||||
-- and have not connected to coderd since a week.
|
||||
-- A provisioner daemon with "zeroed" updated_at column indicates possible
|
||||
-- connectivity issues (no provisioner daemon activity since registration).
|
||||
DELETE FROM provisioner_daemons WHERE (
|
||||
(created_at < (NOW() - INTERVAL '7 days') AND updated_at IS NULL) OR
|
||||
(updated_at IS NOT NULL AND updated_at < (NOW() - INTERVAL '7 days'))
|
||||
);
|
||||
|
||||
Reference in New Issue
Block a user