Add postgresql.passwordFromSecret flag to avoid duplicate PGPASSWORD env var (CE + EE) - #892
Add postgresql.passwordFromSecret flag to avoid duplicate PGPASSWORD env var (CE + EE)#892bxker wants to merge 2 commits into
Conversation
…env var The PGPASSWORD env entry in templates/deployment.yaml is the only secret-derived env var gated on postgresql.enabled in addition to existingSecret - every other field is gated purely on (rawValue OR existingSecret). This means a user who sets postgresql.enabled: true (for PGDATABASE/PGUSER/PGPORT/PGHOST) but supplies PGPASSWORD themselves via extraEnvVars from an external secret mechanism ends up with two PGPASSWORD env entries on the container - one from extraEnvVars, one chart-injected from the auto-created (possibly empty) chart Secret. Add postgresql.passwordFromSecret (default true) so the chart's own PGPASSWORD injection can be opted out of independently, while still rendering the other postgresql.* values. Default true reproduces current behavior exactly - no change for anyone who doesn't set the new flag.
📝 WalkthroughWalkthroughAdds the Estimated code review effort: 2 (Simple) | ~5 minutes Suggested reviewers: 🚥 Pre-merge checks | ✅ 5✅ Passed checks (5 passed)
✨ Finishing Touches🧪 Generate unit tests (beta)
Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out. Comment |
nabeelsaabna
left a comment
There was a problem hiding this comment.
please do the same for renovate-ee chart
The renovate-ee chart's server-deployment.yaml has the identical double-gate bug as mend-renovate-ce: the PGPASSWORD env entry is gated on (postgresql.enabled OR renovateServer.existingSecret), while every other secret-derived env var in the file is gated purely on (rawValue OR existingSecret). Same fix: add postgresql.passwordFromSecret (default true, backward-compatible) and require it alongside the existing guard.
Just added the changes to the mend-renovate-ee chart as well. |
Problem
In both
helm-charts/mend-renovate-ce/templates/deployment.yamlandhelm-charts/mend-renovate-ee/templates/server-deployment.yaml, thePGPASSWORDenv entry is gated on:This is the only secret-derived env var in each file gated on
postgresql.enabledin addition toexistingSecret— every other field (MEND_RNV_LICENSE_KEY,MEND_RNV_GITHUB_APP_KEY,GITHUB_COM_TOKEN, etc.) is gated purely on(rawValue OR existingSecret).Consequence: a user who sets
postgresql.enabled: true(to getPGDATABASE/PGUSER/PGPORT/PGHOSTrendered from values) but suppliesPGPASSWORDthemselves viaextraEnvVars(e.g. sourced from an external-secrets-managed Kubernetes Secret, not this chart's ownexistingSecret/auto-created Secret) ends up with twoPGPASSWORDenv entries on the container — one fromextraEnvVars, one chart-injected from the auto-created (and in this scenario, empty) chart Secret. This duplicate caused a pod crash loop in our environment.Proposed change
Add
postgresql.passwordFromSecret(bool, defaulttrue) to both charts'values.yaml, and change the guard in each deployment template to:Default
truereproduces the current condition exactly (and true X==X) — no behavior change for anyone who doesn't set the new flag. Settingpostgresql.passwordFromSecret: falseopts out of the chart's ownPGPASSWORDinjection while still renderingPGDATABASE/PGUSER/PGPORT/PGHOSTfrompostgresql.*— for use whenPGPASSWORDis supplied viaextraEnvVarsor another external mechanism.No change to either chart's
secret.yaml— the chart's auto-created Secret still exists and still gets apgPasswordkey when.Values.postgresql.passwordis set; the container simply won't reference it forPGPASSWORDwhen the new flag isfalse.Backward-compatibility verification (both charts)
Rendered each chart with default values before and after this change — no diff:
Rendered each chart with
postgresql.enabled: true+passwordFromSecret: false+ an externalPGPASSWORDviaextraEnvVars/renovateServer.extraEnvVars— confirmed exactly onePGPASSWORDentry in both, withPGDATABASE/PGUSER/PGPORT/PGHOSTstill present. Rendered the same values without the new flag set (reproducing the original bug) in both — confirmed twoPGPASSWORDentries, demonstrating the flag is necessary and correctly scoped in both charts.helm lint— 0 failures on bothhelm-charts/mend-renovate-ceandhelm-charts/mend-renovate-ee.Example usage