Skip to content

Commit b1d7275

Browse files
fix: detect postgres dbType and make agent upstream optional
- SlowQueriesSection: Accept both 'postgres' and 'postgresql' dbType The API returns dbType as 'postgres' but the code only checked for 'postgresql' - nginx: Use resolver for deepsql-agent upstream Makes hostname resolution happen at request time instead of startup, allowing nginx to start even when deepsql-agent container is down Co-authored-by: Venkat SF <venkatesh.sakamuri@stayflexi.com>
1 parent 75be4ae commit b1d7275

2 files changed

Lines changed: 8 additions & 5 deletions

File tree

‎docker/nginx/default.conf‎

Lines changed: 7 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -107,10 +107,13 @@ server {
107107
auth_request /__agent_auth;
108108
auth_request_set $deepsql_user $upstream_http_x_remote_user;
109109

110-
# Compose service on the internal network. Literal hostname resolves
111-
# via Docker DNS. If the agent container is down this route returns
112-
# 502 and the rest of the UI keeps working.
113-
proxy_pass http://deepsql-agent:8787/;
110+
# Compose service on the internal network. Using a variable in proxy_pass
111+
# forces nginx to resolve the hostname at request time, not at startup.
112+
# This allows nginx to start even if deepsql-agent is down or restarting.
113+
# Docker's embedded DNS (127.0.0.11) handles container name resolution.
114+
resolver 127.0.0.11 valid=10s ipv6=off;
115+
set $agent_upstream http://deepsql-agent:8787;
116+
proxy_pass $agent_upstream/;
114117
proxy_http_version 1.1;
115118
# The agent API CSRF compares Origin host:port to Host. `$host` drops
116119
# the port (localhost vs localhost:3000) and profile/switch returns 403

‎src/components/sections/SlowQueriesSection.jsx‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -45,7 +45,7 @@ export default function SlowQueriesSection() {
4545
const hasLogSource = Boolean(logSourceQ.data?.id)
4646

4747
// PostgreSQL connections can use pg_stat_statements directly without a log source
48-
const isPostgres = selectedConnection?.dbType?.toLowerCase() === 'postgresql'
48+
const isPostgres = ['postgresql', 'postgres'].includes(selectedConnection?.dbType?.toLowerCase())
4949
const canShowPerformance = hasLogSource || isPostgres
5050

5151
// Filter tabs based on available data sources

0 commit comments

Comments
 (0)