How an install, update, removal and rollback run
An admin with appstore/install presses Get, Update, Remove or Roll back (or runs
appstore.php install|update|remove|rollback). The App Store writes a run (<var>/appstore/runs/<id>.json and its
.log), starts it, and shows its page (History), which follows it until it ends.
Where it runs
appstore.ini [Install] Runner:
- The job queue (
expqueue): the job typeappstore.run, run by the queue's worker or its cron part as the site user. That user runs the steps of this machine itself and reaches the other nodes with its own ssh key: give it a key, authorise it for the site user on each other node (restricted withfrom=to this node's address), give the site user a real shell there (in Plesk: the subscription's SSH access,/bin/bash), and name the hosts in its~/.ssh/configassettings/cluster.iniSsh=does. Set each node'sUser=to that site user. - Within the request (
sync), or on the command line. auto(the default): the command line runs it directly; the admin runs it within the request when every node is this machine and needs no other user, else queues it.
No run uses sudo for the user it runs as, and a web request never tries sudo: a node whose User= is another user
is refused up front, on the app's page, Updates, a run's page and Information, with the reason.
As the site user, the deploy of each node skips the PHP-FPM reload and the Velocity restart (it may not do them):
instead, each node touches [Install] ReloadTrigger (var/appstore/reload.trigger) when that file exists. An
administrator installs a small root path unit per node that watches it and runs only the fixed reload of that node
(systemctl reload <php-fpm>, vcc restart <site>) and reads nothing from the file. Without the file the step says
that the reload is left to an administrator.
On every node
The nodes are the hosts of settings/cluster.ini (the kernel's expClusterHosts), in the order of HostList[].
For each node, through the kernel's expClusterRemote (ssh with BatchMode, Ssh=local with sh -c, as the host's
User=):
- The App Store step:
php extension/exp_app_store/bin/php/appstore.php apply <run>in the node's root:- composer: ezupdate takes a snapshot of
composer.jsonandcomposer.lockunder the run's id and applies the local changes policy (composer status: refuse, orgit stashin each changed package); thencomposer require <package>:<version> --no-updateand a guarded update of that package with its dependencies only: a dry run first, and when it would install, update or remove any other installed package (vendor/ differs from the lock, a dependency would move) nothing runs, the snapshot goes back and the log names those packages. Packages whose locked version no longer satisfies what composer.json already requires (the lock fell behind the root) come along, to the newest version their constraint allows: the run lists them first ("Also brings up to composer.json: ..."), and the local changes policy applies to them too. Nevercomposer installor a fullcomposer update: every other package stays as it is; - git: git_manager clones the repository into
extension/<name>at the release tag, or updates the working copy to the tag after the local changes policy (refuse, orgit stash), and records what was checked out before under the run's id. A private repository takes its SSH key or HTTPS token from the secret store ([Install] KeySecret[<host>]), written to a 0600 file only for the git call that needs it; - an extension that was not active is switched on (
settings/override/site.ini.append.php, as Setup > Extensions does), then the autoloads are regenerated; - the node keeps what it did in
<var>/appstore/node/<run>.json.
- composer: ezupdate takes a snapshot of
- The deploy (
[Install] Deploy=enabled):exp:velocity deploywith the host'sDeployOptions[], as the host's deploy user: autoloads, INI and template caches, the PHP-FPM reload, the Velocity restart on a Velocity node, the caches of rendered output. AnEngine=fpmhost gets--no-velocity.
When a node fails, its own step has already put it back (the snapshot, the earlier checkout), and the run rolls back the nodes done before it, newest first. The site never stays half updated.
Adopt into Composer
An app installed as plain files (a folder under extension/ that is neither in composer.lock nor a git working
copy; the Library and Updates pages mark it "installed as files") is updated with Update (adopt into Composer).
With the composer method the run takes it over, on every node:
- the folder moves into the run's snapshot directory (
.../b), and the release it says it is (its own version, from extension.xml, ezinfo.php or composer.json) is downloaded next to it (.../a); - the difference between the two is the site's local edits, written to
adopt.patchand shown in the log ("Local edits against release ..."); - with the local changes policy refuse and a non-empty patch, the folder goes back as it was and the run stops;
with stash, or when there are no edits, Composer installs the new release through the guarded update above
(only that package and its dependencies), then the patch is applied on top (
patch -p1 --forward) and the log says "Applied the local edits"; a hunk that no longer applies fails the node, which puts everything back.
Each node adopts what it has itself:
- a node without the folder installs the package fresh;
- a node with an empty folder (a copy that never arrived) sets it aside and installs fresh; an empty folder is never read as "every file deleted";
- files of the release that the folder lacks are listed in the log and never deleted from the new release: only
changed and added files are carried over (binary files are copied, the rest is the patch). The whole difference
stays in the snapshot as
adopt-full.patch.
A rollback removes the package from composer.json and composer.lock again (the snapshot) and puts the plain
folder, with its edits, back where it was.
Remove
Remove on an app's page or in the Library opens a confirmation page: what goes, how, on which nodes, and why it
cannot when it cannot. Ticking the confirmation and pressing Remove starts the run (no browser dialog). On the
command line: appstore.php remove <vendor/name|extension:<dir>>. Each node removes what it has itself (a node
without the app passes):
- Refused, with nothing changed, when the app is one of
[Install] KeepInstalled[](the App Store, ezupdate, git_manager, expqueue, the kernel), a folder the site's own repository tracks (shipped with Exponential), or needed: an active extension whoseextension.xmlrequires or extends it, or an installed package that requires it. - The extension is switched off (
settings/override/site.ini.append.php). - composer: a snapshot of
composer.jsonandcomposer.lock(ezupdate) and a copy of the package folder (kept-<name>in the snapshot),composer remove <package> --no-update, a dry run, then the guarded update: only the package goes, with the packages nothing else needs (listed first). When any other installed package would be installed, updated or downgraded, nothing runs and the snapshot goes back. Only a package the site'scomposer.jsonrequires itself can be removed. git and files:extension/<name>moves into<var>/appstore/removed/<run>/<name>; nothing is deleted. - The autoloads, then the deploy, as for an install.
A failure on one node puts that node back (the extension switched on again) and rolls back the nodes before it. A
rollback of a removal puts the snapshot or the folder back and switches the extension on again. Removing uses the
policy appstore/install: the spec has two policies, and every change to the installed apps (install, update,
rollback, remove) is the one of them that changes the site.
Nodes whose trees are synced
Some sites keep their nodes' trees in step with a sync of their own: one node is pulled from another with
rsync --delete (a development tree mirrored from a master). Such a sync must neither copy one node's half-done
state into another during a run, nor undo the run afterwards. The App Store gives it two files, both under var/
(node-local; [Install] SyncHold and SyncWriteback, empty to switch off):
var/appstore/sync.hold: the run writes its id there on every node before its first step and empties it when the run ends, also after a failure and a rollback. A sync skips while the file is non-empty (and younger than two hours, so a crashed run cannot hold it forever).var/appstore/sync-writeback.list: each node appends the paths a successful run (or rollback) changed there:composer.jsonandcomposer.lockwhen they changed,vendor/composer/, the install paths of the packages that came, went or moved,extension/<dir>/,autoload/,settings/override/site.ini.append.phpwhen an extension was switched. The sync pushes these paths to its source first, each with deletes, then pulls.
In the adopt step, a file that already equals the folder's edited version (copied in by such a sync, or carried by
the new release) counts as applied; only the other files go to patch.
Rollback
A finished run can be rolled back from its page (or appstore.php rollback <run>): a new run, on every node,
that reads the node's record of the first run:
- composer: the snapshot's
composer.jsonandcomposer.lockgo back, then a guarded update of only the packages that differ from it (nevercomposer install); - git: git_manager checks out what was there before (a stash made for the update stays in
git stash list), or moves a fresh clone aside toextension/<name>.rolled-back-<run>(nothing is deleted); - an extension the install switched on is switched off again.
- a removal: the package (the snapshot) or the folder comes back, and the extension is switched on again.
Not xne
The App Store installs apps of a site. Upgrades of the Exponential installation itself (the kernel, a whole distribution) are not its job.