Repository navigation
[Helm] Start the server with the observability port and probe /readyz - #2063
Conversation
|
Local AI review run The CI Roles: uc-domain, maintainer-claude, architecture, test-coverage and docs (Claude Opus), the disprove gate, and Isaac Review (0 comments posted). The Codex maintainer role was not run.
Findings:
Current head: |
|
/review |
ae6fa1b to
14a4da2
Compare
|
/review |
14a4da2 to
7e61176
Compare
|
/review |
7e61176 to
3ac0701
Compare
|
/review |
3 similar comments
|
/review |
|
/review |
|
/review |
8589765 to
c2bc7a8
Compare
|
/review |
1 similar comment
|
/review |
## 🥞 Stacked PR Use this [link](https://github.com/unitycatalog/unitycatalog/pull/2020/files) to review incremental changes. - [**stack/ep3-helm-release**](#2020) [[Files changed](https://github.com/unitycatalog/unitycatalog/pull/2020/files)] ← _this PR_ - [stack/ep3-helm-docs](#2021) [[Files changed](https://github.com/unitycatalog/unitycatalog/pull/2021/files/22d5742dcd3de2ec7784ec335f32eb4aca321559..dc242459fb5b9bf7e5ddd757cb988fad092be25e)] - [stack/ep3-helm-graceful-shutdown](#2060) [[Files changed](https://github.com/unitycatalog/unitycatalog/pull/2060/files/dc242459fb5b9bf7e5ddd757cb988fad092be25e..21484d93c12f0b49af7b37cb86f5905983d85588)] - [stack/ep14-helm-readyz](#2063) [[Files changed](https://github.com/unitycatalog/unitycatalog/pull/2063/files/21484d93c12f0b49af7b37cb86f5905983d85588..c2bc7a8976ff0757c1b79d22724a4df534608453)] --------- **Description of changes** The chart has been version `0.0.1-pre.1` with app version `main` since May 2025. A default install therefore runs the `main` server image, a March 2026 development build, and there is no published chart: users clone the repository and install from the folder (#1058, #1025). This PR makes the chart releasable: - **Published name:** the chart is named `unitycatalog-chart`, to be published at `oci://registry-1.docker.io/unitycatalog/unitycatalog-chart`. Docker Hub stores a chart in a repository named after the chart, and `unitycatalog/unitycatalog` already holds the server image. - **Versions from the release:** `Chart.yaml` keeps placeholder versions. `helm/package-chart.sh X.Y.Z` packages chart X.Y.Z with app version `vX.Y.Z`, so a release chart runs that release's server image by default. It rejects a version with a leading `v`, which would point at a `vvX.Y.Z` image. - **UI version:** the UI image keeps the chart's default tag, the app version. Chart X.Y.Z runs `unitycatalog/unitycatalog:vX.Y.Z` and `unitycatalog/unitycatalog-ui:vX.Y.Z`, and each release publishes both. - **README:** install from the OCI registry, which needs Helm 3.8 or later. - **Package contents:** `.helmignore` excludes `*.sh`, so `package-chart.sh` and `generate-docs.sh` don't ship in the published chart. The README drops the version badges, which showed the `0.0.0-dev` and `main` placeholders in a released chart. - **CI:** the workflow packages the chart with the same script and installs that package. Both image tags come only from the version the script stamps. - **Pinned helper images:** the Alpine and busybox helper images move from `latest` to `alpine:3.24.2` and `busybox:1.37.0`, pinned by digest, so every install of a release runs the same images. Each release updates them to the latest stable release (step in #2021's `RELEASING.md`). **User impact.** The published chart is named `unitycatalog-chart`, but resource names don't change: the name helpers fall back to `unitycatalog`, the chart's old name, instead of the chart name. Release `unitycatalog` still creates `unitycatalog-server`, so an install from a cloned folder upgrades in place and keeps its database volume and signing key, with no `nameOverride`. The default is in the helpers rather than `values.yaml`, so a `helm upgrade --reuse-values` keeps it too. I checked with `helm template` that `main`'s chart and this one give the same resource names, apart from the new test pod. **Before the first release.** Docker Hub has only `unitycatalog-ui:main` (May 2025, which predates bun), which the chart starts with yarn (#2019). Each release publishes `unitycatalog-ui:vX.Y.Z`, built with bun (steps in #2021); 0.8.0 is the first. **Tests:** on kind, the chart packaged by `package-chart.sh 0.0.0-ci` ran `unitycatalog:v0.0.0-ci` (built from source) and `unitycatalog-ui:v0.0.0-ci` with no tag override, and `helm test` passed. CI installs that package with the chart's default values, so the UI runs too. `package-chart.sh` rejects `v0.8.0`, `0.8` and `foo`, and accepts `0.8.0`, `0.8.0-rc0` and `0.0.0-ci`. <details><summary><b>📐 Design notes & details</b></summary> **Why placeholders instead of keeping `Chart.yaml` in sync with `version.sbt`.** The release version passed to the script is the only source, so there's no second file to keep in sync and nothing to compare. The Unity Catalog images rendered after packaging 0.7.0: ``` unitycatalog/unitycatalog:v0.7.0 unitycatalog/unitycatalog-ui:v0.7.0 ``` **Why chart version = Unity Catalog version.** A user who asks for chart 0.8.1 expects server 0.8.1. The cost is that a chart-only fix ships with the next release. **Why the UI uses the server's version.** Releases are published by hand. A separate UI version would add a decision and a pin bump to every release, and CI couldn't test a pinned tag before it was published. Rebuilding an unchanged UI image for a release takes a few minutes. **Why not a separate Docker Hub namespace for charts** (for example `unitycatalogcharts/unitycatalog`): - Docker Hub namespaces allow only lowercase letters and digits, and repositories can't be nested. - The `unitycatalog` organization's open-source program benefits apply per organization, and a new organization would start without them. **CI step.** Both images are loaded into kind only as `unitycatalog:v0.0.0-ci` and `unitycatalog-ui:v0.0.0-ci`, with `pullPolicy: Never`. If the stamping broke (for example, the app version stayed `main`), the pods couldn't start and the install would fail. **Pinned helper images.** The chart's helper images used `latest`, so CI and every install could pull different bytes from one run to the next. Tags move too: `busybox:1.37.0` was rebuilt under the same tag on 2026-09-23. They are now pinned by digest: `alpine:3.24.2@sha256:294b…` for the config init container and the create-users job, and `busybox:1.37.0@sha256:bdf5…` for the UI init container. The config init container still runs `apk add` at start (signed packages; versions follow Alpine 3.24); building those tools into an image is a separate change (#1019). The security review of the CI build is in #2019. **Measured with auth on** (kind, `auth.users` set): the create-users job ran on the pinned Alpine, created `[email protected]` and granted CREATE CATALOG. `GET /api/2.1/unity-catalog/catalogs` returned 401 without a token and 401 with a forged token. </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! - [ ] 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]>
3675b0a to
74e603c
Compare
|
/review |
74e603c to
2af8c89
Compare
|
/review |
2af8c89 to
abdb38e
Compare
The chart set the container port from server.deployment.port but never passed it to the server, which kept listening on 8080. Pass --port on every install, and add --obs-port only when obsPort is set. Co-authored-by: Isaac <[email protected]> Signed-off-by: Shubham Bansal <[email protected]>
|
/review |
Address the AI review on unitycatalog#2063: - Say in values.yaml that the chart starts the server image with ./bin/start-uc-server, so a custom image must provide it, and that server.deployment.port is the port the server listens on. - Note in the Helm guide that the liveness probe checks /livez with obsPort. - The obsPort == port check now fails only on the guard's own message. 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, this addresses everything. Passing --port on every install is a nice fix.
One thing the --port change exposes: helm/templates/server/create-users-job.yaml (lines 53-85, not in this diff) builds all five URLs from the Service hostname plus server.deployment.port. But the Service listens on server.service.port and forwards to the api container port. Before this PR nobody could run with deployment.port other than 8080, so it never showed. Now deployment.port: 9000 with the default service.port: 8080 gives a healthy pod, and the job calls <svc>:9000 and never connects. test-connection.yaml, the UI's nc wait and httpRoute.yaml already use server.service.port. Can we switch the job to .Values.server.service.port here, since this PR is what makes port usable?
LGTM once that's in.
There was a problem hiding this comment.
Thanks @shba24 for the PR, looks like it's gone through some rounds of changes -- one comment from me.
The job reaches the server by its Service hostname, which listens on server.service.port, but built its URLs from server.deployment.port. Now that the server listens on server.deployment.port, any value other than the Service port broke the job. Use server.service.port, as test-connection, the UI and the HTTPRoute already do. Co-authored-by: Isaac <[email protected]> Signed-off-by: Shubham Bansal <[email protected]>
The chart now always sets the container command, which replaces the image's ENTRYPOINT. Add server.deployment.command, defaulting to ./bin/start-uc-server, so an image that starts through its own wrapper can keep it. The chart still passes --port and --obs-port as args. Co-authored-by: Isaac <[email protected]> Signed-off-by: Shubham Bansal <[email protected]>
|
@yili-db Done in 51541c9: the create-users job's five URLs now use Also in b83603c, for Tim's comment: |
|
/review |
An upgrade with --reuse-values from a release made before server.deployment.command existed has no value for it, so the server container rendered command: null with --port as args, and Kubernetes tried to run --port. Fall back to ./bin/start-uc-server when the value is null or empty. The create-users check now uses a non-default Service port, so a hard-coded 8080 can't pass. Co-authored-by: Isaac <[email protected]> Signed-off-by: Shubham Bansal <[email protected]>
|
/review |
…2045) ## 🥞 Stacked PR Use this [link](https://github.com/unitycatalog/unitycatalog/pull/2045/files) to review incremental changes. - [**stack/uc-flyway-schema**](#2045) [[Files changed](https://github.com/unitycatalog/unitycatalog/pull/2045/files)] ← _this PR_ - [stack/uc-upgrade-adopt](#2112) [[Files changed](https://github.com/unitycatalog/unitycatalog/pull/2112/files/dfe03066ca3f748f42b916b6908d7ad23e50b7af..187be0b86367b2fe7cb3db852b33039bb534bbfe)] - [stack/uc-upgrade-merge-checks](#2113) [[Files changed](https://github.com/unitycatalog/unitycatalog/pull/2113/files/b2982d514290d5a7cbb70010c31686d681f732d0..837c49999da9d021a385b5878dd5724f902b8ac0)] - [stack/uc-upgrade-retry](#2114) [[Files changed](https://github.com/unitycatalog/unitycatalog/pull/2114/files/86b2b75709c1378fb7d199dabf453033849885c1..6aed4147e2b76bc45b076c5d1769a85461d9aaaf)] - [stack/uc-upgrade-check-schema](#2115) [[Files changed](https://github.com/unitycatalog/unitycatalog/pull/2115/files/8ba3b07ae080f5d07518392679ddba696074afab..b7a8d07fbeae61d80e3518336ad7290b20cd6770)] - [stack/uc-sample-database-built](#2116) [[Files changed](https://github.com/unitycatalog/unitycatalog/pull/2116/files/6a59493c75da317dfde80776cd29f6ae030eeabf..4221ea5224ceaf8b1122c0b00ba41eeaa6003840)] - [stack/uc-flyway-owns-schema](#2117) [[Files changed](https://github.com/unitycatalog/unitycatalog/pull/2117/files/ccb5e69e8b53596d6f2925797970c9828505edba..b1e7a896aa2e48163e9a750265d99abf69c52371)] - [stack/uc-hibernate-fallback](#2118) [[Files changed](https://github.com/unitycatalog/unitycatalog/pull/2118/files/861ca93eabac0bee2f40ebd4d0976dfd964929cf..0ed55964bab3e0d505fc330f41cdf00c48ff40b9)] --------- This PR adds Unity Catalog's database schema as Flyway steps, and a command that you run by hand to apply them: `bin/start-uc-server --upgrade-schema`. The command is optional for now. The server still sets up and updates its schema with Hibernate when it starts. This PR now only adds the steps and the manual command. The rest of what this PR held at the last review moved to the next PRs of the stack: adopting existing databases to #2112, the merge checks and contributor rules to #2113, the built sample database to #2116, and the start-time schema check, the Hibernate refusals, the Helm init container and the step-built test schemas to #2117. "What moved out of this PR" in the details lists each piece. ### What you see - The schema is a list of steps for each supported database: H2, PostgreSQL and MySQL. Step 1 is the schema of release 0.7.0. Step 2 widens the function parameter type column (#2013). - `bin/start-uc-server --upgrade-schema` applies the steps that are not applied yet, records each one in the `uc_schema_history` table, and exits without starting the server. It exits with 0 and prints `The database schema is at version 2.` on success, and exits with 1 and prints the reason otherwise. - It sets up an empty database, also one that holds only other applications' tables, which it leaves alone. It upgrades a database that it set up earlier. - It refuses, and changes nothing, in these cases: - The database has Unity Catalog's tables but no schema history, for example one that a server set up at start. The message says that adopting such a database is not supported yet; #2112 adds it. - The database's schema is newer than this release. - Flyway's check of the schema history fails, for example after a failed step. - The configuration uses H2 in server mode, `hibernate.default_schema` or `hibernate.default_catalog`, an in-memory database, or a database other than H2, PostgreSQL and MySQL, or a configuration file is missing. - On PostgreSQL and MySQL, a run lock lets only one command apply steps at a time. A second command waits for the first. - The new page `docs/server/upgrades.md` describes the command, backups, the lock, and the messages. ### What doesn't change yet - Server start still runs Hibernate's `update` (`hibernate.hbm2ddl.auto=update` in `etc/conf/hibernate.properties`), and the Helm chart still sets it. The steps build the same schema that Hibernate builds from the entities, so on a database that the steps set up, Hibernate changes nothing. - The test suite still builds its schemas with Hibernate, and the sample database `etc/db/h2db.mv.db` is the same as on `main`. - #2117 makes the steps the only way the schema changes. ### Tests Ran locally on H2: compiled all modules and their tests with checkstyle, and ran the schema migration tests, the option parser, Hibernate configurator and key mapper tests, and the catalog SDK tests (46 passed). The four run-lock tests skip on H2, which takes no run lock; they ran locally on PostgreSQL 18 and MySQL 8 only at the top of the stack (#2118). CI runs the full suite on H2, PostgreSQL 18 and MySQL 8. <details><summary><b>📐 Design notes & details</b></summary> ### Design - `SchemaMigrator` classifies the database from its `uc_*` tables only: `EMPTY` (no `uc_*` table), `CURRENT`, `PENDING`, `AHEAD`, or `UNVERSIONED_UC` (Unity Catalog's tables without history). Other applications' tables, such as Casbin's, don't count, so the steps run next to them. On a database with only other tables, Flyway records a baseline at version 0, below step 1, so that step 1 runs. - `upgradeSchema()` is a plain Flyway run under the run lock: refuse `AHEAD` and `UNVERSIONED_UC`, validate the history, migrate, then check that the database ends `CURRENT` with a valid history. Retrying a run that stopped part way comes in #2114. - Every statement of step 1 skips what is already there (for example `create table if not exists`), so that a later run can run it again after a run that stopped in the middle. #2114 relies on this. - The run lock covers the whole run, from classifying the database to the last step; Flyway's own lock is taken per step. PostgreSQL uses `pg_advisory_lock` on a fixed key, and MySQL uses `GET_LOCK` on a name derived from the database name. H2 takes no lock, because one process opens an H2 file; for the same reason H2 in server mode (`AUTO_SERVER`, `jdbc:h2:tcp:`, `jdbc:h2:ssl:`) is refused. The lock lives on one database session, so a pooler in transaction mode (PgBouncer `pool_mode = transaction`) is not supported for the command. A failed lock release closes the connection underneath the pooled one, which ends the session and so releases the lock. - The migrator opens its own pool of 4 connections (the lock's connection, Flyway's two on PostgreSQL, and one for reading the schema) and closes it at the end, so the server's pool size doesn't limit it. - The database kind comes from the name that its JDBC driver reports, not from the URL, so wrapping drivers (`jdbc:aws-wrapper:`, `jdbc:p6spy:`) and pools set up with `hibernate.hikari.dataSourceClassName` work. - Metadata lookups pass the configured schema as an exact pattern (`exactPattern`), since `_` and `%` are wildcards there and `uc_a` would also match `ucxa`. - `hibernate.default_schema` and `hibernate.default_catalog` are refused, also from JVM system properties, because Flyway uses the connection's schema. Set the schema in the JDBC URL instead. In this PR only the command refuses them; #2117 adds the same refusal at server start. - `HibernateConfigurator` gains only helpers here: `hikariConfig()` (the pool settings without opening a pool), `requireSchemaFromConnection()`, and a `setupHibernateProperties()` overload that takes the file path. - Build: the shaded jar merges Flyway's ServiceLoader file; other service files are still dropped. The launcher classpath leaves out the project's class directory, because the jar holds the same steps and Flyway would find each one twice. - `BaselineMatchesEntitiesTest` checks that the steps build the schema that Hibernate builds from the entities. It runs in the normal suite here; #2113 moves it behind `UC_TEST_MIGRATION_CHECKS=true` with the other step checks. - Test plumbing for the migrator tests: `@TempDatabase(empty = true)`, `TestDatabase.dataSource()`, `newEmptyDatabase`, and H2 file databases. The normal suite still builds its schema with Hibernate's `update`. - `deployment.md`: the MySQL collation advice now changes the database default together with every table, so that tables that later steps create also get the binary collation. ### Test coverage - `SchemaMigratorTest`: an empty database, one with only the authorization rules table, one next to another application's tables, a wrapping driver, a pool set up by data source class, a versioned database with a pending step, reading only the configured schema, and the refusals of a database without history, a newer schema, a failed step, and H2 server mode. Run-lock tests on PostgreSQL and MySQL: two runs on an empty database take turns, a refused lock, and a lock that is not released. - `SchemaGateTest`: the command sets up the configured database, and refuses a missing `server.properties` or `hibernate.properties`, an in-memory database and `hibernate.default_schema`. - `OptionParserTest`: `--upgrade-schema`. - 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. ### What moved out of this PR Compared with the head at the last review (ae832c1): - To #2117: - Running the steps at server start. It is now a start-time check (`requireCurrentSchema()`) that refuses a database not at this release's schema; the command applies the steps. - The Hibernate schema-action refusals in `HibernateConfigurator` (`requireNoSchemaChanges`, `isSchemaAction`, `isNone`, `withSchemaUpdatesOff`, the constructor checks, and `setupHibernateProperties` turning `update` into `none`). - `etc/conf/hibernate.properties` without `update`. - The removal of `hibernate.hbm2ddl.auto=update` from the Helm chart's `_config.tpl`. This PR reverts ae832c1's last commit, so the chart is as on `main`. - Building every test database's schema with the steps: `TemplateDatabases`, `TestDatabases.h2`/`runSteps`, `MySqlDatabases`, `TestDatabase` with `hbm2ddl` set to `none`, `KeyMapperTest` with `@TempDatabase`, and the `BaseAccessControlCRUDTest` comment. - `HibernateConfiguratorTest.neverLetsHibernateChangeTheSchema` and `refusesHibernatesOwnDefaultSchema`, and the start-time tests in `SchemaGateTest`. - To #2112: - Adopting a 0.7.0 database as version 1 (`BASELINE_VERSION`, `baselineFor`). It now adopts only on an exact schema match. - `ADOPTED_RELEASE` and `adoptsABaselineDatabase`. - The real-release tests: `RealUpgradeTest`, `OldServer`, `DataSet`, `TestServer`, `upgrade-tests.yml`, and the Vert.x test dependency. - `SchemaSnapshot`, which moves to the main code. - To #2116: the migrated `etc/db/h2db.mv.db` and the `PopulateTestDatabase` call that ran the steps. The sample database is now built (`SampleDatabase`); this PR keeps `main`'s file. - To #2113: the schema-change rules in `AGENTS.md`, `CODE_REVIEW.md` and the AI reviewer's `REVIEW.md`. - Removed, not moved: - `BEFORE_BASELINE`, `BASELINE_TABLES`, `missingBaselineTables` and `refusesADatabaseFromBeforeTheBaselineRelease`. #2112's schema comparison replaces them; its refusal says that a database from before 0.7.0 must be started on a 0.7.0 server first. - `NOT_UC` and `refusesADatabaseOfAnotherApplication`. `setsUpADatabaseNextToAnotherApplicationsTables` replaces them: other applications' tables are left alone. - The H2 lock inside the JVM, `acceptsHibernatesNoneActionObject`, and the schema-versions table in `upgrades.md`. - Kept in this PR: `exactPattern` and the fix that reads only the configured schema's tables (a80afaa), the H2 server-mode refusal, the lock tests, `refusesADatabaseWithAFailedStep`, `migrate()` (now named `upgradeSchema()`), the pool size (now 4 instead of 3), and step 1 written so that it can run again. ### Stack Part 1 of 8 of the schema-upgrade stack: 1. #2045 [Server] Add the schema steps and a manual --upgrade-schema command (this PR) 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 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]>
## 🥞 Stacked PR Use this [link](https://github.com/unitycatalog/unitycatalog/pull/2112/files/dfe03066ca3f748f42b916b6908d7ad23e50b7af..187be0b86367b2fe7cb3db852b33039bb534bbfe) to review incremental changes. - [stack/uc-flyway-schema](#2045) [[Files changed](https://github.com/unitycatalog/unitycatalog/pull/2045/files)] - [**stack/uc-upgrade-adopt**](#2112) [[Files changed](https://github.com/unitycatalog/unitycatalog/pull/2112/files/dfe03066ca3f748f42b916b6908d7ad23e50b7af..187be0b86367b2fe7cb3db852b33039bb534bbfe)] ← _this PR_ - [stack/uc-upgrade-merge-checks](#2113) [[Files changed](https://github.com/unitycatalog/unitycatalog/pull/2113/files/b2982d514290d5a7cbb70010c31686d681f732d0..837c49999da9d021a385b5878dd5724f902b8ac0)] - [stack/uc-upgrade-retry](#2114) [[Files changed](https://github.com/unitycatalog/unitycatalog/pull/2114/files/86b2b75709c1378fb7d199dabf453033849885c1..6aed4147e2b76bc45b076c5d1769a85461d9aaaf)] - [stack/uc-upgrade-check-schema](#2115) [[Files changed](https://github.com/unitycatalog/unitycatalog/pull/2115/files/8ba3b07ae080f5d07518392679ddba696074afab..b7a8d07fbeae61d80e3518336ad7290b20cd6770)] - [stack/uc-sample-database-built](#2116) [[Files changed](https://github.com/unitycatalog/unitycatalog/pull/2116/files/6a59493c75da317dfde80776cd29f6ae030eeabf..4221ea5224ceaf8b1122c0b00ba41eeaa6003840)] - [stack/uc-flyway-owns-schema](#2117) [[Files changed](https://github.com/unitycatalog/unitycatalog/pull/2117/files/ccb5e69e8b53596d6f2925797970c9828505edba..b1e7a896aa2e48163e9a750265d99abf69c52371)] - [stack/uc-hibernate-fallback](#2118) [[Files changed](https://github.com/unitycatalog/unitycatalog/pull/2118/files/861ca93eabac0bee2f40ebd4d0976dfd964929cf..0ed55964bab3e0d505fc330f41cdf00c48ff40b9)] --------- `bin/start-uc-server --upgrade-schema` now adopts an existing database: one that has Unity Catalog's tables but no schema history, such as a 0.7.0 database or one that a server of this release set up at start with Hibernate. Before this PR, the command refused such a database. ### What you see - A database whose schema is exactly the schema of version 1 (release 0.7.0) gets step 1 recorded without running it, and the later steps run. - A database whose schema is exactly this release's schema gets every step recorded without running it. A server of this release that set up a new database at start leaves such a schema. - Any other schema is refused, with one line for each difference from version 1, and the hint that a database from before 0.7.0 must be started on a 0.7.0 server first. For example, after someone added a column by hand: ```console The database has no schema history, and its schema is neither the schema of version 1 nor that of version 2. It differs from version 1 in: unexpected column uc_catalogs.extra ... ``` - At the end of every run, the command compares the whole schema with the schema that the steps build, and fails with the differences if they don't match. - `docs/server/upgrades.md` describes the baseline release, how to repair a database from before 0.7.0 (two CHECK constraints differ; the page gives the SQL for each database), and why not to start 0.7.0 again on an upgraded database. ### What doesn't change yet - Server start still runs Hibernate's `update`, and the command is still optional and run by hand. #2117 switches that. ### Tests Ran locally on H2: compiled all modules and their tests with checkstyle, and ran the schema migration tests and the catalog SDK tests. The real-release upgrade tests need `UC_TEST_UPGRADES=true` and did not run locally; the new path-filtered workflow runs them in CI on H2, PostgreSQL 18 and MySQL 8. CI also runs the full suite on all three databases. <details><summary><b>📐 Design notes & details</b></summary> ### Design - Adoption needs an exact match. A database that matches neither version 1 nor the latest version can't be told apart from one that someone changed by hand, so the command refuses it and lists the differences instead of guessing. - To compare schemas, `SchemaSnapshot` moves from the tests to the server, and renders what a one-statement step can change: CHECK constraints by clause, MySQL enum values, column collations, numeric scale, foreign key rules, descending index columns, and PostgreSQL's partial indexes. It reads only Unity Catalog's `uc_*` tables, so the test-only step's table is now `uc_test_only_step`. - Each step has an effect file per database, `schema-effects/<database>/V<n>.txt`, that lists what the step changes. The schema of a version is the sum of the effect files up to it (`SchemaMigrator.expected()`). The effect files ship in the server jar, so the installed command compares without building a reference database. - `MigrationStepRulesTest.eachStepHasItsEffectFile` checks each effect file against what the step does on a new database. `build/sbt updateSchemaDumps` rewrites the files on all three databases (PostgreSQL and MySQL need Docker). This test lands here, not in #2113, because the effect files and the rendering must exist before #2113 freezes merged effect files. - The record-without-running uses Flyway's `target` with `skipExecutingMigrations`, so Flyway writes the history records itself. - `adoptsADatabaseWithThisReleasesSchemaWithoutHistory` is a temporary test: it drops the history table to stand in for a database that Hibernate set up. #2118 removes it, because its hibernate-mode tests cover the same case with a real Hibernate setup. - `docs/server/upgrades.md` also says why not to start 0.7.0 on an upgraded database: its Hibernate `update` narrows the column that step 2 widened, while the history still records step 2. ### Test coverage - `SchemaMigratorTest`: adopts a version 1 database, adopts a database with this release's schema, and refuses a version 1 database with an extra column. - `SchemaSnapshotTest`: tells apart schemas that differ only in each rendered detail (some rows run only on PostgreSQL or MySQL), applies an effect file with no changes, and counts duplicate checks once. - `RealUpgradeTest` (`UC_TEST_UPGRADES=true`, workflow `upgrade-tests.yml`): each release tag from 0.7.0 up to, but not including, this build's version writes a data set, then this build upgrades the database and reads every copy back. A database that 0.4.0 set up and 0.7.0 upgraded is refused, then repaired with the documented SQL (`db/repair-0.7.0/*.sql`) and upgraded. This build's shaded jar sets up an empty database with `--upgrade-schema` and serves it. `OldServer`, `DataSet` and `TestServer` support it; the Vert.x test dependency is there because older releases read Vert.x's version file at start. - 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, and before #2045 added `refusesADatabaseWithAFailedStep`. CI runs on the merged head. ### Stack Part 2 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 (this PR) 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 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]>
## 🥞 Stacked PR Use this [link](https://github.com/unitycatalog/unitycatalog/pull/2114/files) 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)] ← _this PR_ - [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)] - [stack/uc-hibernate-fallback](#2118) [[Files changed](https://github.com/unitycatalog/unitycatalog/pull/2118/files/0a120a3c682986c926845a85ad249df1720e5d4c..97bc44b5dfb75eb27fdddc33db6ea208680234ac)] --------- `bin/start-uc-server --upgrade-schema` can now be run again after a run that stopped part way, for example after a crash, a lost connection, or a step that failed. Before this PR, it refused a database with a failed step, and you had to restore the backup. ### What you see - The command applies the pending steps one at a time. Before each step, it compares the whole schema with the schema before and after that step: - If the schema is the one before the step, the step runs. - If the schema already has the step's change, the step is recorded without running. That is the schema after the step (a run that stopped before Flyway recorded it) or after a later step (a database without schema history at a later step, such as one that Hibernate updated). - Otherwise the command stops, changes nothing more, and lists the differences from the nearer of the two versions. - Step 1 also runs again after an earlier run of it stopped part way, because its statements skip what is already there. - If the schema history is otherwise valid, the record of a step that failed (H2 and MySQL keep one) is deleted once the schema check accepts the step, so that the step is tried again. A run that the schema check or Flyway's history check refuses keeps the record, and the command stops. - `docs/server/upgrades.md` says to fix the cause that the command names and run the same command again. For example, on MySQL, if the database connection drops after step 2 changed the column but before Flyway recorded step 2, the next run logs `Recorded schema step 2 without running it: the database already has its change`. ### What doesn't change yet - Server start still runs Hibernate's `update`, and the command is still optional and run by hand. #2117 switches that. ### Tests Ran locally on H2 with `UC_TEST_MIGRATION_CHECKS=true`: compiled all modules and their tests with checkstyle, and ran the schema migration tests, including the sweep that stops a run at every statement of every step, and the catalog SDK tests. The same sweep ran locally on PostgreSQL 18 and MySQL 8 at the top of the stack (#2118). CI runs it in the "All tests" rows, which set `UC_TEST_MIGRATION_CHECKS`. <details><summary><b>📐 Design notes & details</b></summary> ### Design - The retry decision (`runs()`) uses the effect files from #2112: the schema of version `n-1` means run step `n`, the schema of version `n` means record it. This works because #2113 keeps each later step to one statement, so a step is either fully there or not there at all. Step 1 is the exception: it has many statements, so a partial step 1 under an existing history table runs again. - Recording uses Flyway's `target(step)` with `skipExecutingMigrations`, one step per Flyway call. After each call, the command checks that exactly that one step was recorded, and stops otherwise. - During an upgrade, the history check ignores Flyway's failed-step error, and only that one, so that the record can be deleted. Any other error, such as an edited step, still stops the run and keeps the record. - Failed records are deleted with plain SQL on a connection that commits by itself, after the history is validated. The caller's pool may not commit by itself, and a rollback would keep the record. The connection's previous auto-commit setting is put back afterwards, as it is for the run lock's connection. Flyway's `repair` would also rewrite the other records' checksums, which would hide an edited step. - The refusal message names the nearer version (by the size of the difference list), so the operator sees the shorter, more useful list. It adds the pre-0.7.0 hint only when the database has no history. - `refusesADatabaseWithAFailedStep` (from #2045) is removed: a failed step is now tried again. `runsAgainAFailedStepOnTheConfiguredPool` and `keepsTheRecordOfAFailedStepWhenTheHistoryIsRefused` cover both sides. ### Test coverage - `SchemaMigratorTest`: runs a failed step again, keeps a failed record when the history is refused, runs again after a run that stopped in a step (before and after its record), runs step 1 again after it stopped part way, and refuses a step when the schema is neither before nor after it. - `everyStepRunsAgainAfterARunThatStoppedInIt` (`UC_TEST_MIGRATION_CHECKS=true`): for every step of this build, stops a run at each of its statements and between its last statement and its history record, then checks that the next run ends with a new install's schema. `failingAt` and the watcher helpers in `UpgradeTestUtils` make the chosen statement or history record fail. - The sweep in `SchemaMigratorTest` runs with `UC_TEST_MIGRATION_CHECKS=true`, which the "All tests" rows of Unit Tests set. - 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 4 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 (this PR) 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 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]>
## 🥞 Stacked PR Use this [link](https://github.com/unitycatalog/unitycatalog/pull/2115/files/d4c1b003a0e576debded4b91a28b256d02507f67..0028bc22bb2e6ebd02e11048a2d7560ad023be19) 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)] ← _this PR_ - [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)] - [stack/uc-hibernate-fallback](#2118) [[Files changed](https://github.com/unitycatalog/unitycatalog/pull/2118/files/0a120a3c682986c926845a85ad249df1720e5d4c..97bc44b5dfb75eb27fdddc33db6ea208680234ac)] --------- This PR adds `bin/start-uc-server --check-schema`, which tells you whether `--upgrade-schema` would go through, without changing the database. Run it before an upgrade to find problems early; on PostgreSQL and MySQL, the old servers can keep serving while it runs. ### What you see - `--check-schema` prints the database's schema version, what `--upgrade-schema` would do with each pending step (run it, or record it without running because its change is already there), and whether the upgrade would go through. It runs the same checks on the schema as the upgrade. - It exits with 0 when the upgrade would go through, and with 1 and the reasons otherwise. - It changes nothing and takes no run lock, so on PostgreSQL and MySQL you can run it with the new release while the old servers still run. H2 lets only one process open the database file, so on H2 stop the server first. - It refuses the same configurations as `--upgrade-schema`, such as a missing configuration file or an in-memory database. - You can pass only one of `--check-schema` and `--upgrade-schema`. - `docs/server/upgrades.md` adds the check as a step of the upgrade procedure. For example, on an empty database: ```console $ bin/start-uc-server --check-schema Database schema version: none; this release ends at 3. Pending steps: 1 baseline 0 7: runs 2 widen function param type json: runs 3 s3 compatible credential type: runs The schema allows the upgrade: --upgrade-schema would run the steps above. ``` ### What doesn't change yet - Server start still runs Hibernate's `update`, and both commands are optional and run by hand. #2117 switches that. ### Tests Ran locally on H2 with `UC_TEST_MIGRATION_CHECKS=true`: compiled all modules and their tests with checkstyle, and ran the schema migration tests, the option parser tests and the catalog SDK tests. CI runs the full suite on H2, PostgreSQL 18 and MySQL 8. <details><summary><b>📐 Design notes & details</b></summary> ### Design - `checkSchema()` walks the pending steps with the same decision as the upgrade (`runs()` from #2114), but against the expected schema after each step instead of a real run, then compares the result with the schema of the last version. A step that failed counts as pending, because the upgrade deletes its record first. - It takes no run lock, so a run in progress can change the answer. That trade-off lets it run next to serving servers on PostgreSQL and MySQL. - `runCommand(boolean upgrade, ...)` serves both options, so the configuration refusals are shared. In `OptionParser`, an `OptionGroup` makes the two options exclusive. - The upgrade's refusal of a step that was not recorded as its run's only change now points at `--check-schema` to see the database's state. ### Test coverage - `SchemaMigratorTest`: checks an empty database without changing it, a versioned database with a pending step, a failed step as one to run again (the failed record stays), and a database whose schema differs (exit 1). - `SchemaGateTest`: both commands refuse each bad configuration. - `OptionParserTest`: parses each command, and refuses both at once. - 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 5 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 (this PR) 6. #2116 [Build] Build the sample database instead of checking it in 7. #2117 [Server] Let only the schema steps change the schema 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]>
## 🥞 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]>
PR Checklist
docsis updatedDescription of changes
The server's health endpoints (
/livez,/readyz) are only served when it starts with--obs-port, and the chart had no way to pass it. The chart's probes only checked that the API port accepted a TCP connection, so a pod could receive traffic while the server couldn't reach its database.This PR:
server.deployment.obsPort. It is unset by default, like the server's--obs-portflag. When set, the server starts with--obs-porton that port, and the readiness and liveness probes, when turned on, check/readyzand/livez;server.deployment.portto the server as--port. The chart used it only for the container port, so with any value other than 8080 the server kept listening on 8080 and the pod failed its startup probe;server.deployment.command, defaulting to./bin/start-uc-server. Kubernetes runs it instead of the image'sENTRYPOINT, so an image that starts through its own wrapper can set it;server.service.port. It reached the server through the Service but usedserver.deployment.port, which only worked while both were 8080;obsPortthey check the API port, as they already did;livenessProbe,readinessProbeandstartupProbevalues (server and UI). Until now they rendered the whole chart context instead of the probe;obsPort=8090and the readiness probe on, so the kind test exercises/readyz.📐 Design notes & details
Why
obsPortis optional. The observability endpoints are off unless the server is given--obs-port, and the chart follows that. It also keeps a chart installed from a source checkout working: its default image tagmainpoints to a Docker Hub image older than v0.7.0, which rejects--obs-port. Ahelm upgrade --reuse-valuesfrom a release without the value also keeps working, with observability off.Example.
This renders
command: ./bin/start-uc-serverwithargs: --port "8080" --obs-port "8090", anobscontainer port, and a readiness probe on/readyz(period 10s,failureThreshold: 3). The startup probe already covers slow starts, so readiness can react within about 30s when the database becomes unreachable. WithoutobsPort, the probes keep their earlier TCP checks and timings.Compatibility.
command: ./bin/start-uc-serverandargs: --port "8080". That is the image's ownCMDplus its default port, so it starts the same way. Because a pod'scommandreplaces the image'sENTRYPOINT, an image with its ownENTRYPOINTwrapper should setserver.deployment.commandto it. When the value is null or empty, as after ahelm upgrade --reuse-valuesfrom a release made before it existed, the chart falls back to./bin/start-uc-server.obsPortset, the server image must be v0.7.0 or later.Network exposure. The observability endpoints are unauthenticated, and the server binds the port on all interfaces. The value's description says that other pods can reach it on the pod IP, suggests a NetworkPolicy, and notes that the kubelet must be allowed through for the probes. The Service doesn't expose the port.
Precedent. Apache Polaris's chart runs a management port with health and metrics endpoints, and its probes check it.
Probe override fix. The templates read
{{- if .Values.server.deployment.readinessProbe }} readinessProbe: {{- toYaml . }}.ifdoesn't rebind., sotoYaml .dumped the whole render context. They now usewith, in all six places (server and UI).CI render step (in
helm-chart-tests.yml) checks:obsPort:--portfollowsport, there is no--obs-port, and the readiness probe, when on, checks the API port;obsPort=9099: the--obs-portarg, thecontainerPort, and/readyzand/livezprobes on portobs;obsPortequal toportfails the render with the guard's message;commandis./bin/start-uc-server,server.deployment.commandreplaces it, and a null value falls back to the default;portdiffers from it;Capabilities,ReleaseorValueskeys;terminationGracePeriodSeconds: 0is kept ([Helm] Add lifecycle and terminationGracePeriodSeconds for the server pod #2060).I ran it locally with Helm 3.20.0. It passes on this chart and fails when each bug is put back: an always-on
--obs-port, no--portor--portonly withobsPort, noobsPortguard, a default probe onapi,ifinstead ofwithin any of the six probes, a hard-codedcommand, the job onserver.deployment.port, orwithfor the grace period.Docs and validation.
docs/server/helm.mdgets a short Health checks section, which notes the v0.7.0 requirement. The chart fails at render ifobsPortequalsport, since the server would refuse to start.Other checks.
helm lintpasses.helm/README.mdwas regenerated with helm-docs v1.14.2.--obs-port 8090answers/readyzand/livezwith 200 on 8090, and/readyzwith 404 on the API port.Not changed here. The
nameOverriderow inhelm/README.mdshowsnull: that is what helm-docs v1.14.2 renders for the annotation from #2020, and CI's README freshness check passes.This pull request and its description were written by Isaac.