Updating module versions with minimal downtime
When you deploy a new version of a module, Jahia restarts that module and every module that depends on it. A limited set of modules, such as a template set or the default module, have many other modules of the platform that depend on them. On a cluster, a standard deploy of such a module restarts all of these modules on every node at the same time, so the whole cluster stops serving traffic for several seconds.
This page gives a procedure to deploy a new version of such a module on a Jahia cluster, so that only one node at a time is impacted. This procedure is applicable at any cluster size, and it needs one temporary cellar group per node.
This procedure is aimed at system administrators of an on-premises Jahia cluster behind a load balancer. It was validated on Jahia 8.1.9.0 and is compatible with future versions.
This procedure is not supported on Jahia Cloud. On Jahia Cloud, use the procedure described in upgrading your Jahia Cloud environment.
Constraints
Cellar groups are limited to controlling only the OSGi bundle lifecycle. But no matter the group, three parts of a module deployment reach every node:
- The jar stored in the JCR.
- The content the module imports into the JCR.
- The node type definitions it registers.
Because of this, use this procedure ONLY if these conditions are met:
- The new version brings NO breaking change in its
.cnddefinitions. Node type definitions are shared by the whole cluster, and the cluster cannot contain two versions of a definition. A node still running the old version sees the definitions of the new one. - The content imported by the module is harmless to cluster nodes running the old version of the module. The processing node is the only node that imports that content, and the imported content reaches every other node through the Jackrabbit journal. The processing node is upgraded first, and following that, the content gets distributed in the entire cluster.
Do not use this procedure for a module that changes or removes a node type, a property definition or a mandatory constraint. No group arrangement protects the cluster from a definition change. If you are in this situation, plan a maintenance window instead.
One node at a time
A group of one node avoids the cellar cleanup
When a node joins a group, cellar can uninstall every local bundle that the group map does not list. That cleanup is skipped for the first node that joins a group, and it runs for every node that joins after the first. A group that contains one node only ever takes a first join, so the cleanup can never run. A group that contains several nodes requires every member to carry the same module set.
A failure stays on one node
A deploy that fails affects every member of the target group. With one node per group a failed upgrade stops on that node, the other nodes keep the old version and keep serving, and you can stop the procedure there and take corrective actions.
Before you start
Check the cluster
- Every node belongs to the cellar group
default. Check withcluster:group-list. - The command
jahia:clustered-bundle-states -iprints a header and no rows. Do not start while the cluster is inconsistent. - You can reach the Karaf shell on every node, and the provisioning API at
<node-url>/modules/api/provisioning. - You have each node identifier in the form
<ip>:7860, and each node URL. The port is the value ofcluster.hazelcast.bindPortinjahia.node.properties.
Avoid any other module management operation during the procedure.
Two command channels: provisioning for the deploy, Karaf for the groups
Every module operation below goes through the provisioning API. You POST a short script to <node-url>/modules/api/provisioning. Its installModule operation calls the same ModuleManager entry point as the module manager REST API, so the cluster semantics are identical, and it takes the cellar group in its target key.
The provisioning API carries no cellar group operation. Group create, join, quit and delete stay in the Karaf shell, so the procedure uses both channels.
Pay attention to the following when running the procedure:
- Send each provisioning command to a node that belongs to the target group. A command sent to a node outside the group returns before the work is done, and will corrupt the bundle map of that group.
- Never set
uninstallPreviousVersion. Old versions of modules shouldn't be removed in the middle of the procedure, this removal is documented at the end. - Verify with
jahia:clustered-bundle-states -iafter every deploy. Check the result even when the HTTP response reports a success.
Jahia 8.2.4.0 added the installModule operation. On a version before Jahia 8.2.4.0, use the installBundle operation, with the same target and autoStart keys.
To upgrade several modules in one deploy, put one installModule entry for each module in the same script.
installModule accepts a Maven coordinate, so the usual deploy uploads no jar.
If you want to use a local jar file, not present in a Maven repository, post the script and the file together as a multipart form, and name the file in the script, as detailed below:
cat > deploy.yaml <<'YAML'
- installModule: "<module>-<new-version>.jar"
target: "up1"
autoStart: true
YAML
curl -u root:<pwd> \
--form "script=@deploy.yaml;type=application/yaml" \
--form "file=@<module>-<new-version>.jar" \
<this-node-url>/modules/api/provisioning
Define the node order: the processing node first, the browsing nodes after
A browsing node cannot finish a module upgrade on its own, so the processing node MUST be the first one to be upgraded.
Jahia registers a module version only once the JCR contains the node /modules/<id>/<version>. The import that creates that node runs on the processing node and nowhere else. A browsing node that starts a version no processing node has imported yet leaves the module in the state Waiting to be imported by processing server. The previous version has already left the registry. The node serves nothing from that module, while its OSGi bundle state still reads ACTIVE.
Upgrade the processing node first. Every browsing node then finds the imported content and starts the new version as soon as deployed.
The last node upgraded repairs the cellar map of the group default, and that node keeps the old version until the end. The last node is a browsing node, so pick the browsing node whose restart matters least for front-end traffic.
Full read-only mode and the node order
A change of full read-only mode made on the processing node applies to the whole cluster. The same change made on a browsing node applies to that node only. The processing node must leave full read-only mode to receive its own deploy and to import the module content. That action clears the switch everywhere.
The processing node goes first, so the freeze cannot simply stay in place until the end. The procedure opens the freeze for the deploy of the processing node, then closes the freeze again from the same node. Both changes happen before any browsing node is touched. Each browsing node then clears the switch locally for its own deploy.
The whole cluster accepts writes while the processing node deploys and imports, which is phase 2. Content changes must not occur during that step, keep your editors out of Jahia by another means.
A staged node is a node moved into its own temporary group and upgraded from that group. The staged nodes are the processing node in phase 2, and every browsing node but one in phase 3. The last node is the browsing node that stays in default and is upgraded through default in phase 4.
Jahia has two separate settings with similar names: read-only mode and full read-only mode. This procedure uses full read-only mode only, and the maintenance page parameter for it is fullReadOnlyMode. Every mention below means that setting.
The procedure
Three switches move during the procedure: public traffic at the load balancer, full read-only mode, and cellar group membership. The table below gives the state of each switch in each phase.
| Phase | Public traffic | Full read-only mode | Cellar groups |
|---|---|---|---|
| 1. Freeze the cluster | Every node serves. | Set ON everywhere, from the processing node. | Every node is in default. |
| 2. Upgrade the processing node | Every browsing node serves, on the old version. Only the processing node is out. | OFF everywhere for the length of this phase, then ON everywhere again. Both changes are made from the processing node. | The processing node is alone in its own group. Every browsing node stays in default. |
| 3. Upgrade each browsing node except the last | One node is out at a time. Every other node serves, including the nodes already upgraded. | OFF on the node being upgraded. ON everywhere else. | The node being upgraded is alone in its own group. The others stay in default. |
| 4. Upgrade the last browsing node | Only the last node is out. Every other node serves, on the new version. | OFF on that node. ON everywhere else. | The last node is alone in default, and the deploy goes through default. |
| 5. Return the staged nodes | Every node serves. No node leaves public traffic during this phase. | ON everywhere. | Every node returns to default, and each temporary group is deleted. |
| 6. Close the operation | Every node serves. | Cleared everywhere, from the processing node. | Every node is in default, and no temporary group is left. |
A node leaves public traffic only for its own deploy, and it returns as soon as that deploy is verified. A node upgraded during phase 3 serves traffic from its own temporary group, and it does not wait for the end of the procedure.
Phase 1: Freeze the cluster
-
Confirm that
jahia:clustered-bundle-states -iprints no rows. -
Enable full read-only mode for the whole cluster. Run this on the processing node.
<processing-node-url>/modules/tools/maintenance.jsp?fullReadOnlyMode=trueOnly the processing node propagates the switch. The same page on a browsing node would set that node alone.
-
Confirm on the same page that every node reports the state ON. The page lists the state per node and reports an inconsistent cluster.
Phase 2: Upgrade the processing node
The processing node imports the module content into the JCR, which is what lets every browsing node finish its own upgrade later. No browsing node is touched during this phase.
-
Take the processing node out of public traffic, if it serves traffic. Many installations keep the processing node out of the load balancer, and this step is then not needed.
-
Create the temporary group for the processing node, and join the node to it.
cluster:group-create up0 cluster:group-join up0 <processing-node-id>A new group has an empty bundle map, so this join must not change the node.
-
Confirm the processing node still runs the old version, then remove it from the group
default.cluster:group-quit default <processing-node-id>Always join the new group before you quit
default. A node that is a member of no group is put back intodefaultat once. -
Disable full read-only mode from the processing node.
<processing-node-url>/modules/tools/maintenance.jsp?fullReadOnlyMode=falseThis clears full read-only mode for the whole cluster, and the module content cannot be imported without it. The cluster accepts writes until step 7 closes the switch again.
-
Deploy the new version to this group, and send the request to the processing node.
curl -u root:<pwd> \ -H "Content-Type: application/json" \ -d '[{"installModule": "mvn:<group-id>/<module>/<new-version>", "target": "up0", "autoStart": true}]' \ <processing-node-url>/modules/api/provisioningThe request must reach a member of the target group. Sent elsewhere, it returns before the work is done and it corrupts the group map. Set no
uninstallPreviousVersionkey here, because the old version is removed in phase 6. -
Verify the processing node runs the new version, that its Jahia module state is
STARTED, and that no browsing node restarted anything. See the verification section.A processing node that did not import leaves every browsing node unable to start the new version. Stop the procedure here if the check fails.
-
Enable full read-only mode again, from the processing node.
<processing-node-url>/modules/tools/maintenance.jsp?fullReadOnlyMode=trueThis restores the freeze across the cluster for the browsing node upgrades. Confirm on the same page that every node reports ON.
-
Return the processing node to public traffic, if you took it out at step 1.
Phase 3: Upgrade each browsing node except the last
Repeat per node, one node at a time. Complete all ten steps for one node, and confirm the cluster is healthy, before you start the next node. Use a new group name for each node, such as up1, then up2. Leave one browsing node for phase 4. Exactly one node is out of public traffic at any moment.
-
Take the node out of public traffic at the load balancer. Wait for its in-flight requests to end.
The node is about to restart its modules, and it cannot serve during that time.
-
Create the temporary group for this node.
cluster:group-create up1 -
Join the node to that group.
cluster:group-join up1 <node-id>A new group has an empty bundle map, so this join must not change the node.
-
Confirm the node still runs the old version. Stop the procedure if it runs the new one.
A version change here means the group was not empty, and the node was upgraded by the cellar synchronizer instead of the deploy. See the limitations section.
-
Remove the node from the group
default.cluster:group-quit default <node-id>Always join the new group before you quit
default. A node that is a member of no group is put back intodefaultat once. -
Disable full read-only mode on this node, from this node.
<this-node-url>/modules/tools/maintenance.jsp?fullReadOnlyMode=falseThe module manager refuses every operation that changes module state while the node is in full read-only mode. On a browsing node this change stays local, so the rest of the cluster stays frozen.
-
Deploy the new version to this group, and send the request to this node.
curl -u root:<pwd> \ -H "Content-Type: application/json" \ -d '[{"installModule": "mvn:<group-id>/<module>/<new-version>", "target": "up1", "autoStart": true}]' \ <this-node-url>/modules/api/provisioningThe request must reach a member of the target group. Sent elsewhere, it returns before the work is done and it corrupts the group map. Set no
uninstallPreviousVersionkey here, because the old version is removed in phase 6. -
Verify this node runs the new version with the Jahia module state
STARTED, and that the node renders a page. Verify that no other node restarted anything. See the verification section.A node whose module state reads
Waiting to be imported by processing serverserves nothing from that module. Do not return such a node to public traffic. See the recovery section. -
Enable full read-only mode on this node again.
<this-node-url>/modules/tools/maintenance.jsp?fullReadOnlyMode=trueThe node rejoins a cluster that is still frozen, so it returns to the same state as the others.
-
Return the node to public traffic at the load balancer.
The node is upgraded and healthy, and it serves normally from its own group. It does not have to wait for the end of the procedure.
Phase 4: Upgrade the last browsing node
Start this phase only when every other browsing node runs the new version. The last browsing node is now the only member of the group default.
-
Take the node out of public traffic at the load balancer. Wait for its in-flight requests to end.
-
Disable full read-only mode on this node, from this node.
<this-node-url>/modules/tools/maintenance.jsp?fullReadOnlyMode=false -
Deploy the new version through the group
default. Send the request to this node, which is now the only member of that group.curl -u root:<pwd> \ -H "Content-Type: application/json" \ -d '[{"installModule": "mvn:<group-id>/<module>/<new-version>", "target": "default", "autoStart": true}]' \ <this-node-url>/modules/api/provisioningThis upgrades the node, and it writes the new version into the cellar map of
default. Because of this, the nodes return todefaultin phase 5 without a module restart. -
Verify this node runs the new version with the Jahia module state
STARTED, and that it renders a page. -
Enable full read-only mode on this node again.
<this-node-url>/modules/tools/maintenance.jsp?fullReadOnlyMode=true -
Return the node to public traffic at the load balancer.
Phase 5: Return the staged nodes to default
Repeat per staged node. No module restarts during this phase. The map of default now lists the new version, and every node already runs it. The processing node is a staged node too, so return it as well.
-
Put the node back into the group
default.cluster:group-join default <node-id> -
Remove the node from its temporary group, and delete that group.
cluster:group-quit up1 <node-id> cluster:group-delete up1 -
Confirm that no node restarted a module during the rejoin.
Phase 6: Close the operation
-
Clear full read-only mode for the whole cluster. Run this on the processing node.
<processing-node-url>/modules/tools/maintenance.jsp?fullReadOnlyMode=falseConfirm on the same page that every node reports the state OFF.
-
Confirm that
cluster:group-listshows every node indefaultand no temporary group left. -
Confirm that
jahia:clustered-bundle-states -iprints a header and no rows. -
Remove the previous module version later, as an ordinary synchronized operation. Keep it out of this window, and check the cluster again after it.
curl -u root:<pwd> \ -H "Content-Type: application/json" \ -d '[{"uninstallModule": "<group-id>/<module>/<old-version>", "target": "default"}]' \ <node-url>/modules/api/provisioningThis step carries its own risk. Read the traps section before you run it.
Verification
Check these points at the stages named. The REST response is not a reliable signal on its own.
Check the Jahia module state, in addition to the OSGi state. A bundle carries an OSGi state, and a Jahia module carries a second state of its own. A module Jahia refused to register still reports the OSGi state ACTIVE. The bundle runs, the module is out of the registry, and the node serves nothing from that module. Read the Jahia module state, and confirm the reading with a page the module renders.
One call returns both states for one node, and no cluster call is involved:
curl -u root:<pwd> \
<this-node-url>/modules/api/bundles/<group-id>/<module>/<version>/_localInfo
A healthy node answers "osgiState":"ACTIVE" with "moduleState":"STARTED". A node that cannot serve the module answers "osgiState":"ACTIVE" with "moduleState":"WAITING_TO_BE_IMPORTED".
| Stage | What to check | Expected result |
|---|---|---|
| Phases 2 and 3, after the join and before the deploy | The module version on that node | The node still runs the old version. |
| After every deploy | The module version and the Jahia module state on that node | The node runs the new version, and the module state is STARTED. |
| After every deploy, before the node returns to traffic | A page the module renders, requested on that node | The node answers HTTP 200 with the page. |
| After every deploy | The count of stopped modules in each node log | Only the deployed node stopped modules. Every other node stopped none. |
| After every rejoin in phase 5 | The count of stopped modules in each node log | No node stopped a module. |
| Phase 6, and after the uninstall | jahia:clustered-bundle-states -i | The command prints a header and no rows. |
The node log reports a stopped module with the text Stopping DX OSGi bundle. Count those lines per node for the window of the step.
The provisioning endpoint ships in a core bundle, and a module deploy does not restart it, so the call returns its own result. The module manager REST endpoint lives in a module that the deploy restarts, so it answers HTTP 500 with ServiceLocatorImpl … has been shut down while the deploy still succeeds. Confirm the outcome with jahia:clustered-bundle-states in both cases.
Recovery
A module stays RESOLVED on one node
Restart that node. The module keeps a reference to a bundle that no longer exists, and only a restart clears it. A start through the REST API returns success and changes nothing, a start through the Karaf shell starts the module and the module stops again, and a bundle refresh leaves the module RESOLVED.
A node stays in a temporary group
Join the node to default first, then remove it from the temporary group, then delete the group. Join first, because a node that is a member of no group is put back into default at once.
A staged node went back to the old version
The node rejoined default before phase 4. Deploy the new version to that node again through its own group, complete phase 4, and only then run phase 5.
A node reports ACTIVE and serves nothing
Read the Jahia module state on that node. A state of Waiting to be imported by processing server means the processing node has not imported this version. Keep the node out of public traffic, and check that phase 2 completed on the processing node with the module state STARTED. Deploying the version to the processing node is what releases every node in that state, wherever those nodes sit in the cellar groups.
Full read-only mode is inconsistent across the cluster
The maintenance page lists the state per node and reports the inconsistency. Set the intended state from the processing node, because that is the only node whose switch reaches the whole cluster.
Traps and limitations
Node type definitions are shared, and the JCR import is not reversible
The definitions reach every node as soon as the first node is upgraded, and the imported content reaches every node as soon as the processing node is upgraded in phase 2. From phase 2 to the end of phase 4 the cluster runs two module versions against one set of definitions. This is the reason the procedure is limited to a module with no breaking definition change, and the reason a rollback is not a simple downgrade.
A browsing node cannot finish a module upgrade on its own
For this reason, the processing node is upgraded first. If a browsing node is upgraded first, that node stops serving the module. A browsing node that starts a version the processing node has not imported reports the module state Waiting to be imported by processing server. The previous version has already left the registry. The node then renders nothing that the module carries, and the OSGi bundle state of that node still reads ACTIVE.
The cellar groups have no effect on this behavior. The node recovers by itself once the processing node imports the content. The JCR write made by the import replicates through the journal, and that write starts the module on every node waiting for it. Do not rely on this recovery: it happens only when the processing node is upgraded, and the node serves nothing until then.
The mixed version window
Between the first staged deploy and the end of phase 4, nodes run different module versions, and administrators see two versions of the module in the module manager. Jahia also flushes HTML cache entries across the cluster, so a fragment produced under one version can be flushed on a node that runs the other version.
A node must never be upgraded by the cellar synchronizer
When a node joins a group whose map already lists the new version, cellar upgrades that node itself. That path skips the order Jahia applies around a module version change. A node upgraded that way can lose a module later, during the uninstall of the previous version. Giving each node its own new group prevents the case, and the version check before each deploy detects it.
The uninstall of the previous version can strand a module
The uninstall can leave a dependent module in state RESOLVED on one node, and the cluster still reports the operation as successful. The affected module registers rules whose classes load through the uninstalled module. A restart of that node is the only recovery. This is why phase 6 keeps the uninstall separate and requires a check after it.
A deleted group leaves its configuration behind
Deleting a cellar group removes the group name from the group list, and it leaves the properties of that group in the cellar configuration file on every node. The keys are inert, and reusing the same group names overwrites them.
The cluster-wide bundle info call times out
The module manager REST call that returns information for all bundles uses a fixed five second timeout. It fails against the remote nodes on a full bundle list, and it returns a failure entry rather than an error. Use jahia:clustered-bundle-states for verification, or request a single bundle key.