Repository navigation
[Server] Read the database password from an environment variable - #2080
Conversation
|
Local AI review run The CI
Each finding was checked against the code before acting on it.
Reviewed heads: 2f4bb5a, 690745f, 8b8356b, c0bc199, d7bf525. Current heads: 81e48b4, eba9f92, 99ae5a0, b91905f, b19e7a5. |
eba9f92 to
cf24a2d
Compare
|
Local AI review run (round 2) The CI
Verification on the current heads:
|
|
/review |
cf24a2d to
01ba0eb
Compare
|
/review |
72bbfef to
94710f1
Compare
Operators can now set any setting, including the OAuth client secret, the AWS secret key, and the per-bucket S3 and ADLS secrets, in an environment variable a shell can export: UC_, then the key in upper case with `_` for each other character, such as UC_S3_SECRETKEY_0. The prefix keeps variables that runtimes set for their own use, such as AWS_REGION, from changing settings. A variable named exactly as the key still comes first. At startup the server logs the name of each variable it uses, never the value. `bin/uc auth login` also reads UC_SERVER_CLIENT_SECRET. Secrets in server.properties keep working, but the server now logs a deprecation warning for each one it reads from the file, and the docs mark that way as deprecated. The Helm chart passes the S3 and ADLS secrets to the server container as environment variables instead of rendering them into server.properties, and no longer gives the server the OAuth client secret, which only the CLI reads. Co-authored-by: Isaac <[email protected]> Signed-off-by: Shubham Bansal <[email protected]>
The comment on reading UC_SERVER_CLIENT_SECRET repeated what the next lines do; keep the part that says why the name and trimming match the server. Co-authored-by: Isaac <[email protected]> Signed-off-by: Shubham Bansal <[email protected]>
The server never reads server.client-secret, but its deprecation warning told operators to set UC_SERVER_CLIENT_SECRET, and setting it in the server's environment silenced the warning. The warning now says only bin/uc auth login reads it, names the shell that runs that command, and is no longer silenced by the server's environment. Co-authored-by: Isaac <[email protected]> Signed-off-by: Shubham Bansal <[email protected]>
The CLI login tests pass --identity_token, so none reached the UC_SERVER_CLIENT_SECRET lookup in the OAuth flow. Move the lookup into Oauth2CliExchange.clientSecret and test it in CliAuthCrudTest: the variable wins over server.client-secret with a trailing line break dropped, and an absent, empty or line-break-only variable falls back to the file. Co-authored-by: Isaac <[email protected]> Signed-off-by: Shubham Bansal <[email protected]>
The database password could only come from hibernate.properties. The server now also takes it from the UC_HIBERNATE_CONNECTION_PASSWORD environment variable, which wins over the file. A system property is not used for it: Hibernate copies system properties into its own settings, and a password there makes the connection pool fail. A password kept in hibernate.properties still works, but the server logs a deprecation warning, and the docs mark that way as deprecated. The Helm chart passes the password to the server container as an environment variable instead of rendering it into hibernate.properties. Co-authored-by: Isaac <[email protected]> Signed-off-by: Shubham Bansal <[email protected]>
AGENTS.md describes where the backends are configured, and a password in hibernate.properties still works; the configuration and deployment docs cover the environment variable. Co-authored-by: Isaac <[email protected]> Signed-off-by: Shubham Bansal <[email protected]>
The two-line private method says the same. Co-authored-by: Isaac <[email protected]> Signed-off-by: Shubham Bansal <[email protected]>
94710f1 to
a733445
Compare
Co-authored-by: Isaac <[email protected]> Signed-off-by: Shubham Bansal <[email protected]>
Co-authored-by: Isaac <[email protected]> Signed-off-by: Shubham Bansal <[email protected]>
…plates
A server.config.override or extraProperties template could use the init container's S3_SECRET_KEY_<n>, ADLS_CLIENT_SECRET_<n> or OAUTH_CLIENT_SECRET for any key, for example aws.secretKey=${S3_SECRET_KEY_0}. After the secrets moved to the server's environment, those lines rendered empty. The init container now gets these variables again when either setting is set, which is deprecated. OAUTH_CLIENT_SECRET is optional, and the auth Secret only needs clientId, since nothing else in the chart reads the client secret.
Co-authored-by: Isaac <[email protected]>
Signed-off-by: Shubham Bansal <[email protected]>
Co-authored-by: Isaac <[email protected]> Signed-off-by: Shubham Bansal <[email protected]>
|
/review |
Co-authored-by: Isaac <[email protected]> Signed-off-by: Shubham Bansal <[email protected]>
Co-authored-by: Isaac <[email protected]> Signed-off-by: Shubham Bansal <[email protected]>
Co-authored-by: Isaac <[email protected]> Signed-off-by: Shubham Bansal <[email protected]>
Co-authored-by: Isaac <[email protected]> Signed-off-by: Shubham Bansal <[email protected]>
## 🥞 Stacked PR Use this [link](https://github.com/unitycatalog/unitycatalog/pull/2079/files) to review incremental changes. - [**stack/ep31-config-secrets-env**](#2079) [[Files changed](https://github.com/unitycatalog/unitycatalog/pull/2079/files)] ← _this PR_ - [stack/ep31-db-password-env](#2080) [[Files changed](https://github.com/unitycatalog/unitycatalog/pull/2080/files/6af48d7037ce77ff96e920c539c9d770d6ef830a..52be2ac3336ec008692a713804031a9779cac524)] - [stack/ep31-signing-key-dir](#2081) [[Files changed](https://github.com/unitycatalog/unitycatalog/pull/2081/files/52be2ac3336ec008692a713804031a9779cac524..2b96c369d6a90b52461eb617050dd7b35d3b1bb0)] - [stack/ep31-admin-token-in-memory](#2082) [[Files changed](https://github.com/unitycatalog/unitycatalog/pull/2082/files/2b96c369d6a90b52461eb617050dd7b35d3b1bb0..576ec307a689978e488eb7b36ae8c6f01d8fccc8)] --------- **PR Checklist** - [x] A description of the changes is added to the description of this PR. - [ ] If there is a related issue, make sure it is linked to this PR. - [x] If you've fixed a bug or added code that should be tested, add tests! - [x] If you've added or modified a feature, documentation in `docs` is updated This is part 1 of 4 in a stack; each PR handles one kind of secret end to end (server, Helm chart, docs, tests). Review only this PR's changes with its incremental link above. **Description of changes** Operators can now set any server setting, and so every secret, in an environment variable that a shell or a Kubernetes Secret can supply. Before, UC looked only for a variable named exactly like the key (`s3.secretKey.0`), which no shell can export, so secrets lived in `server.properties` in plaintext, and the Helm chart rendered them there. - A setting's variable is `UC_`, then the key in upper case, with `_` for every character that is not a letter or digit: `UC_S3_SECRETKEY_<n>`, `UC_S3_SESSIONTOKEN_<n>`, `UC_ADLS_CLIENTSECRET_<n>`, `UC_AWS_SECRETKEY`, `UC_SERVER_CLIENT_SECRET`. It takes precedence over `server.properties`. - At startup the server logs the name of each environment variable it uses for a setting, never its value. - Secrets in `server.properties` still work. The server logs a deprecation warning at startup for each one (key name only), and the docs mark that way as deprecated. The warning for `server.client-secret` says that only `bin/uc auth login` reads it and to set `UC_SERVER_CLIENT_SECRET` in the shell that runs that command; setting the variable for the server does not silence it. - The Helm chart passes the S3 and ADLS secrets to the server container as environment variables from the same Kubernetes Secrets, instead of rendering them into `server.properties`. Chart values are unchanged. The OAuth client secret is no longer passed to the server at all: only `bin/uc auth login` reads it. - `bin/uc auth login` reads `UC_SERVER_CLIENT_SECRET` before `etc/conf/server.properties`. - `docs/server/aws.md` also gets the master user keys right: the server reads `aws.masterRoleArn` / `aws.accessKey` / `aws.secretKey`, not the `aws.s3.*` names the page showed. - Docs that showed secrets in `server.properties` now use the environment variables and mark the file deprecated: configuration, auth, AWS, Docker Compose, the Spark and XTable integrations, the integration-test setup, the sample `server.properties` files, and the Helm `config.override` / `extraProperties` values. ```sh export UC_S3_SECRETKEY_0='<secret key>' bin/start-uc-server ``` <details><summary><b>📐 Design notes & details</b></summary> **Why this shape.** Apache Polaris reads settings from environment variables under the property name in upper case (SmallRye config rules), and its chart passes Kubernetes Secrets in with `secretKeyRef`. This PR follows the same model. No generic "read any secret from a file" option is added. **Why the `UC_` prefix, for every key.** One rule for all keys is easier to use than a list of secret keys. Without a prefix, variables that runtimes set for their own use would change UC settings: `aws.region` would map to `AWS_REGION`, which AWS runtimes set, and `server.env` to `SERVER_ENV`. With the prefix, only variables meant for UC count. **Details.** - Lookup order: system property, then the variable under the exact key, then the `UC_` name, then `server.properties`. - An empty `UC_` variable is ignored, like an empty value in `server.properties`. - A line break at the end of a `UC_` value is dropped. Before, the chart's envsubst wrote the value into `server.properties`, and `Properties.load` ended it at the line break; Secrets made from a file often end with one. - The deprecation warning fires only when a secret's value really comes from the file. A secret also set in the environment does not warn, except `server.client-secret`: the server never reads it, so a variable in the server's environment is not a fix. - Kubernetes service links: the variables Kubernetes adds for each Service end in `_SERVICE_HOST`, `_SERVICE_PORT` or `_PORT[...]`. The only key whose `UC_` name has that shape is `server.redirect-port`, and only for a Service named `uc-server-redirect`; the chart's Services are named `<fullname>-server` and `<fullname>-ui`. A wrong value there fails startup validation. - Helm: a `server.config.override` or `extraProperties` template that uses the chart's old `${OAUTH_CLIENT_SECRET}`, `${S3_SECRET_KEY_<n>}` or `${ADLS_CLIENT_SECRET_<n>}` keeps working, for any key (for example `aws.secretKey=${S3_SECRET_KEY_0}`): when either setting is set, the init container still gets those variables. That is deprecated, and `values.yaml` says so. `OAUTH_CLIENT_SECRET` is an optional ref, since nothing else in the chart reads the client secret; the auth Secret only needs `clientId`. **Compatibility.** Users see these in the new Upgrading list under Secrets in `docs/server/configuration.md`. - A `UC_` variable already set in the server's environment now takes precedence over the same key in `server.properties`. - Secrets in `server.properties` keep working, with a warning. - Helm with `server.deployment.image.tag` pinned to an older server image: that image doesn't read these variables, so S3 and ADLS lose their secrets. The image tag note in `values.yaml` says to use the server image from the chart's release (the default). - Helm: the rendered `server.properties` no longer holds these secrets, and without a custom template the init container no longer has `OAUTH_CLIENT_SECRET`, `S3_SECRET_KEY_<n>` or `ADLS_CLIENT_SECRET_<n>`. A container added through `extraInitContainers` or `extraContainers` that needs them must read them from the Kubernetes Secret itself. **Tests.** - `ServerPropertiesTest.testSettingsFromEnvironment`: `UC_` variables for the client secret, S3 secret key and session token, ADLS client secret and a non-secret key (`s3.region.0`); a trailing CR/LF is dropped; an empty `UC_` variable is ignored; `AWS_REGION` does not change `aws.region`; the exact-name variable wins over the `UC_` one. - `CliAuthCrudTest.testAuthLoginReadsTheClientSecretFromTheEnvironmentBeforeTheFile`: `bin/uc auth login` takes `UC_SERVER_CLIENT_SECRET` over `server.client-secret`, drops a trailing line break, and falls back to the file when the variable is absent, empty or only a line break. The other CLI login tests pass `--identity_token`, so they skip this path. - `helm/ci/secrets-values.yaml` renders the S3 and ADLS secret variables in chart lint, plus the deprecated init container variables through `extraProperties`; `helm template` renders with and without auth, S3 and ADLS, and with none of them no `env:` block is emitted. - Checked by hand on a local server: a secret in `server.properties` logs the warning; with `UC_S3_SECRETKEY_0` set, the log names the variable and only the remaining file secrets warn; no value appears in the log. </details> This pull request and its description were written by Isaac. --------- Signed-off-by: Shubham Bansal <[email protected]> Co-authored-by: Isaac <[email protected]>
unitycatalog#2079 landed as d31fa8b, whose tree is unitycatalog#2079's head, which this branch already holds. Co-authored-by: Isaac <[email protected]> Signed-off-by: Shubham Bansal <[email protected]>
|
/review |
yili-db
left a comment
There was a problem hiding this comment.
[AI Assisted] The server change looks right: the variable wins over the file, the value is never logged, and the chart stops rendering the password into hibernate.properties. The gaps are in tests, where every new branch has existing scaffolding that was not extended. Inline comments below, plus one that has no diff anchor:
.github/workflows/helm-chart-tests.yml: secrets-values.yaml now has a password Secret, but the render check knows nothing about it. Can you add UC_HIBERNATE_CONNECTION_PASSWORD:ci-db-password:password to the for ref loop, hibernate\.connection\.password to the "none in the file" grep, and assert DB_PASSWORD is gone from the init container? Without that the chart half of this PR is only lint-covered.
…sets it The server reads the database password only from UC_HIBERNATE_CONNECTION_PASSWORD, so a system property no longer silences the "is ignored" warning. The key is one constant, and the hibernate.properties warning derives the variable name. Co-authored-by: Isaac <[email protected]> Signed-off-by: Shubham Bansal <[email protected]>
Co-authored-by: Isaac <[email protected]> Signed-off-by: Shubham Bansal <[email protected]>
Co-authored-by: Isaac <[email protected]> Signed-off-by: Shubham Bansal <[email protected]>
|
/review |
yili-db
left a comment
There was a problem hiding this comment.
[AI Assisted] Thanks for the fixes. The Helm render check, the system-property handling, the shared key constant and the template comment all look good. Still open: tests for both warnings and the test subclass (replied on those threads). Two small things from the new commits are inline.
A system property does not silence it; UC_HIBERNATE_CONNECTION_PASSWORD does. Co-authored-by: Isaac <[email protected]> Signed-off-by: Shubham Bansal <[email protected]>
Co-authored-by: Isaac <[email protected]> Signed-off-by: Shubham Bansal <[email protected]>
MySQL from unitycatalog#2119 takes the same password path as PostgreSQL: the chart passes UC_HIBERNATE_CONNECTION_PASSWORD to the server, and neither hibernate.properties nor the init container gets the password. Co-authored-by: Isaac <[email protected]> Signed-off-by: Shubham Bansal <[email protected]>
|
@yili-db Thanks for the reviews. On the Helm render check from your first review: it now covers the password Secret (0ed1bdf). It checks that |
|
/review |
The server container had two env lists on MySQL: the secrets and the JDK_JAVA_OPTIONS for the driver. YAML keeps the last key, so the database password variable was dropped, the server could not log in and the chart install timed out. Render both into one env list. Co-authored-by: Isaac <[email protected]> Signed-off-by: Shubham Bansal <[email protected]>
|
/review |
yili-db
left a comment
There was a problem hiding this comment.
[AI Assisted] Three small nits inline; no blockers.
The password is not a secret the server reads from server.properties, so it leaves SECRET_KEY and gets its own check after the loop; the override branch holds the warning. The render check comment says it covers the whole chart. Co-authored-by: Isaac <[email protected]> Signed-off-by: Shubham Bansal <[email protected]>
Co-authored-by: Isaac <[email protected]> Signed-off-by: Shubham Bansal <[email protected]>
|
/review |
## 🥞 Stacked PR Use this [link](https://github.com/unitycatalog/unitycatalog/pull/2117/files/727e167d1206b36e7bbb1e30fb18bd5ee0d4be7f..0a120a3c682986c926845a85ad249df1720e5d4c) to review incremental changes. - [stack/uc-flyway-schema](#2045) (merged) - [stack/uc-upgrade-adopt](#2112) (merged) - [stack/uc-upgrade-merge-checks](#2113) (merged) - [stack/uc-upgrade-retry](#2114) [[Files changed](https://github.com/unitycatalog/unitycatalog/pull/2114/files)] - [stack/uc-upgrade-check-schema](#2115) [[Files changed](https://github.com/unitycatalog/unitycatalog/pull/2115/files/d4c1b003a0e576debded4b91a28b256d02507f67..0028bc22bb2e6ebd02e11048a2d7560ad023be19)] - [stack/uc-sample-database-built](#2116) [[Files changed](https://github.com/unitycatalog/unitycatalog/pull/2116/files/0028bc22bb2e6ebd02e11048a2d7560ad023be19..727e167d1206b36e7bbb1e30fb18bd5ee0d4be7f)] - [**stack/uc-flyway-owns-schema**](#2117) [[Files changed](https://github.com/unitycatalog/unitycatalog/pull/2117/files/727e167d1206b36e7bbb1e30fb18bd5ee0d4be7f..0a120a3c682986c926845a85ad249df1720e5d4c)] ← _this PR_ - [stack/uc-hibernate-fallback](#2118) [[Files changed](https://github.com/unitycatalog/unitycatalog/pull/2118/files/0a120a3c682986c926845a85ad249df1720e5d4c..97bc44b5dfb75eb27fdddc33db6ea208680234ac)] --------- This PR makes the schema steps the only way Unity Catalog's schema changes. The server no longer lets Hibernate build or change the schema at start. Instead, it checks that the database is at this release's schema, and refuses to start otherwise. The Helm chart runs `--upgrade-schema` in an init container before each server pod starts. ### What you see - Before the first start on a new database, run `bin/start-uc-server --upgrade-schema` once. A source checkout's quickstart sample database needs none. An in-memory database (`server.env=test`, or a named `jdbc:h2:mem:<name>;DB_CLOSE_DELAY=-1` URL; unnamed in-memory URLs are refused) is the exception: it lasts only as long as the server, so the server sets it up itself, and `--upgrade-schema` succeeds on it without doing anything. - The server refuses to start on a database that is not at this release's last step, or whose schema history fails Flyway's check (a failed step, also a newer release's, or an edited or missing step). The start refuses what `--check-schema` and `--upgrade-schema` refuse. The message says what to do: the command to run, or, for a history the commands refuse too, to run the release that applied the steps or restore the backup. For example: ```console The database schema is at version none, and this release needs version 2. Stop every server of the previous release, run bin/start-uc-server --upgrade-schema with this release, then start the server. ``` - To upgrade from 0.7.0, stop the servers, back up the database, run `--upgrade-schema` with the new release, then start it. See `docs/server/upgrades.md`. - `etc/conf/hibernate.properties` no longer sets `hibernate.hbm2ddl.auto=update`. If your file still sets `hibernate.hbm2ddl.auto` (to `update` or another value), the server sets it to `none` and logs a warning. Any other schema action setting that isn't `none` (`jakarta.persistence.schema-generation.database.action`, its `javax.` form, or a suffixed form such as `hibernate.hbm2ddl.auto.orm`) makes the start refuse, also when it comes from a JVM system property or a `hibernate.properties` on the classpath. - The start also refuses what `--upgrade-schema` refuses: `hibernate.default_schema` or `hibernate.default_catalog`, H2 in server mode, and a database other than H2, PostgreSQL and MySQL. Before, Hibernate built a schema on any database. - With authorization enabled, the authorization library runs `CREATE TABLE IF NOT EXISTS casbin_rule` at every start, so the database user keeps the CREATE privilege. - A server that sets up its own test database (`server.env=test`, or no `hibernate.properties`) gives it a name of its own and shuts it down when it closes, so a later server in the same JVM starts on an empty one. A database the configuration names is left as it is. - Helm chart: - An `upgrade-schema` init container runs `bin/start-uc-server --upgrade-schema` in each server pod, after `server.deployment.extraInitContainers`. For an in-memory database it does nothing. - The update strategy defaults to `Recreate`, so all old server pods stop before new ones start, which an upgrade with schema steps needs. The server is unavailable during an upgrade until the new pods are ready. `RollingUpdate` can still be set, for an upgrade without schema steps. - `server.deployment.replicaCount` above 1 with the file database fails to render. - The chart no longer renders `hibernate.hbm2ddl.auto=update`. - `docs/server/helm.md` covers backups, the init container's log, database proxies as native sidecars, scaling to 0 and restoring the backup before `helm rollback`, and why not to use `helm upgrade --atomic`. ### Compatibility - A database not at this release's schema no longer starts: run `bin/start-uc-server --upgrade-schema` first. - `hibernate.hbm2ddl.auto` in `hibernate.properties` is ignored with a warning. Any other schema action setting that isn't `none` is refused, also from a JVM system property or a classpath `hibernate.properties`. - `hibernate.default_schema` and `hibernate.default_catalog` are refused: put the schema in the JDBC URL. - The Helm chart's update strategy defaults to `Recreate` (a values file that sets `RollingUpdate` keeps it), and the file database allows one replica. ### What doesn't change yet - There is no way back to Hibernate's `update` yet. #2118 adds `server.schema-management=hibernate` as a temporary fallback. - The Helm upgrade test covers H2 and PostgreSQL. Once the MySQL Helm PR #2119 lands, it should cover MySQL too. ### Tests - `SchemaMigratorTest`: the start refuses a history the commands refuse (a newer release's failed step, edited and missing steps), with advice that gets past each refusal. - `SchemaGateTest`: the start and both commands on a missing H2 file, an empty database, and each in-memory URL form (`mem:`, `.`, `memFS:`, `memLZF:`, `nioMemFS:`, `nioMemLZF:`), where `--upgrade-schema` succeeds without doing anything. - `UnityCatalogServerTest`: a server built from its own configuration refuses a mistyped H2 path without creating a file; two servers with their own test databases don't share one, and a closed one's database is gone; a configured in-memory database, and a file database behind a leftover in-memory URL setting, are left alone; an injected database keeps its tables. - `HibernateConfiguratorTest`: a schema action set as a JVM system property is refused (in a child JVM). - Helm render checks: `Recreate` renders by default and `RollingUpdate` when set, `replicaCount` above 1 is rejected for the file database, and the init container renders for an in-memory configuration and mounts the configuration and database volume. - Ran on H2, PostgreSQL 18 and MySQL 8 locally: the start-gate, migrator, server and configurator tests and the schema migration tests; the full server suite on H2. CI runs the full suite on all three databases and the Helm install and upgrade tests. <details><summary><b>📐 Design notes & details</b></summary> ### Design - Start runs `requireCurrentSchema()` on the migrator's own small pool: the recorded version must be this build's last step, and Flyway's validation must pass. It takes no run lock and changes nothing. A database newer than this release gets the "newer than this release" refusal; an empty one gets "The database has no Unity Catalog schema yet". - `HibernateConfigurator` refuses every schema action but `none` (`hibernate.hbm2ddl.auto`, `jakarta.persistence.schema-generation.database.action` and its `javax.` form, also with a contributor suffix such as `hibernate.hbm2ddl.auto.orm`) before the pool or the session factory exists, and reads JVM system properties and a classpath `hibernate.properties` the way Hibernate does. `validate` is refused too. Only the server's own `etc/conf/hibernate.properties` gets the lenient path (its schema action turned to `none` with a warning, which also overrides a JVM system property for it), so an old file keeps working. - The whole test suite now builds its schemas with the steps: `TemplateDatabases`, `TestDatabases`, `MySqlDatabases` and `TestDatabase` (with `hbm2ddl` set to `none`), plus `KeyMapperTest` and `BaseAccessControlCRUDTest`. `BaselineMatchesEntitiesTest` keeps checking that the steps match the entities. - Helm: the init container shares the server container's volume mounts through a new `unitycatalog.server.volumeMounts` helper. It runs after `extraInitContainers`, so a database proxy run there as a native sidecar (`restartPolicy: Always`) is up first; a proxy in `extraContainers` starts only after the init containers. The update strategy defaults to `Recreate`, also when an upgrade with `--reuse-values` carries no value from an older release: an upgrade with schema steps changes the database schema, so the old servers must stop before the new ones start. `RollingUpdate` can be set for an upgrade without schema steps. - Helm CI: the "Upgrade from the base chart" step builds the server image from the pull request's base (`HEAD^1`), installs the base chart with it, creates a catalog, runs `helm upgrade` to this chart and image, and checks the catalog is still there. It runs on H2 and on PostgreSQL with two replicas, whose init containers both run the upgrade under the run lock. The workflow now also triggers on changes to the migration code, the steps, the effect files, `UnityCatalogServer.java`, `OptionParser.java` and `bin/start-uc-server`. - Helm: the init container's environment has only what `--upgrade-schema` needs to reach the database: the database password as `UC_HIBERNATE_CONNECTION_PASSWORD` (the way #2080 passes it to the server) and, on MySQL, the driver mount and `JDK_JAVA_OPTIONS` from #2119, through the new `unitycatalog.server.dbPasswordEnv` and `unitycatalog.server.mysqlDriverEnv` helpers. Its environment has no storage credentials. It shares the server container's volume mounts, including the GCS key files, through `unitycatalog.server.volumeMounts`, so the two can't drift apart. The server container keeps one `env` list. - `docs/server/deployment.md` drops the manual `ALTER` statements for `uc_properties.property_value`: new installs get the wide column from the steps, and a pre-0.7.0 database gets it from starting 0.7.0 once. ### Test coverage - `SchemaMigratorTest.serverRefusesToStartOnADatabaseNotAtThisReleasesSchema`: a pending step, a failed step, an edited step, a step missing below the recorded one, and a newer schema. - `SchemaGateTest`: refuses to start on a database that is not set up, and sets up an in-memory database at start. - `HibernateConfiguratorTest`: `neverLetsHibernateChangeTheSchema`, `refusesASchemaActionOtherThanNone` (each setting form), and `refusesHibernatesOwnDefaultSchema`. - Local runs: the runs listed above were on this branch before its last merge of `main`, which brought in #1902, #2063, #2084, #2085, #2086 and #2111. CI runs on the merged head. ### Stack Part 7 of 8 of the schema-upgrade stack: 1. #2045 [Server] Add the schema steps and a manual --upgrade-schema command 2. #2112 [Server] Adopt existing databases in --upgrade-schema 3. #2113 [Build] Check the schema steps on every pull request 4. #2114 [Server] Retry a schema upgrade that stopped part way 5. #2115 [Server] Add a read-only --check-schema command 6. #2116 [Build] Build the sample database instead of checking it in 7. #2117 [Server] Let only the schema steps change the schema (this PR) 8. #2118 [Server] Add a temporary fallback to Hibernate schema updates </details> **PR Checklist** - [x] A description of the changes is added to the description of this PR. - [ ] If there is a related issue, make sure it is linked to this PR. - [x] If you've fixed a bug or added code that should be tested, add tests! - [x] If you've added or modified a feature, documentation in `docs` is updated This pull request and its description were written by Isaac. --------- Signed-off-by: Shubham Bansal <[email protected]> Co-authored-by: Isaac <[email protected]>
unitycatalog#2080 landed as 642cb5c, whose tree is unitycatalog#2080's head, which this branch already holds. Co-authored-by: Isaac <[email protected]> Signed-off-by: Shubham Bansal <[email protected]>
🥞 Stacked PR
Use this link to review incremental changes.
PR Checklist
docsis updatedThis is part 2 of 4 in a stack; each PR handles one kind of secret end to end (server, Helm chart, docs, tests). Review only this PR's changes with its incremental link above.
Description of changes
The database password can now come from the
UC_HIBERNATE_CONNECTION_PASSWORDenvironment variable. Before, it could only be written inetc/conf/hibernate.properties, and the Helm chart rendered it there from its Kubernetes Secret.hibernate.properties, the same order as forserver.properties.hibernate.propertiesstill works. The server logs a deprecation warning at startup, and the docs mark that way as deprecated.server.db.postgresqlConfig.passwordSecretName, instead of rendering it intohibernate.properties.hibernate.connection.passwordline inserver.properties, where the server never reads it, logs a warning saying it is ignored.hibernate.propertiesnow use the variable and mark the file deprecated: configuration, deployment, Docker Compose, and the Helmdb.overrideConfigvalue.export UC_HIBERNATE_CONNECTION_PASSWORD=uc_default_password bin/start-uc-server📐 Design notes & details
UC_rule from the previous PR in this stack and gets the same handling: an empty variable is ignored, a line break at the end is dropped, and the startup log names the variable, never the value.hibernate.properties.-Dhibernate.connection.passwordsystem property. Hibernate copies all system properties into its own settings, and a password there makes Hibernate ask the Hikari pool for a connection with a user and password, which Hikari does not support, so startup fails. That happens before this PR too.hibernate.connection.passwordline inserver.propertiesdoes not trigger theserver.propertiesdeprecation warning, only the "ignored" one.Compatibility. Users see these in the Upgrading list under Secrets in
docs/server/configuration.md.hibernate.propertieskeeps working, with a warning.server.deployment.image.tagpinned to an older server image: that image doesn't read the variable, so the PostgreSQL connection fails. The image tag note invalues.yamlcovers it.DB_PASSWORD. Adb.overrideConfigtemplate withhibernate.connection.password=${DB_PASSWORD}still connects (the line is left empty and the variable supplies the password);values.yamlsays to remove that line. A container added throughextraInitContainersthat needs the password must read it from the Kubernetes Secret itself.Tests.
HibernateConfiguratorTest.prefersThePasswordFromTheEnvironmentToTheFile: the file value is kept without an override, the override wins, andsetupHibernatePropertiestakes it fromServerProperties.getEnv.ServerPropertiesTest.testSettingsFromEnvironmentalso coversUC_HIBERNATE_CONNECTION_PASSWORD.helm/ci/secrets-values.yamladds a PostgreSQL database with a password Secret, so chart lint renders the variable.hibernate.properties(before the variable got itsUC_prefix): with no variable set, startup fails ("no password was provided"); with the variable set, the server serves; with the password only in the file, it serves and logs the deprecation warning. The password never appears in the log.This pull request and its description were written by Isaac.