Skip to content

[feat] Add agent sandbox Postgres sslMode, sslRootCert and extra volumes - #431

Open
cameronattard wants to merge 1 commit into
tryretool:mainfrom
cameronattard:feat/agent-sandbox-postgres-tls
Open

cameronattard wants to merge 1 commit into
tryretool:mainfrom
cameronattard:feat/agent-sandbox-postgres-tls

Conversation

@cameronattard

Copy link
Copy Markdown

What

Lets the agent sandbox controller and proxy verify the Postgres server certificate.

  • rr.agentSandbox.postgres.sslMode and rr.agentSandbox.postgres.sslRootCert are appended to the DSN as ?sslmode=...&sslrootcert=... when the chart assembles it (the postgres.host path and the default inherit-from-config.postgresql path).
  • rr.agentSandbox.extraVolumes / rr.agentSandbox.extraVolumeMounts are added to the controller and proxy pods (not the sandbox Job pods), so a CA bundle can be mounted for sslRootCert.

With nothing set, the rendered manifests are unchanged: the inherit path still adds sslmode=no-verify when the backend has ssl_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 via NODE_EXTRA_CA_CERTS and POSTGRES_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 in postgres.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 sslrootcert as a file path and honours sslmode=verify-full, so no image change is needed.

Example:

rr:
  agentSandbox:
    postgres:
      sslMode: verify-full
      sslRootCert: /etc/ssl/rds/global-bundle.pem
    extraVolumes:
      - name: rds-ca
        configMap:
          name: rds-ca
    extraVolumeMounts:
      - name: rds-ca
        mountPath: /etc/ssl/rds
        readOnly: true

Validation

  • sslMode must be one of disable, prefer, require, verify-ca, verify-full or no-verify.
  • sslRootCert must be an absolute path of [A-Za-z0-9._/-], since it is embedded in the URL.
  • Either option combined with postgres.url or postgres.urlSecretName fails 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-level extraVolumes / extraVolumeMounts. That pattern doesn't reach the sandbox controller and proxy:

  • they don't receive the top-level env, extraVolumes or extraVolumeMounts;
  • even with a CA in Node's trust store, sslmode=no-verify in 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 / extraVolumeMounts like 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 under rr.agentSandbox. sslMode is needed either way. Happy to switch if you'd prefer inheritance.

Verified

  • New .github/test_agent_sandbox_postgres_tls.py, wired into ci.yaml, covers:
    • the inherit default with and without SSL;
    • inherit and host paths with verify-full + sslrootcert;
    • the host path default;
    • extra volumes and mounts on both pods;
    • the three validation failures.
  • A default render diffed against main differs only in the chart version label.
  • helm lint and schema/generate.sh --check pass; the two values.yaml files are in sync.
  • New 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).
  • Chart version bump 6.14.2 -> 6.14.3.

@greptile-apps

greptile-apps Bot commented Nov 23, 2026 •

Copy link
Copy Markdown
Contributor

RetriggerView in GreptileConfidence Score: 4/5

[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

  1. P2 Missing URLs still pass ▶

Reviews (1) · Last reviewed commit: "[feat] Add agent sandbox Postgres sslMod..." · Reviewed by Greptile

Comment on lines +92 to +93
for dsn in dsns(out):
self.assertEqual(dsn, f"postgres://agent@db.example:5432/retool?sslmode=verify-full&sslrootcert={CA}")

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

P2 Missing URLs still pass

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.

Copy link
Copy Markdown
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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).
@cameronattard
cameronattard force-pushed the feat/agent-sandbox-postgres-tls branch from 344737e to cec20ea Compare November 23, 2026 03:52
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant