Repository navigation
[Helm] Upgrade the schema safely with helm upgrade: Recreate, a pre-upgrade check, MySQL, backup - #2054
Closed
shba24 wants to merge 129 commits into
Closed
[Helm] Upgrade the schema safely with helm upgrade: Recreate, a pre-upgrade check, MySQL, backup#2054shba24 wants to merge 129 commits into
shba24 wants to merge 129 commits into
Conversation
The UI moved from yarn to bun (unitycatalog#1732), but the chart still starts it with `yarn start`. Yarn 1 refuses to run because package.json declares `packageManager: bun@...`, so the UI pod crash-loops on any image built from the current ui/ directory. The published unitycatalog-ui:main image (May 2025) predates bun and still needs `yarn start`, so after this change the chart needs a UI image built from today's ui/; the next PR pins one. - Start the UI with `bun run start`. - Add a Helm test hook that checks the server API, the UI page and the UI's /api proxy (API checks only when auth is off), and names the check that failed. Its busybox image is pinned by digest. - Add a Helm Chart Tests workflow for pull requests: helm-docs freshness (failing on any change under helm/), ct lint, and a helm install plus helm test on kind with server and UI images built from the same commit. It uses no secrets, runs only on pull requests so it can't write caches that main reads, and pins uv, kind, the kind node image and kubectl. - Regenerate the chart README (it missed the unitycatalog#1689/unitycatalog#1690 values) and fix the two yamllint errors in values.yaml (whitespace only). Co-authored-by: Isaac <[email protected]> Signed-off-by: Shubham Bansal <[email protected]>
The published unitycatalog-ui:main image predates bun, so with bun run start a default install would crash-loop the UI pod until a release publishes a bun-based UI image. A default install now runs only the server; set ui.enabled=true for the UI. CI sets it, so the chart test still checks the UI. Co-authored-by: Isaac <[email protected]> Signed-off-by: Shubham Bansal <[email protected]>
…ute example The helm test pod image now comes from test.image, with test.imagePullSecrets, so a mirrored registry can run helm test. values.httproute.yaml turns the UI on, because the example serves the API and the UI on one hostname and the UI is now off by default. Co-authored-by: Isaac <[email protected]> Signed-off-by: Shubham Bansal <[email protected]>
CI regenerates the README with helm-docs v1.14.2, and the README footer records that version, so a README made with another local version still fails the check. The message now points to the pre-commit hook, which pins the same version. Co-authored-by: Isaac <[email protected]> Signed-off-by: Shubham Bansal <[email protected]>
Pinned by commit SHA, like the other actions in the workflow. Co-authored-by: Isaac <[email protected]> Signed-off-by: Shubham Bansal <[email protected]>
The chart has been 0.0.1-pre.1 with appVersion `main` since May 2025, so a default install runs a development image, and there is no published chart to install without cloning the repository. - Publish the chart as `unitycatalog-chart` (Docker Hub repo names come from the chart name, and `unitycatalog/unitycatalog` is the server image). - Keep placeholder versions in Chart.yaml. `helm/package-chart.sh X.Y.Z` stamps chart version X.Y.Z and appVersion vX.Y.Z, so a release chart runs that release's server image. It rejects a version with a leading v. - The UI image keeps defaulting to the app version, so chart X.Y.Z runs server and UI images vX.Y.Z, and each release publishes both. - Turn the UI off by default: it runs a development server, so it's opt-in with `ui.enabled=true`. CI turns it on to keep testing it. - Pin the helper images by digest (alpine 3.24.2 for the config init container and the create-users job, busybox 1.37.0 for the UI init container) instead of `latest`. - Document installing from the OCI registry (needs Helm 3.8+). - CI packages the chart with the same script and installs that package, with both image tags taken only from the stamped version. Co-authored-by: Isaac <[email protected]> Signed-off-by: Shubham Bansal <[email protected]>
… install example .helmignore now excludes *.sh, so package-chart.sh and generate-docs.sh no longer ship inside the published chart. The README install example uses X.Y.Z instead of a fixed release. Co-authored-by: Isaac <[email protected]> Signed-off-by: Shubham Bansal <[email protected]>
package-chart.sh stamps Chart.yaml but packages the README as generated, so a released chart's README showed the 0.0.0-dev and main placeholder badges. helm show chart gives the real versions. Co-authored-by: Isaac <[email protected]> Signed-off-by: Shubham Bansal <[email protected]>
The deployment page covers only the tarball, and there are no steps for publishing the chart. - Add docs/server/helm.md: install from the OCI registry, open the API and the optional UI, use PostgreSQL, upgrade and uninstall. Link it from the deployment page and the docs nav. - Add helm/RELEASING.md: publish the server and UI images with the release version before the chart, package with helm/package-chart.sh, push to Docker Hub, and check that every image the published chart runs exists. Only the release managers can push to the Docker Hub organization. Co-authored-by: Isaac <[email protected]> Signed-off-by: Shubham Bansal <[email protected]>
The release check now renders the chart with the UI on, so it also checks the UI image. The upgrade guide tells source-checkout installs to set nameOverride: unitycatalog, which keeps the old resource names after the chart rename, and ui.enabled: true to keep the UI. Co-authored-by: Isaac <[email protected]> Signed-off-by: Shubham Bansal <[email protected]>
…efresh The release check now runs Helm with empty Helm and Docker credential files. helm registry logout alone left the docker login credentials in use, so a private chart could pass the check. The guide uses X.Y.Z instead of a fixed release, and says that several replicas with authentication on need server.authorization.policy-refresh. Co-authored-by: Isaac <[email protected]> Signed-off-by: Shubham Bansal <[email protected]>
With PostgreSQL the chart does a rolling update, so even one replica runs next to its replacement during an upgrade; the guide now asks for policy refresh whenever authentication is on with PostgreSQL. RELEASING.md states who pushes to Docker Hub as a rule, since the access is granted outside the repository. Co-authored-by: Isaac <[email protected]> Signed-off-by: Shubham Bansal <[email protected]>
Signed-off-by: Shubham Bansal <[email protected]>
Co-authored-by: Isaac <[email protected]> Signed-off-by: Shubham Bansal <[email protected]>
Adds MySQL 8.4 to the test database harness (testMySQL8) and a CI job. Test databases use the case-sensitive utf8mb4_0900_bin collation. The isolation test now reads the database's default level instead of assuming READ_COMMITTED. Co-authored-by: Isaac <[email protected]> Signed-off-by: Shubham Bansal <[email protected]>
Without an ORDER BY, MySQL returned columns (and function parameters) in its own order. Co-authored-by: Isaac <[email protected]> Signed-off-by: Shubham Bansal <[email protected]>
Storage paths and names are case-sensitive, but MySQL's default collation is not. Log a warning at startup and document the utf8mb4_0900_bin collation. Co-authored-by: Isaac <[email protected]> Signed-off-by: Shubham Bansal <[email protected]>
MySQL and PostgreSQL now share one harness: Hibernate builds the schema once per JVM into a template and each test clones it. Both containers keep their data in memory with durability off. Co-authored-by: Isaac <[email protected]> Signed-off-by: Shubham Bansal <[email protected]>
Fix harness comments and docs, assign the cached database only after it started, drop duplicate test dependencies, request a different isolation level in the restore test, check the MySQL template has every mapped table, and cover parameter order in the function CRUD test. Co-authored-by: Isaac <[email protected]> Signed-off-by: Shubham Bansal <[email protected]>
The MYSQL_8 CI row runs SdkDeltaCommitsCRUDTest on MySQL, so the class that started its own MySQL container is no longer needed. Its lock-reading test moves into SdkDeltaCommitsCRUDTest and runs on every database. Co-authored-by: Isaac <[email protected]> Signed-off-by: Shubham Bansal <[email protected]>
A @TempDatabase field gets a fresh TestDatabase, per test for an instance field and per class for a static one. The extension stores it in the JUnit store, which closes it after every @AfterEach, so a test's server always closes before its database is dropped, and a failing setUp still drops it. TestDatabase no longer takes a ServerProperties (it overwrote everything the properties set) and offers hibernateProperties(), hibernateConfigurator() and sessionFactory(). All tests that made their own database now use the annotation. 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]>
…eSQL containers Co-authored-by: Isaac <[email protected]> Signed-off-by: Shubham Bansal <[email protected]>
…lt_on_error The isolation test asks for a level other than the default, because asking for the default would pass even if nothing were restored. The MySQL template keeps halt_on_error off only for the one index InnoDB rejects; a TODO removes it once the schema migration steps build the template. Co-authored-by: Isaac <[email protected]> Signed-off-by: Shubham Bansal <[email protected]>
Adds Flyway 13.10.3, the V1 baseline of the 0.7 schema and V2 (type_json widening) for H2, PostgreSQL and MySQL; empty test databases, @TempDatabase and TestDatabase.dataSource()/kind() in the harness; and a schema snapshot check that the steps build the schema the entities expect. Co-authored-by: Isaac <[email protected]> Signed-off-by: Shubham Bansal <[email protected]>
Adds Migrator, which classifies a database (empty, current, pending, newer than this release, an unversioned 0.7 database, not a Unity Catalog database, failed step) and, under a run lock, sets up an empty database, adopts a 0.7 one (version 1 recorded as the baseline) and applies the pending steps. The run lock is pg_advisory_lock on PostgreSQL, GET_LOCK on MySQL and an in-process lock per database file on H2. bin/uc-migrate runs `migrate` and `info` against the database in etc/conf/hibernate.properties. Co-authored-by: Isaac <[email protected]> Signed-off-by: Shubham Bansal <[email protected]>
…ases with Flyway The server sets up an empty database itself (a second server starting at the same time waits on the run lock) and refuses any other schema version with a message that names the fix. Hibernate never alters the schema: hbm2ddl.auto is forced to none, even if an old hibernate.properties says update. Co-authored-by: Isaac <[email protected]> Signed-off-by: Shubham Bansal <[email protected]>
…ases Adds V3. On MySQL it converts the database and every Unity Catalog table (and casbin_rule, when it exists) to utf8mb4_0900_bin, so a database created with MySQL's case-insensitive default compares names and storage paths like PostgreSQL and H2. Converting is safe to repeat, so the step holds several statements. On PostgreSQL and H2, V3 does nothing. The startup collation warning skips Flyway's history table, which keeps the database's original collation. Test-only steps move to version 1000 and tests read the latest version instead of hard-coding it. Co-authored-by: Isaac <[email protected]> Signed-off-by: Shubham Bansal <[email protected]>
Every test database now gets its schema from Migrator, never from Hibernate DDL: the PostgreSQL and MySQL templates are migrated once, and each H2 test database is migrated when it is created. Hibernate runs with hbm2ddl.auto=none in every test. MySQL clones now also copy the template's rows (Flyway's history), as PostgreSQL's TEMPLATE does, so a clone is at the current version. The MySQL template no longer needs halt_on_error=false or the check that every mapped table exists: Flyway stops on any failed statement. PopulateTestDatabase migrates its database before opening it. Co-authored-by: Isaac <[email protected]> Signed-off-by: Shubham Bansal <[email protected]>
Describe how Flyway manages the schema, how to upgrade without Helm with bin/uc-migrate, the first start on an empty database, the MySQL case-sensitivity change, going back to 0.7, and each error message with what to do. Replace the outdated Hibernate auto-update paragraph in the deployment guide with a link to the guide. Co-authored-by: Isaac <[email protected]> Signed-off-by: Shubham Bansal <[email protected]>
The pre-upgrade check Job's pod now gets the server pod's extraInitContainers, extraVolumes, extraVolumeMounts and extraPodLabels, so a check works wherever the server does: a CA or client certificate mounted through extraVolumes, a driver fetched by an init container into the driver volume, or a NetworkPolicy that admits pods by a label. extraContainers stays out, because a sidecar would keep the Job from completing. The Job, its pod and the hook ConfigMap are labelled app.kubernetes.io/name, instance and component "upgrade-check", so they can be found by release; the component differs from "server", so the server Service does not select the check pod. Co-authored-by: Isaac <[email protected]> Signed-off-by: Shubham Bansal <[email protected]>
The Job and hook ConfigMap names add "-upgrade-check" (and "-upgrade-check-config-templates") to the server's name, which may itself be 63 characters, so a release name of about 30 characters made a Job name that Kubernetes rejects, and every helm upgrade with PostgreSQL or MySQL failed at the hook. Both names are now cut to 63 characters (trunc 63 | trimSuffix "-"); short names are unchanged. A Job and a ConfigMap may share a name. docs/server/helm.md gives the log command as job/<fullname>-server-upgrade-check and says what <fullname> is, including with nameOverride: unitycatalog. Co-authored-by: Isaac <[email protected]> Signed-off-by: Shubham Bansal <[email protected]>
… users set it Only the backup reads UC_CHART_REVISION, but the chart set it on every server pod, and its value changes with every revision, so every helm upgrade (scaling, an ingress change) restarted all servers, a full outage with Recreate. It is now rendered only with server.migration.backup.enabled. helm template, which Argo CD uses, always renders revision 1, so a restored mark would never clear. server.migration.backup.chartRevision (default empty: the release revision) sets the value instead; bumping it tries the upgrade again. The values doc and docs/server/helm.md say so. Co-authored-by: Isaac <[email protected]> Signed-off-by: Shubham Bansal <[email protected]>
docs/server/helm.md offered helm upgrade --atomic as a way back after a restored upgrade. But --atomic rolls back on any failure: also after the schema upgrade went through (--wait timing out after it, a post-upgrade hook failing) and while it is still running. The rollback then starts the previous release on an upgraded or partly upgraded schema, which upgrades.md says must not happen. The guide now says: with the backup off, never use --atomic, and never helm rollback after a schema upgrade started (restore your own backup instead); with the backup on, a rollback during or after a failed upgrade is safe, because the server restores the copy first, but not after the upgrade went through. With --wait or --atomic, set --timeout well above the upgrade time. Co-authored-by: Isaac <[email protected]> Signed-off-by: Shubham Bansal <[email protected]>
…ry may hold
The chart puts every entry of the MySQL driver directory on the Java module path. A second
driver version ("Two versions of module mysql.connector.j found") or a directory the server
cannot read, such as the root-owned lost+found of a new ext4 volume, stops the JVM before main,
in the server and in the pre-upgrade check alike.
server.db.mysqlConfig.driver.subPath mounts one directory of the volume instead of its top, in
the server and the check Job. The values doc and docs/server/helm.md now say the directory must
hold exactly one driver jar and nothing else, and to replace the jar rather than add one; the
example uses a subPath.
Co-authored-by: Isaac <[email protected]>
Signed-off-by: Shubham Bansal <[email protected]>
…oken Pre-upgrade hooks run before the release's resources are applied, so a ServiceAccount that the same upgrade creates or renames (serviceAccount.create, serviceAccount.name) did not exist yet: the Job controller could not create the pod, helm upgrade timed out, and every retry failed the same way. Argo CD also runs the hook on the first sync. The check needs no Kubernetes API access, so the Job now uses the namespace's default ServiceAccount with automountServiceAccountToken: false. Co-authored-by: Isaac <[email protected]> Signed-off-by: Shubham Bansal <[email protected]>
…r's pool
The server's pool doesn't autocommit (Hibernate manages transactions), and
the migration took its connections from it. On PostgreSQL the lock-wait SET
then opened a transaction, so a bad-row check's setReadOnly(true) failed
("Cannot change transaction read-only property in the middle of a
transaction") and every check refused the start. A statement run on such a
connection outside Flyway would also never be committed.
connection() now sets autocommit before the SET, as the backup's connections
do; a check still runs in its own read-only transaction. Flyway gets the same
autocommit connections the tests always gave it. The new test runs the checks
and the upgrade on a pool built like the server's.
Co-authored-by: Isaac <[email protected]>
Signed-off-by: Shubham Bansal <[email protected]>
…widen the paths - After the upgrade, the job runs --check-schema in the new server and requires "Pending steps: none." instead of printing log lines with "grep schema || true", which asserted nothing. (An upgrade from a base without new steps logs no "Upgraded" line, so the log is not checked.) - A step that runs only on failure prints the upgrade namespace's pods, Jobs and events, and describes and logs the check Job and the server. - The job also runs on changes to bin/start-uc-server and UnityCatalogServer.java (--check-schema and the start order). Run by hand on kind (images from main 2c0d0ef and an earlier build of this branch's server), with serviceAccount.create: true and an extraPodLabels entry turned on in the same upgrade: the check Job completed, --check-schema printed "Pending steps: none.", helm test passed and the catalog was still there. actionlint 1.7.7 with shellcheck 0.10.0 reports nothing. Co-authored-by: Isaac <[email protected]> Signed-off-by: Shubham Bansal <[email protected]>
…plete copies The MySQL restore dropped the database's tables one by one, then moved the copies back. A restore that failed partway (a lock a client held past the lock-wait cap) left dropped tables, and the next start, seeing a database at the previous release, dropped the only good copy and backed up the gutted database. - The restore moves the database's tables to <db>_uc_trash and the copy's tables back in one RENAME TABLE, which MySQL runs whole or not at all, then drops the trash and the copy. - The copy is complete once it has the table uc_backup_complete, the last statement of the copy. A copy without it (a server killed or disconnected while copying) is replaced at the previous release and refused partway through the steps, instead of being restored over the database. - A complete copy that has tables the database lacks is never dropped: the start refuses and names the copy. PostgreSQL's CREATE DATABASE and H2's .part file plus atomic move are whole or nothing, so their copies need no mark. Co-authored-by: Isaac <[email protected]> Signed-off-by: Shubham Bansal <[email protected]>
The type-change probe compared only the type and size, so a step that restates them and changes something else was recorded without running: a MySQL MODIFY c varchar(64) NOT NULL over a nullable varchar(64), or a PostgreSQL ALTER COLUMN c TYPE varchar(64) COLLATE "C". The probe now recognises a type change only when nothing but NULL or NOT NULL follows the type; any other clause (DEFAULT, COLLATE, CHARACTER SET, USING, ...) gets no probe, so the step runs. A NULL or NOT NULL must match the column's nullability. MySQL's MODIFY and H2's ALTER COLUMN c <type> restate the column: they drop its default, and MySQL's makes it nullable unless it says NOT NULL, so for them the column must also have no default, and on MySQL be nullable when the statement says nothing. Co-authored-by: Isaac <[email protected]> Signed-off-by: Shubham Bansal <[email protected]>
…e a ServiceAccount The refusal of server.migration.backup.enabled with more than one replica said "Scale to 1 for the upgrade, then scale back", which the same refusal blocks while the backup is on. It now says to run the upgrade with one replica, then turn the backup off before scaling up (or keep one replica); the values doc and docs/server/helm.md say the same. server.upgradeCheck.serviceAccountName (default empty: the namespace's default ServiceAccount without a token, as before) makes the pre-upgrade check Job use that ServiceAccount and mount its token, for a server that reaches the database through workload identity such as IAM database authentication. The docs say it must exist before helm upgrade runs, because the hook runs before the chart creates its resources. Co-authored-by: Isaac <[email protected]> Signed-off-by: Shubham Bansal <[email protected]>
The run checks for SIGTERM before each step and between a data step's batches, but not after the last step. SIGTERM during the last step let the run pass the schema check and drop the backup, so the process exited with the upgraded database and no backup, although the docs promise a restore. The run now checks once more after the steps and the schema check, before it drops the backup, and restores when a stop was requested. The new test sends SIGTERM to a server process during a slow last SQL step (PostgreSQL and MySQL; H2 has no sleep function). Co-authored-by: Isaac <[email protected]> Signed-off-by: Shubham Bansal <[email protected]>
…tore CREATE DATABASE ... TEMPLATE copies the tables, not the database's own attributes, and the restore renames the copy in place of the dropped database. A restore therefore lost ALTER DATABASE ... SET settings (a search_path that selects UC's schema among them, after which the previous release sees an empty catalog), ALTER ROLE ... IN DATABASE settings, GRANTs on the database, its owner and its connection limit. The backup now creates the copy as <db>_uc_backup_part, gives it those attributes of <db>, then renames it to <db>_uc_backup, so a copy under the backup's name is always complete. A copy restored by hand keeps them too. List settings such as search_path are re-quoted element by element, as pg_dump does. Co-authored-by: Isaac <[email protected]> Signed-off-by: Shubham Bansal <[email protected]>
… in the URL
Connections to the companion database <db>_uc_upgrade take the
server's URL, parameters included. With ?currentSchema=uc there, the
companion has no such schema, so creating or reading the restored mark
failed ("no schema has been selected to create in") and, with
UC_CHART_REVISION set, every start with the backup on refused.
The mark's table is now public.uc_restored on PostgreSQL.
Co-authored-by: Isaac <[email protected]>
Signed-off-by: Shubham Bansal <[email protected]>
…set step
The release before this build's was the highest listed release below it. A
patch release without steps of its own then moved it: with 0.7.0=1, 0.8.0=3
and 0.8.1=3, a 0.8.2 build refused a 0.7.0 database and a 0.8.0 upgrade that
stopped midway ("Upgrade to 0.8.1 first"), and no step was this release's, so
the every-start schema check compared no table.
The release before is now the first listed release of the minor line before
this build's: any release of that line, or a later one such as an earlier
patch of this build's own line, upgrades, and this release's steps are those
above that release's last step. This follows the project's policy of testing
upgrades from the latest patch of each minor line. The refusal names the
line: "... upgrades only from 0.7.0 or a later 0.7 release (version 3 or
later). Upgrade to the latest 0.7 release first, ...". upgrades.md and the
releases.properties header say so.
MySQL's step 3 converts the character set of every table, which made every
table one this release changes, so the every-start check refused, for
example, an index a DBA added to uc_catalogs. A statement that changes only a
table's character set or collation (not compared by the schema check) no
longer counts as changing the table.
Co-authored-by: Isaac <[email protected]>
Signed-off-by: Shubham Bansal <[email protected]>
… like the start
- PostgreSQL applies lock_timeout to advisory-lock waits too. With the
backup on, the run lock is taken on a companion connection that has
the run's 60-second lock wait, so a second starting server failed
("canceling statement due to lock timeout") instead of waiting, as
upgrades.md says it does. A pooled connection can keep an earlier
run's lock wait as well. The run lock's connection now sets
lock_timeout = 0 before it waits.
- bin/start-uc-server --check-schema ignored server.migration.backup,
so on PostgreSQL it locked <db> while a start with the backup on held
the lock in <db>_uc_upgrade: the two didn't exclude each other. It
now turns the backup on from the same setting, taking the lock where
the start does. upgrades.md says to give every server of a database
the same setting.
Co-authored-by: Isaac <[email protected]>
Signed-off-by: Shubham Bansal <[email protected]>
…ty H2 mark file
- --check-schema with the backup on now prints the restored mark's
refusal and exits 1 when a start of this release in this chart
revision would refuse. It exited 0 ("The upgrade would go through")
while every start refused.
- An H2 mark file without its release or revision (a crash while
writing it) is no mark. It threw a bare NullPointerException on every
start.
Co-authored-by: Isaac <[email protected]>
Signed-off-by: Shubham Bansal <[email protected]>
Adoption compared every table in the schema with the 0.7.0 schema, so a
database whose schema also holds another application's tables was refused
("differs from the 0.7.0 schema in ways the server can't repair"), which
0.7.0's Hibernate update accepted.
It now compares only Unity Catalog's tables: those of the baseline dump and
of this build's dump (casbin_rule and uc_schema_history stay left out). An
extra or missing column, index or key on one of them is still refused.
Co-authored-by: Isaac <[email protected]>
Signed-off-by: Shubham Bansal <[email protected]>
…e probe The add-column probe also matched ALTER TABLE t ADD UNIQUE (c), ADD PRIMARY KEY, ADD INDEX and the like, taking the keyword for a column name. It then reported the change as absent instead of "can't tell", so a failed step of that form whose change was there was run again: an unnamed unique key was added twice, and a named index failed again on every start. These forms now get no probe: a failed one is refused with the "can't tell" message, a pending one runs. Co-authored-by: Isaac <[email protected]> Signed-off-by: Shubham Bansal <[email protected]>
Conflicts: SchemaMigrator type-change probe keeps the Optional return with the new end-anchored regex and the nullable/restates hasType arguments; StepAlreadyInDatabaseTest keeps both test-step directories. Co-authored-by: Isaac <[email protected]> Signed-off-by: Shubham Bansal <[email protected]>
Conflict: BadRowCheckTest imports. SchemaSnapshot is in the migrate package on this branch, so the kit import goes; the HikariDataSource and HibernateConfigurator imports of the new pool test stay. Co-authored-by: Isaac <[email protected]> Signed-off-by: Shubham Bansal <[email protected]>
Conflict: SchemaMigrator.connection() keeps the autocommit fix and this branch's static lockWaitSql(kind, lockWait). Co-authored-by: Isaac <[email protected]> Signed-off-by: Shubham Bansal <[email protected]>
… new rule The release before this build's is now the first listed release of the minor line before it. BackupTest's map 0.7.0=1, 0.7.5=6000 then made 0.7.0 (version 1) the release before, so a database at 6000 counted as partway through this release's steps: takesAFreshBackupAtThePreviousRelease reused the older copy and lost the row written after it. The map is now 0.6.0=1, 0.7.0=6000, which keeps version 6000 as the last step of the release before this one, as the tests intend. Co-authored-by: Isaac <[email protected]> Signed-off-by: Shubham Bansal <[email protected]>
Conflicts in SchemaMigrator: the class comment keeps the adoption paragraph and takes the minor-line release rule; checkSchema checks the restored mark, then the release rule, then lists the adoption's drifts; the backed-up run passes the drifts to upgrade() and stops at the end of the upgrade on SIGTERM. 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]>
…way applied A start with the backup on keeps a copy that is already there only when the database is partway through this release's steps. That check used the threshold of the skipped-release rule: the last step of the first release of the minor line before this build's. With releases 0.6.0=1, 0.7.0=3 and 0.7.5=6000, a clean 0.7.5 database at 6000 counted as partway through an 0.8 upgrade. A complete leftover copy (an earlier upgrade whose drop failed) was then reused, and a failed upgrade restored it, losing the rows written after it; an incomplete one made the start refuse. The check now uses the latest release listed before this build's, the one the database was at before the upgrade started. The skipped-release refusal keeps the minor-line threshold. BackupTest covers a database at 0.7.5's last step with an older copy: the upgrade fails and the restore brings back the current rows. Co-authored-by: Isaac <[email protected]> Signed-off-by: Shubham Bansal <[email protected]>
… mid-upgrade 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]>
Collaborator
Author
|
Closing this draft. Its code is kept as a reference on |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
🥞 Stacked PR
Use this link to review incremental changes.
PR Checklist
docsis updatedDescription of changes
helm upgradenow upgrades the schema safely: old servers stop before new ones start, a pre-upgrade Job runs the new release's checks first, MySQL is supported, and the backup can be turned on.db.type: filefails the render (H2: one server per file). The startup probe allows 30 minutes (180 × 10 s) for a migration at start; the probe templating bug (if→with, which rendered the whole values tree) is fixed for the startup, liveness and readiness probes.pre-upgradehook Job (PostgreSQL and MySQL) runs the new image'sbin/start-uc-server --check-schemawith the server's config and secrets (from its own hook ConfigMap, since hooks run before Helm updates the release's ConfigMap). Exit 1 failshelm upgradebefore the old pods are touched; failed Jobs stay for their logs.server.upgradeCheck.enabled(default true).db.type: mysqlwithmysqlConfig(host, port, database, user, password Secret, extra parameters). The MySQL driver isn't bundled (licence):mysqlConfig.driver.volumemounts a volume holding the driver jar, loaded throughJDK_JAVA_OPTIONS=--module-path=… --add-modules=ALL-MODULE-PATH.server.migration.backup.enabled(default false) rendersserver.migration.backup=true. The chart refuses it with an in-memory H2 URL and with more than one replica (every other new server would hold connections the copy and the restore need free).UC_CHART_REVISION={{ .Release.Revision }}lets the server refuse a revision that already restored instead of restoring in a loop.terminationGracePeriodSecondsdefaults to 120, now thatbin/start-uc-serverrunsexec javaand SIGTERM reaches the JVM (the migration stops at a safe point or finishes a restore).hibernate.hbm2ddl.auto=update(the server forcesnoneand warned on every start).helm-chart-tests.ymlgains an upgrade test: in one kind cluster with PostgreSQL 18, install the base branch's chart and image, create a catalog,helm upgradeto this PR's chart and image (the check Job must succeed), thenhelm testand read the catalog back.ct lintrenders default, PostgreSQL and MySQL value sets (helm/ci/*-values.yaml).docs/server/helm.md: upgrade order, a failed check (read the Job's log, fix, retry), long migrations (the probe budget), MySQL, the backup and--atomic, and thathelm rollbackdoesn't undo a schema upgrade.Testing
helm lintandct lintwith all three value sets,helm-docsleaves the tree clean,actionlintclean.helm testand the catalog read passed;helm upgradeexited 1 and the old pod kept serving; after removing the row the next upgrade passed;helm test, upgrade, no Job, Recreate;UC_CHART_REVISION=3, grace period 120, the backup property.From the final review: the check Job gets the server pod's
extraVolumes/extraVolumeMounts/extraInitContainers/extraPodLabels, names cut to 63 characters, runs as the namespace's default ServiceAccount without a token (orserver.upgradeCheck.serviceAccountName);UC_CHART_REVISIONonly with the backup on (server.migration.backup.chartRevisionfor Argo CD /helm template);--atomic/rollback guidance;mysqlConfig.driver.subPathand "exactly one jar"; CI assertsPending steps: none.after the upgrade and dumps logs on failure.📐 Design notes & details
Why no init container. The server upgrades the schema itself at start (#2045); the hook only checks, read-only, while the old servers still serve.
Why the check isn't run for H2. The file sits on the server's volume, which the running server holds.
Every
helm upgraderestarts the servers.UC_CHART_REVISIONis in the pod template, so even an otherwise unchanged upgrade rolls the pods (a short outage with Recreate).Left as they were (chart bugs from before, outside this PR):
postgresqlConfig.extraParamsrenders a Go map;server.deployment.resourcesis documented but not rendered; the UI deployment's probes have the sameifbug; the hook Job doesn't take theextra*values, so a database reached through a sidecar proxy can't run the check. CI now builds three server images, which may press on runner disk.This pull request and its description were written by Isaac.