Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix: ps cmd should ignore dead runners #1050

Merged
merged 4 commits into from
Mar 12, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 5 additions & 3 deletions backend/controller/sql/queries.sql
Original file line number Diff line number Diff line change
Expand Up @@ -110,7 +110,8 @@ RETURNING deployment_id;
-- name: KillStaleRunners :one
WITH matches AS (
UPDATE runners
SET state = 'dead'
SET state = 'dead',
deployment_id = NULL
WHERE state <> 'dead' AND last_seen < (NOW() AT TIME ZONE 'utc') - sqlc.arg('timeout')::INTERVAL
RETURNING 1)
SELECT COUNT(*)
Expand All @@ -119,7 +120,8 @@ FROM matches;
-- name: DeregisterRunner :one
WITH matches AS (
UPDATE runners
SET state = 'dead'
SET state = 'dead',
deployment_id = NULL
WHERE key = $1
RETURNING 1)
SELECT COUNT(*)
Expand Down Expand Up @@ -160,7 +162,7 @@ SELECT d.min_replicas,
r.endpoint,
r.labels AS runner_labels
FROM deployments d
LEFT JOIN runners r on d.id = r.deployment_id
LEFT JOIN runners r on d.id = r.deployment_id AND r.state != 'dead'
WHERE d.min_replicas > 0
ORDER BY d.name;

Expand Down
8 changes: 5 additions & 3 deletions backend/controller/sql/queries.sql.go

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Loading