Highlights
- A pull request preview can get a copy of its MongoDB database too, from the latest backup, without any of the server's accounts: every database the application made is on the copy, whatever it named them.
- A preview's database copies now come from a node too: a database that runs on a node is copied onto the panel host, where previews run, from what the node's agent streams.
- The instance file (GitOps) names a project's databases and which service gets each one's connection string, and Plan the apply shows every step before anything runs.
Action needed: No. A preview copy of a MySQL or MariaDB database that runs on a node needs its agent 0.22.0 or newer; with an older one the deploy log names the agent, and the preview gets no copy of that database.
Added
- A preview copy of a MongoDB database. A pull request preview could get a copy of its PostgreSQL, Redis-family, MySQL and MariaDB databases. MongoDB joins them, on the panel host. Its copy comes from the latest completed backup, or from a dump taken at that moment when there is none, as a PostgreSQL copy does; and it is restored with the server's own databases left out (
admin,configandlocal). MongoDB keeps the account of every database, the copy's as much as production's, inadmin, and its open sessions inconfig, and the backup holds them: measured on MongoDB 8.0 and 7.0, a fresh copy restored from a backup the usual way takes production's root password at once and stops taking its own, and an account made in production signs in to the copy. With the server's databases left out, the copy keeps the credentials of its own first start, production's password fails on the copy and the copy's in production, and no account of production is on the copy. The application's data comes whole: every database the application made, whatever it named them (the panel leaves the name to the application), with its views and indexes; a database with no application data yet gives an empty copy. The deploy log says what was left out. - A preview copy of a database that runs on a node. A database attached to a service ran on a node, no preview of that service got a copy of it. It does now, for every copied engine: the copy is made on the panel host, where previews run, from the node database's latest completed backup, or from a dump the node's agent streams to the panel at that moment when there is none (the file every backup of a node database is made of, encrypted on the panel as they are). A MySQL or MariaDB database on a node is copied from its application database alone, as on the panel host: that dump is a later addition to what the agent can stream (
scope: 'application', capabilitydb.dump.scope, agent 0.22.0 or newer), and with an older agent the deploy log names the agent and the version to update to, and the preview gets no variable for that database while its other databases are still copied. The copy is a database of the panel host's own, with its own credentials, and nothing changes on the node: its database is only read. Measured with the node's agent in the process on real Docker: a MySQL database on a node ready in 13.2 s and its copy made in 12.2 s, a PostgreSQL one in 3.8 s and 6.0 s (and 6.0 s from its backup), a MongoDB one in 7.8 s and 8.2 s. - Databases in the instance file, and a plan for applying it. The instance file (GitOps) described projects, services, domains and grants; a database made through the panel was not in it, so an instance exported and applied from its file came back without its databases, and without the attachments that hand them to services. The file now names a project's databases (
slug,engine, and optionallyversion,nodeandextensions) and, on a service, the databases whose connection strings it gets (databases: [orders], or with analias). Applying creates them through the ordinary route, which starts the database as the panel does, and attaches them. What a database was made with is not changed by the file: another engine, version, node or extensions for a database that exists is reported, and the step is refused with its reason.POST /v1/gitops/plananswers the steps applying would run, in order, with what each writes and the reason of each one that cannot be had however the routes answer; nothing runs. Applying runs the plan's steps, in its order, and answers each with what happened to it; the one thing it replaces is an attachment whose alias the file changed. Measured through the ordinary routes: an instance built through the API, exported and applied into an empty one is the same instance again, and the second apply has nothing left to do.
Fixed
- A MySQL or MariaDB database is ready only when its own server answers. On a database's first start the image's entrypoint runs a temporary server on its socket alone (
--skip-networking), sets the root password on it, then stops it and starts the real one. The readiness probe went over the socket, so the temporary server could answer it, and the socket was then gone for a moment until the real server was up: whatever the panel sent next failed with "Can't connect to local MySQL server through socket" (measured on mysql:9.7: the probe was answered 0.7 s before the socket went away, gone for 1.2 s, longer on a loaded runner). CI's integration job met it on a slow runner on December 2, in the preview copy of a MySQL database; a first deploy of a preview with a fresh MySQL or MariaDB copy, a restore into a fresh database or a statement sent right after a database's creation could meet it too. The probe goes over TCP now, which the temporary server does not have and which is how a service reaches the database; the same builder serves the agent's probe of a node's database.
Internal
- The MongoDB copy:
RestoreScopeon the restore builders (lib/databaseCommands.ts:restoreCommand(engine, cn, tmp, password, scope)withwithoutServer,MONGO_SERVER_EXCLUDEDasmongorestore --nsExcludeforadmin,configandlocal; a scope refused for any other engine, so a wrong wiring cannot pass as a whole restore),restoreDatabase(d, file, log, scope)in the engine, andRESTORE_WITHOUT_SERVERinlib/previewDatabases.ts(the copy comes from the latest backup as a PostgreSQL one does; a mongo database is not inBACKUP_CARRIES_ACCOUNTS). Measured before the design onmongo:8.0(8.0.38) andmongo:7.0(7.0.48): the panel's backup ismongodump --archive --gzipof the whole server withadmin.system.usersin it;mongodumphas no namespace filter (--nsExcludeismongorestore's), so a database cannot be left out of a dump, and a dump of one database would miss the ones the application named otherwise (the guide's own example usesshop); a restore with--nsExclude admin.* --nsExclude config.* --nsExclude local.*is clean. Tests:test/databaseCommands.test.ts,test/database.test.ts,test/lib/previewDatabases.test.ts,test/lib/previewDatabaseDeps.test.ts, and real Docker through the real flow (test/integration/previewDatabasesMongo.integ.test.ts: 35 s, production ready in 6.2 s and the copy made in 7.3 s). - The probe over TCP:
probeCommandfor mysql and mariadb inlib/databaseCommands.ts(-h 127.0.0.1 --protocol=tcp;lib/backupRestoreVerification.tsread the final server that way already), the recorded argv fixture's two probe entries (test/fixtures/databaseArgv015.json, by hand: a regeneration withNINEDEPLOY_RECORD_DB_ARGV=1re-records the retained-volume and extra-engine outcomes too, which its tests do not expect) andtest/databaseCommands.test.ts. Measured with the panel's own probe polled every 200 ms onmysql:9.7andmariadb:12.3: one first start of five answered the probe from the temporary server; a probe over TCP was answered by the real server only, in every run. Real Docker:test/integration/previewDatabasesMysql.integ.test.ts2 of 2,mysql.integ.test.tsanddatabase.integ.test.ts. - The node sources: the capability
db.dump.scope(packages/schemasMULTI_NODE_CAPABILITIES, the agent'sagentOps/databases.tsmodule,AGENT_DUMP_SCOPE_VERSION0.22.0, the node's switchNINEDEPLOY_AGENT_DATABASES), the dump kind'sscope: 'application'(dbDumpKind: refused for any other value and any other engine),DatabaseRuntime.backup(file, log, scope)with the node runtime'sdumpUnlockedasking fordb.dump.scopebefore it opens the stream,previewNodeRefusalbesidepreviewCopyRefusal(which no longer decides placement), and the preview deps'dumpanddumpApplicationgoing throughdatabaseRuntime, with their new handnodeRefusal. The support matrix's "Preview copy" column is the panel host's and the node's for all eight engines. The CLI'spreviews database-copieshelp still said MySQL, MariaDB and MongoDB were not copied; it says what is copied now. Tests:packages/schemas/test/multiNode.test.ts,test/agentOpsDatabases.test.ts,test/nodeFeatureRefusals.test.ts,test/lib/previewDatabases.test.ts,test/lib/previewDatabaseDeps.test.ts,apps/cli/test/previews.test.ts, and real Docker with the agent's own code in the process (test/integration/previewDatabasesNode.integ.test.ts: 78 s; only the sealed transport is a function call), where the capability ping is the agent's own registry's answer and an older agent's is a scripted line. - N14's first slice: the schema (
instanceSpecDatabase,instanceSpecAttachment— a bare slug or{ slug, alias }; the drift kindsdatabaseandattachment;GitopsPlanStep,GitopsPlan),lib/instanceGitops.ts(loadLivereads databases, attachments and node names, leaving a preview's copies out;computeDrift; a database's name is exported only when it shortens to its slug, since the panel derives the slug from the name),modules/instanceGitops.ts(planInstance: one planner forPOST /v1/gitops/planand for applying, phase by phase, the plan seeing what its own steps would make),lib/databaseAlias.ts(aliasFor, shared with the attach route), the OpenAPI entry, the authorization matrix row, the SDK'sgitops.plan(), the web's Plan the apply,docs/INSTANCE_GITOPS.md. Tests:test/instanceGitops.test.ts(the file's rules, the drift, the export, the plan and the apply through stand-ins) andtest/instanceGitopsRoundTrip.test.ts(new: through the ordinary routes, the database engine a stand-in). Found on the way: Fastify refuses a request with a JSON content type and no body, so the detach of a reattach sends the type only with a body; withpgvectorthe panel runs the engine'svectorrelease whatever version was asked, and the exported file says so.