Gateway Helm: fail on contradictory DSN + passwordSecretRef
@renuka-fernando is already working on this.
Since Aug 27, 2026.
- Dominant language
- Go
- Stars
- 71
- Forks
- 111
- Avg merge
- 1d 14h
- Merged PRs (30d)
- 110
Description
Description
The gateway-helm-chart lets an operator configure the controller's external database (postgres/sqlserver) either via a full dsn or via individual host/port/database/user fields with the password injected separately from a Secret (passwordSecretRef). These two modes are mutually exclusive, but the chart neither enforces nor clearly documents that — leading to silent misconfiguration.
Root cause in the controller: buildPostgresDSN (gateway/gateway-controller/pkg/storage/postgres.go:140) and buildSQLServerDSN (pkg/storage/sqlserver.go) return the dsn as-is when it is non-empty and never merge the separately-configured Password. The password field is only used when dsn is empty. At the chart level, gateway-config.yaml renders the password = '{{ env … }}' line only in the non-DSN branch, so when dsn is set the injected APIP_GW_CONTROLLER_STORAGE_POSTGRES_PASSWORD env var has nothing to consume it.
Two footguns this creates:
dsnset without a password +passwordSecretRefset → the secret is silently ignored; the controller connects with no password and crashloops on a Postgrespassword authentication failederror that points at the DB, not at the contradictory Helm values.dsnset with an inline password +passwordSecretRefset → works (DSN wins), but the mounted secret is dead weight and the password lands in the ConfigMap in plaintext.
Note — "both set" is sometimes valid: the secure DSN pattern embeds a {{ env "APIP_GW_CONTROLLER_STORAGE_POSTGRES_PASSWORD" }} token inside the dsn, which does consume passwordSecretRef at load time and keeps the password out of the ConfigMap. Any guard must allow this.
Proposed fix
- Guarded
fail: ingateway-config.yaml, for both thepostgresandsqlserver/databaseblocks,failat template render time whendsnis set andpasswordSecretRef.nameis set and thedsndoes not reference the password env token — with a message directing the operator to either embed the{{ env … }}token in the DSN or droppasswordSecretRef. Consistent with the chart's existingfail/requiredvalidation (removedsqlserverkey, missing host/db/user,encryptenum). - Docs: correct the misleading
values.yamlcomments in thepostgres/databaseblocks, which currently state both "Full DSN takes precedence over individual fields when set" and "Password is injected separately via … passwordSecretRef" — together implying a password-less DSN plus a separate secret works, which it does not.
Version
No response
Related Issue
No response
Contributor guide
No contributing guide indexed for this repository
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
Assessment
This issue has not been assessed yet.