Repository navigation
[feat] Add agent sandbox Postgres sslMode, sslRootCert and extra volumes - #431
cameronattard wants to merge 1 commit into
Conversation
[Medium impact] The changes affect Postgres connections and pod volumes for the agent sandbox controller and proxy. The PR appears safe to merge, with a non-blocking gap in the host-path tests. Findings
Reviews (1) · Last reviewed commit: "[feat] Add agent sandbox Postgres sslMod..." · Reviewed by Greptile |
| for dsn in dsns(out): | ||
| self.assertEqual(dsn, f"postgres://agent@db.example:5432/retool?sslmode=verify-full&sslrootcert={CA}") |
There was a problem hiding this comment.
The host-path tests pass when either or both Deployments lack AGENT_SANDBOX_POSTGRES_URL. dsns() returns only the URLs it finds, so missing entries never reach these assertions. Assert that exactly two URLs were found before checking their values in both host-path tests, as the inherited TLS test already does.
There was a problem hiding this comment.
Fixed in cec20ea: every test that loops over the DSNs (both host-path tests and both inherit-default tests) now asserts exactly two were found first.
The controller and proxy DSN hardcoded sslmode=no-verify when inheriting a backend with SSL, and the pods had no way to mount a CA bundle, so they could not verify the database's certificate. rr.agentSandbox.postgres.sslMode and sslRootCert are appended to the DSN on the host and inherit paths, and rr.agentSandbox.extraVolumes / extraVolumeMounts are added to the controller and proxy pods. With nothing set the rendered DSN is unchanged. Validation rejects unknown modes, paths that aren't URL-safe, and the options combined with a verbatim DSN (url or urlSecretName).
344737e to
cec20ea
Compare
What
Lets the agent sandbox controller and proxy verify the Postgres server certificate.
rr.agentSandbox.postgres.sslModeandrr.agentSandbox.postgres.sslRootCertare appended to the DSN as?sslmode=...&sslrootcert=...when the chart assembles it (thepostgres.hostpath and the default inherit-from-config.postgresqlpath).rr.agentSandbox.extraVolumes/rr.agentSandbox.extraVolumeMountsare added to the controller and proxy pods (not the sandbox Job pods), so a CA bundle can be mounted forsslRootCert.With nothing set, the rendered manifests are unchanged: the inherit path still adds
sslmode=no-verifywhen the backend hasssl_enabled, and the host path still adds nothing.Why
When inheriting a backend with SSL, the chart hardcodes
?sslmode=no-verify, and the controller and proxy have no extra volumes. On a database that requires verified TLS (for example Amazon RDS / Aurora with the RDS CA bundle, where the backend can already verify viaNODE_EXTRA_CA_CERTSandPOSTGRES_SSL_REJECT_UNAUTHORIZED=true), the sandbox components are the only Retool workloads left that can't verify the server. The only workaround today is to hand-build the whole DSN inpostgres.url/urlSecretName, which still leaves no way to mount the CA file.The controller and proxy use node-postgres with pg-connection-string, which reads
sslrootcertas a file path and honourssslmode=verify-full, so no image change is needed.Example:
Validation
sslModemust be one ofdisable,prefer,require,verify-ca,verify-fullorno-verify.sslRootCertmust be an absolute path of[A-Za-z0-9._/-], since it is embedded in the URL.postgres.urlorpostgres.urlSecretNamefails with a message to put the parameters in that DSN, rather than silently ignoring them.Reviewer notes
The backend has no chart-level Postgres CA setting; installs verify TLS with
env(NODE_EXTRA_CA_CERTS,POSTGRES_SSL_REJECT_UNAUTHORIZED) plus the top-levelextraVolumes/extraVolumeMounts. That pattern doesn't reach the sandbox controller and proxy:env,extraVolumesorextraVolumeMounts;sslmode=no-verifyin the DSN turns verification off, so the DSN is the only lever.The alternative is to have the controller and proxy inherit the top-level
env/extraVolumes/extraVolumeMountslike most workloads. That would be more uniform, but it changes the render for every install that already sets them (for example a ReadWriteOnce PVC or a secret that only exists for the backend would land on two more pods). This PR keeps the change opt-in underrr.agentSandbox.sslModeis needed either way. Happy to switch if you'd prefer inheritance.Verified
.github/test_agent_sandbox_postgres_tls.py, wired intoci.yaml, covers:verify-full+sslrootcert;maindiffers only in the chart version label.helm lintandschema/generate.sh --checkpass; the twovalues.yamlfiles are in sync.charts/retool/ci/test-agent-sandbox-postgres-tls-option.yaml, so kubeconform validates the new path (passes locally with kubeconform 0.6.7 against Kubernetes 1.31.1).