-
Notifications
You must be signed in to change notification settings - Fork 76
agent-sandbox: validate required secrets + existing-secret DSN ref #308
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
base: r2-cleanup
Are you sure you want to change the base?
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -623,6 +623,79 @@ app.kubernetes.io/component: proxy | |
| telemetry.retool.com/service-name: agent-sandbox-proxy | ||
| {{- end -}} | ||
|
|
||
| {{/* | ||
| Validate that an enabled agent sandbox has its required secrets supplied. The | ||
| controller and proxy fail to boot without a Postgres connection and a JWT | ||
| public key, and the Retool backend needs the JWT private key to sign sandbox | ||
| tokens. Each may come from a plaintext value, the per-key existing-secret refs, | ||
| or the catch-all externalSecret.name. No-op when agentSandbox is disabled. | ||
| */}} | ||
| {{- define "retool.agentSandbox.validateSecrets" -}} | ||
| {{- if .Values.agentSandbox.enabled -}} | ||
| {{- $as := .Values.agentSandbox -}} | ||
| {{- $ext := $as.externalSecret.name -}} | ||
| {{- if not (or $as.postgres.url $as.postgres.urlSecretName $as.postgres.host $ext) -}} | ||
| {{- fail "agentSandbox.enabled requires a Postgres connection. Set one of: agentSandbox.postgres.url (DSN), agentSandbox.postgres.host + user + database (the chart assembles the DSN, password from postgres.password or postgres.passwordSecretName), agentSandbox.postgres.urlSecretName (existing secret holding the DSN), or agentSandbox.externalSecret.name." -}} | ||
| {{- end -}} | ||
| {{- if and $as.postgres.host (not (and $as.postgres.user $as.postgres.database)) -}} | ||
| {{- fail "agentSandbox.postgres.host is set, so postgres.user and postgres.database are also required to assemble the DSN." -}} | ||
| {{- end -}} | ||
| {{- if not (or $as.jwtPublicKey $ext) -}} | ||
| {{- fail "agentSandbox.enabled requires a JWT public key. Set agentSandbox.jwtPublicKey or agentSandbox.externalSecret.name." -}} | ||
| {{- end -}} | ||
| {{- if not (or $as.jwtPrivateKey $ext) -}} | ||
| {{- fail "agentSandbox.enabled requires a JWT private key (the backend signs sandbox tokens with it). Set agentSandbox.jwtPrivateKey or agentSandbox.externalSecret.name." -}} | ||
| {{- end -}} | ||
| {{- end -}} | ||
| {{- end -}} | ||
|
|
||
| {{/* | ||
| Render the AGENT_SANDBOX_POSTGRES_URL env entry for the controller/proxy (plus a | ||
| PGPASSWORD entry when assembling from fields). validateSecrets guarantees one of | ||
| these applies, in order: postgres.url -> postgres.host -> postgres.urlSecretName | ||
| -> externalSecret.name. | ||
|
|
||
| For the host path the password is passed via PGPASSWORD rather than embedded in | ||
| the URL: node-postgres reads PGPASSWORD when the connection string omits the | ||
| password, so it needs no URL escaping. PGPASSWORD is process-global but safe | ||
| here because the controller/proxy open exactly one Postgres connection. | ||
| Usage: {{- include "retool.agentSandbox.postgresUrlEnv" . | nindent 12 }} | ||
| */}} | ||
| {{- define "retool.agentSandbox.postgresUrlEnv" -}} | ||
| {{- $pg := .Values.agentSandbox.postgres -}} | ||
| {{- $ext := .Values.agentSandbox.externalSecret.name -}} | ||
| {{- if $pg.url }} | ||
| - name: AGENT_SANDBOX_POSTGRES_URL | ||
| value: {{ $pg.url | quote }} | ||
| {{- else if $pg.host }} | ||
| {{- $port := $pg.port | default 5432 -}} | ||
| {{- if $pg.passwordSecretName }} | ||
| - name: PGPASSWORD | ||
| valueFrom: | ||
| secretKeyRef: | ||
| name: {{ $pg.passwordSecretName }} | ||
| key: {{ $pg.passwordSecretKey | default "password" }} | ||
| {{- else if $pg.password }} | ||
| - name: PGPASSWORD | ||
| value: {{ $pg.password | quote }} | ||
| {{- end }} | ||
| - name: AGENT_SANDBOX_POSTGRES_URL | ||
| value: {{ printf "postgres://%s@%s:%v/%s" $pg.user $pg.host $port $pg.database | quote }} | ||
|
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
The The PR correctly routes the password through |
||
| {{- else if $pg.urlSecretName }} | ||
| - name: AGENT_SANDBOX_POSTGRES_URL | ||
| valueFrom: | ||
| secretKeyRef: | ||
| name: {{ $pg.urlSecretName }} | ||
| key: {{ $pg.urlSecretKey | default "postgres-url" }} | ||
| {{- else if $ext }} | ||
| - name: AGENT_SANDBOX_POSTGRES_URL | ||
| valueFrom: | ||
| secretKeyRef: | ||
| name: {{ $ext }} | ||
| key: postgres-url | ||
| {{- end }} | ||
| {{- end -}} | ||
|
|
||
| {{/* | ||
| Agent sandbox env vars for the Retool backend, workflow backend, and workers. | ||
| Outputs env entries that tell the backend how to reach the agent sandbox services. | ||
|
|
||
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
postgres.hostis set with no password sourceWhen
postgres.hostis set and neitherpostgres.passwordnorpostgres.passwordSecretNameis provided, the template emits noPGPASSWORDentry and the assembled URL carries no credentials. For most production Postgres deployments this results in a rejected connection, but the failure surfaces at pod startup rather than athelm installtime.validateSecretsalready enforcesuseranddatabaseon thehostpath; extending it to check(not (or $pg.password $pg.passwordSecretName))and{{- fail }}when true (or document it as intentional for trust-auth) would make the behaviour explicit.