fix(dtrack): source JDBC host/port from externalDatabase.existingSecret#113
Conversation
|
Thanks for this. Now that several chart PRs (including the v1.2.0 alignment #145 and the load-bearing image-tag change #78) have landed on (The red SonarCloud check is a known non-blocking fork limitation and can be ignored.) |
When `postgres.enabled=false` and `externalDatabase.existingSecret` is set (the canonical external-DB path), `templates/dtrack-deployment.yaml` built `ALPINE_DATABASE_URL` from `externalDatabase.host` / `externalDatabase.port` plain-string values. Operators following the existingSecret pattern who omit those plain values get an empty-host JDBC URL — `jdbc:postgresql://:5432/dependency_track` — which JDBC interprets as `localhost` and dtrack then fails on startup with `Connection refused`. This change projects host/port out of the operator-provided Secret into two leading env vars (`_DTRACK_DB_HOST`, `_DTRACK_DB_PORT`) and references them from `ALPINE_DATABASE_URL` via Kubernetes `$(VAR)` expansion. Two new values let operators point at custom keys in the Secret: externalDatabase.existingHostKey (default "POSTGRES_HOST") externalDatabase.existingPortKey (default "POSTGRES_PORT") Mirrors the precedent set by `externalDatabase.existingPasswordKey` (artifact-keeper#110). Strictly additive: when `existingSecret` is unset, the literal host/port substitution is preserved — `helm template` output is byte-identical for the in-cluster postgres and inline-host/port paths.
11d74ea to
337bb6b
Compare
|
Rebased onto the latest |
Summary
When
postgres.enabled=falseandexternalDatabase.existingSecretis set (the canonical external-DB path),templates/dtrack-deployment.yamlbuildsALPINE_DATABASE_URLfromexternalDatabase.host/externalDatabase.portplain-string values. Operators following theexistingSecretpattern who omit those plain values get an empty-host JDBC URL —jdbc:postgresql://:5432/dependency_track— which JDBC interprets aslocalhost, and dtrack then fails on startup withConnection refused.This PR projects host/port out of the operator-provided Secret into two leading env vars (
_DTRACK_DB_HOST,_DTRACK_DB_PORT) and references them fromALPINE_DATABASE_URLvia Kubernetes$(VAR)expansion. Two new values let operators point at custom keys in the Secret:Mirrors the precedent in #110 (
existingPasswordKey). Strictly additive: whenexistingSecretis unset, the literal host/port substitution is preserved —helm templateoutput is byte-identical for the in-cluster-postgres and inline-host/port paths.A longer-term alternative would be to consume the full
DATABASE_URLthe backend already reads from the Secret (parsepostgresql://...→jdbc:postgresql://...in the template). Happy to do that follow-up if you'd prefer a single source of truth across both deployments.Reproducer (before this PR):
Renders
ALPINE_DATABASE_URL: "jdbc:postgresql://:5432/dependency_track". After this PR the same command renders the URL with$(VAR)expansion against the two new env vars sourced frommysecret.Test Checklist
helm lintclean)Infrastructure
helm templaterenders correctly: defaults / inline external DB /existingSecretonly /existingSecret+ custom host/port keyshelm-docsregenerated (README values table updated)terraform validatepasses (N/A)terraform planshows expected changes (N/A)Closes #151