fix(rr): inherit backend SSL for agent sandbox postgres (sslmode=no-verify)#334
Conversation
|
| Filename | Overview |
|---|---|
| charts/retool/templates/_helpers.tpl | Appends ?sslmode=no-verify to the inherited AGENT_SANDBOX_POSTGRES_URL when ssl_enabled is true; logic is correct, scoped to the inherit branch only, and doesn't affect other DSN construction paths. |
| charts/retool/ci/test-agent-sandbox-inherit-ssl-option.yaml | New CI fixture covering the external-SSL inherit path (postgresql.enabled: false + ssl_enabled: true); correctly exercises the fixed code path that no prior fixture reached. |
| charts/retool/Chart.yaml | Patch version bump 6.11.3 → 6.11.4 to reflect the bug fix. |
Flowchart
%%{init: {'theme': 'neutral'}}%%
flowchart TD
A[postgresUrlEnv helper] --> B{pg.url set?}
B -- yes --> C[Use literal URL directly]
B -- no --> D{pg.host set?}
D -- yes --> E[Build DSN from host fields\nno SSL suffix]
D -- no --> F{pg.urlSecretName set?}
F -- yes --> G[Pull DSN from Kubernetes Secret]
F -- no --> H[Inherit backend connection]
H --> I{ssl_enabled == true?}
I -- yes --> J[sslSuffix = sslmode=no-verify]
I -- no --> K[sslSuffix = empty]
J --> L[Append SSL suffix to assembled DSN]
K --> M[Assembled DSN without SSL suffix]
Reviews (2): Last reviewed commit: "fix(rr): inherit backend SSL for agent s..." | Re-trigger Greptile
| {{- $sslSuffix := ternary "?sslmode=no-verify" "" (eq (include "retool.postgresql.ssl_enabled" . | trimAll "\"") "true") }} | ||
| - name: AGENT_SANDBOX_POSTGRES_URL | ||
| value: {{ printf "postgres://%s@%s:%s/%s" (include "retool.postgresql.user" . | trimAll "\"") (include "retool.postgresql.host" . | trimAll "\"") (include "retool.postgresql.port" . | trimAll "\"" | default "5432") (include "retool.postgresql.database" . | trimAll "\"") | quote }} | ||
| value: {{ printf "postgres://%s@%s:%s/%s%s" (include "retool.postgresql.user" . | trimAll "\"") (include "retool.postgresql.host" . | trimAll "\"") (include "retool.postgresql.port" . | trimAll "\"" | default "5432") (include "retool.postgresql.database" . | trimAll "\"") $sslSuffix | quote }} |
There was a problem hiding this comment.
No CI fixture for the fixed scenario
The new code path — postgresql.enabled: false + config.postgresql.ssl_enabled: true + inherited agent-sandbox postgres — is not exercised by any ci/ YAML. All existing fixtures that hit the else (inherit) branch use postgresql.enabled: true / ssl_enabled: false, so $sslSuffix is always "" in CI. If someone later changes retool.postgresql.ssl_enabled or the ternary logic, CI won't catch a regression in the external-SSL path. Adding a companion to test-agent-sandbox-inherit-postgres-option.yaml with postgresql.enabled: false, config.postgresql.host/ssl_enabled: true, and the required sandbox JWT keys would lock in the fix.
…erify) when agentSandbox.postgres inherits the backend connection (config.postgresql), the assembled AGENT_SANDBOX_POSTGRES_URL carried no sslmode, so the controller/proxy connected without TLS. an SSL-required RDS then rejects it: 'no pg_hba.conf entry for host ... no encryption'. append ?sslmode=no-verify to the inherited DSN when the backend uses SSL (retool.postgresql.ssl_enabled), mirroring the backend's connectionStringUtil. - ci: add test-agent-sandbox-inherit-ssl-option.yaml exercising postgresql.enabled=false + config.postgresql.ssl_enabled=true (the external-SSL inherit path; existing inherit fixture uses the subchart with SSL off, so the suffix was never covered) - bump chart 6.11.3 -> 6.11.4
258dac9 to
55fd90a
Compare
lukefoster11
left a comment
There was a problem hiding this comment.
"%s %s %s %s %s" ("this") ("looks") ("good") ("to") ("me")
what
When
rr.agentSandbox.postgresis left to inherit the backend connection (config.postgresql), the chart assembledAGENT_SANDBOX_POSTGRES_URLwith nosslmode. The agent-sandbox controller/proxy connect via Knex/pg, which only does TLS if the connection string says so — so an SSL-required RDS rejects them:The backend connects to the same DB fine because it applies SSL (
common/resources/connectionStringUtil.ts→sslmode=no-verify); the inherited sandbox DSN didn't carry it.fix
Append
?sslmode=no-verifyto the inherited DSN when the backend uses SSL (retool.postgresql.ssl_enabledis true), mirroring the backend. No effect when SSL is off (e.g. the in-cluster postgresql subchart). The explicitpostgres.url/urlSecretNamepaths are unchanged — operators putsslmodein those themselves.testing
helm template: external pg +ssl_enabled: true→…/hammerhead_admin_prod?sslmode=no-verify; in-cluster subchart → nosslmode. Allci/fixtures render;helm lintclean.ci/test-agent-sandbox-inherit-ssl-option.yamlexercises the external-SSL inherit path (postgresql.enabled: false+config.postgresql.ssl_enabled: true), which no existing fixture covered — locks in thesslmodesuffix against future regressions.🤖 Generated with Claude Code