Skip to content

Filter query: has-agent connecting, connected, disconnected, timeout #5145

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

Merged
merged 30 commits into from
Nov 24, 2022
Merged
Show file tree
Hide file tree
Changes from 1 commit
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
Prev Previous commit
Next Next commit
databasefake
  • Loading branch information
mtojek committed Nov 22, 2022
commit 66892d72bc376df82f624b9f76708a4769a4be5b
4 changes: 3 additions & 1 deletion coderd/database/databasefake/databasefake.go
Original file line number Diff line number Diff line change
Expand Up @@ -905,7 +905,9 @@ func (q *fakeQuerier) GetAuthorizedWorkspaces(ctx context.Context, arg database.
case "connecting":
hasAgentMatched = !wa.FirstConnectedAt.Valid
case "disconnected":
hasAgentMatched = wa.DisconnectedAt.Valid && wa.DisconnectedAt.Time.After(wa.LastConnectedAt.Time)
// FIXME agentInactiveDisconnectTimeout = 6
hasAgentMatched = (wa.DisconnectedAt.Valid && wa.DisconnectedAt.Time.After(wa.LastConnectedAt.Time)) ||
(wa.LastConnectedAt.Valid && wa.LastConnectedAt.Time.Add(6*time.Second).Before(database.Now()))
case "timeout":
hasAgentMatched = !wa.FirstConnectedAt.Valid &&
wa.CreatedAt.Add(time.Duration(wa.ConnectionTimeoutSeconds)*time.Second).Before(database.Now())
Expand Down
2 changes: 1 addition & 1 deletion coderd/database/queries.sql.go

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

2 changes: 1 addition & 1 deletion coderd/database/queries/workspaces.sql
Original file line number Diff line number Diff line change
Expand Up @@ -194,7 +194,7 @@ WHERE
latest_build.disconnected_at > latest_build.last_connected_at
) OR (
latest_build.last_connected_at IS NOT NULL AND
latest_build.last_connected_at + 6 * INTERVAL '1 second' < NOW() -- agentInactiveDisconnectTimeout = 6
latest_build.last_connected_at + 6 * INTERVAL '1 second' < NOW() -- FIXME agentInactiveDisconnectTimeout = 6
)
WHEN @has_agent = 'connected' THEN
latest_build.last_connected_at IS NOT NULL
Expand Down