refactor(flyte-binary): consolidate DB config to runs.database#7525
Conversation
Remove the duplicate configuration.database block; flyte-core-components.runs.database is the single source the unified binary connects through. Repoint the waitForDB init container and the optional DB-password Secret at runs.database, and drop the dead 002-database.yaml render. Signed-off-by: Kevin Su <pingsutw@gmail.com> Signed-off-by: Kevin Su <pingsutw@apache.org>
11b991e to
6aeeb28
Compare
There was a problem hiding this comment.
Pull request overview
This PR cleans up the flyte-binary Helm chart by removing the unused configuration.database block and consolidating all DB configuration under flyte-core-components.runs.database, ensuring the init-container and optional DB-password Secret target the same database the unified binary uses.
Changes:
- Removed the unused
configuration.databasedefaults fromvalues.yaml. - Updated the
wait-for-dbinit container to derivepg_isreadyparameters fromflyte-core-components.runs.database.postgres. - Removed the standalone
002-database.yamlconfig render and moved the optional password Secret to read fromruns.database.postgres.password.
Reviewed changes
Copilot reviewed 4 out of 4 changed files in this pull request and generated 1 comment.
| File | Description |
|---|---|
| charts/flyte-binary/values.yaml | Removes configuration.database defaults and documents the consolidated DB config location. |
| charts/flyte-binary/templates/deployment.yaml | Points the wait-for-db init container at runs.database.postgres fields. |
| charts/flyte-binary/templates/configmap.yaml | Removes 002-database.yaml generation (standalone-binary-only config). |
| charts/flyte-binary/templates/config-secret.yaml | Reads optional DB password from runs.database.postgres.password to generate 012-database-secrets.yaml. |
Comments suppressed due to low confidence (1)
charts/flyte-binary/templates/deployment.yaml:80
- If
flyte-core-components.runs.database.postgresis missing (or overridden to a non-postgres config), thiswithblock renders no args forsh -ec, which will crash the init container in a non-obvious way. Prefer failing the template render with a clear error (or require users to providedeployment.waitForDB.args).
{{- with (index .Values "flyte-core-components" "runs" "database" "postgres") }}
- |
until pg_isready \
-h {{ tpl .host $ }} \
-p {{ .port }} \
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
bdc0cab to
dcda6f2
Compare
Consolidate the chart DB config onto a flat configuration.database block and map it to runs.database at render time (the path the unified binary reads via runsconfig.GetConfig().Database). The 002-database.yaml render strips the password before toYaml so it never lands in the ConfigMap in plaintext; the password is supplied via the 012-database-secrets.yaml Secret instead. - values.yaml: drop flyte-core-components.runs.database; add configuration.database - configmap.yaml: render configuration.database under runs.database (password scrubbed) - config-secret.yaml: source password from configuration.database.postgres.password - deployment.yaml: waitForDB reads configuration.database.postgres Signed-off-by: Kevin Su <pingsutw@apache.org>
dcda6f2 to
14d4c19
Compare
There was a problem hiding this comment.
Pull request overview
Copilot reviewed 4 out of 4 changed files in this pull request and generated 4 comments.
Comments suppressed due to low confidence (1)
charts/flyte-binary/templates/deployment.yaml:82
002-database.yamltemplates the entireconfiguration.databaseblock viatpl, which meanspostgres.usernamecan be templated in the rendered config. Thewait-for-dbinit container currently uses.usernamewithouttpl, which can lead to it waiting with a different username than the binary config if a user supplies a templated value. Consider templating the username here as well for consistency.
until pg_isready \
-h {{ tpl .host $ }} \
-p {{ .port }} \
-U {{ .username }}
do
…nfig The devbox set the DB password via the deprecated flat field configuration.database.password and again in configuration.inline.runs.database, both of which render into ConfigMaps in plaintext (the config Secret only fires on configuration.database.postgres.password). - values.yaml: move the password under configuration.database.postgres so it is emitted as the 012-database-secrets.yaml Secret and scrubbed from the ConfigMap - values.yaml: drop the duplicate inline password (supplied via the Secret on merge) - regenerate manifests/complete.yaml: DB password now appears only in the Secret, and 002-database.yaml renders under runs.database (matching the chart consolidation) Signed-off-by: Kevin Su <pingsutw@apache.org>
Signed-off-by: Kevin Su <pingsutw@apache.org>
There was a problem hiding this comment.
Pull request overview
Copilot reviewed 6 out of 6 changed files in this pull request and generated 2 comments.
Comments suppressed due to low confidence (2)
charts/flyte-binary/templates/deployment.yaml:86
- If
configuration.database.postgresis empty/omitted anddeployment.waitForDB.argsis not set, thewithblock produces no list items andargs:becomesnull, which is invalid for a container spec. Consider failing fast withrequired(or providing an explicit fallback) so Helm doesn’t render an invalid manifest.
{{- with .Values.configuration.database.postgres }}
- |
until pg_isready \
-h {{ tpl .host $ }} \
-p {{ .port }} \
-U {{ .username }}
do
echo waiting for database
sleep 0.1
done
{{- end }}
docker/devbox-bundled/manifests/complete.yaml:7812
- This rendered manifest’s inline
runs.database.postgresblock usesdbName/userkeys, which don’t match Flyte’s expecteddbname/usernamekeys for Postgres config. If this file is used directly, the override may be ignored and the service can end up using the default DB settings instead of the intendedrunsDB.
ephemeralStorage: 0
gpu: 0
memory: 1Gi
limits:
cpu: 0
|
Should we also update flyte/charts/flyte-binary/README.md Lines 46 to 52 in 9c41e6e |
| # passwordPath Mountpath of file containing password to be added to Flyte deployment | ||
| passwordPath: "" |
There was a problem hiding this comment.
I think this is still supported? Should we add it back?
There was a problem hiding this comment.
Good catch — yes, it's still supported. passwordPath is read by the binary (flytestdlib/database/config.go: PostgresConfig.PasswordPath, with "Either Password or PasswordPath must be set"), and the legacy flat database.passwordPath is still mapped into Postgres.PasswordPath in GetConfig().
Added it back under configuration.database.postgres.passwordPath in 689f63a. It's the file-based password option (point at a file you mount yourself via deployment.extraVolumes/extraVolumeMounts, e.g. from an external secret manager) — distinct from password, which the chart turns into a managed Secret; the two are mutually exclusive. It flows straight through to runs.database.postgres.passwordPath via the existing configmap rendering (only password is stripped), so no template change was needed.
…Path passwordPath is still read by the binary (flytestdlib PostgresConfig.PasswordPath; "Either Password or PasswordPath must be set"), so keep it in the chart values. It is the file-based password option — distinct from `password`, which the chart turns into a managed Secret — for externally-mounted secrets. It flows straight through to runs.database.postgres.passwordPath via the existing configmap rendering (password is stripped, passwordPath is not). Signed-off-by: Kevin Su <pingsutw@apache.org>
There was a problem hiding this comment.
Pull request overview
Copilot reviewed 7 out of 7 changed files in this pull request and generated 4 comments.
Comments suppressed due to low confidence (1)
charts/flyte-binary/templates/deployment.yaml:81
- If
deployment.waitForDB.argsis not set andconfiguration.database.postgresis missing (e.g., users still providing the legacyconfiguration.database.host/port/usernamekeys), this renders an initContainer withsh -ecbut no command string underargs, causing pod startup failure with a confusing shell error. Consider failing fast with a clear message whenconfiguration.database.postgresis absent.
{{- with .Values.configuration.database.postgres }}
- |
until pg_isready \
-h {{ tpl .host $ }} \
-p {{ .port }} \
-U {{ .username }}
Tracking issue
N/A — chart cleanup.
Why are the changes needed?
The flyte-binary chart configured the database in two places:
flyte-core-components.runs.database— what the unified binary actuallyconnects through (
runsconfig.GetConfig().Databaseinmanager/cmd/main.go,registered under the
runsconfig section).configuration.database— a separate top-level block that the unified binarydoes not read. It only fed the
waitForDBinit container, the002-database.yamlconfig file (a top-leveldatabase:section read only bythe standalone
runs/cache_servicecmd binaries, never the unified binary),and an optional password Secret.
Keeping both invites drift (the two could point at different DBs) and is
confusing. This consolidates to a single, flat source of truth:
configuration.database. Users set the DB in one conventional place, and thechart maps it to
runs.database— the path the unified binary actually reads —at render time.
What changes were proposed in this pull request?
values.yaml— removed theflyte-core-components.runs.databaseblock.configuration.databaseis now the single DB config (withmaxIdleConnections,maxOpenConnections,connMaxLifeTime, and thepostgressub-block).configmap.yaml—002-database.yamlnow rendersconfiguration.databaseunder
runs.database(instead of the old top-leveldatabase:), so theunified binary reads it at
runsconfig.GetConfig().Database. The config dir isloaded via
--config /etc/flyte/config.d/*.yaml, so this file deep-merges withthe
runs:section in000-core.yamland the password in012-database-secrets.yaml. The password field is stripped beforetoYaml(
deepCopy+unset) so it is never written to the ConfigMap in plaintext —it is supplied via the Secret instead.
config-secret.yaml— the optional DB-password Secret(
012-database-secrets.yaml) now readsconfiguration.database.postgres.passwordand renders it as
runs.database.postgres.password.deployment.yaml— thewaitForDBinit container derives itspg_isreadytarget from
configuration.database.postgres, so it waits on exactly the DBthe binary connects to.
configuration.databaseremains the single, required DB config.How was this patch tested?
helm templaterenders cleanly both with a values override and with barechart defaults.
002-database.yamlrendersruns.databaseand that the password isnever present in the ConfigMap (0 plaintext occurrences) while still being
carried by
012-database-secrets.yaml.wait-for-dbinit container resolves to the configuredconfiguration.databasehost/port/user.helm lintpasses.Labels
changed
Check all the applicable boxes