Warm update of libraries from the application or via API

Overview

The most commonly used method for updating to a new minor version.

It is performed inside the container by replacing all libraries and assets with the versions from the update archive. The docker container itself is not recreated but stays the same. Therefore the container version also remains the same and may not match the platform version running inside. However, this does not create any risks.

The update file has the name format 'era_<VERSION>_debian_amd64.zip' and contains libraries and assets in the target directory tree. Such an update archive can be applied to any installed version, except for a few cases described below in the "Limitations" section.

Update algorithm

  1. Upload the update file to the system.

  2. Initiate the update preparation process and wait for it to complete.

  3. Initiate update application and wait for it to complete.

  4. Check the system state and wait for it to normalize.

How the update works

Uploading is performed to the web server via the API or the "Settings" administrator application with authorization under the master domain administrator account.

Update preparation consists of copying the archive to all available cluster servers and unpacking it. Archives are placed in the working directories of nodes with active instances of the mic and ic microservices and the server node. The path inside the container: "/var/lib/era/_workdir/<NODE>/autoupdate"). Unpacked directories are placed in the "/usr/lib/era_platform/<VERSION_DIRECTORY>" directory. The whole time preparation is running, the system is active and available. Copying the update is intentionally slowed down so as not to significantly affect network throughput.

The update is applied by changing the symlink /usr/lib/era_platform/era_current to the directory with the updated version on all available cluster servers. Then the root application is unloaded, initiating a restart of the docker container. A previously prepared update can be applied at any time if no other operations (canceling the current update or uploading another update file) were performed since preparation.

The architecture excludes coupling servers and nodes of different versions into a single cluster. Therefore, as the update is applied, nodes with the old version unload and nodes with the new version load without affecting each other. The update completes when all nodes are restarted on the updated version and coupled into one cluster.

On the first start of the updated version, databases are updated by scripts and static assets are moved according to their new placement, in line with the changes.

From the point of view of all target system processes, the update runs from the moment of application to the moment node restarts complete.

State verification is performed by polling /system/state and monitoring nodes and their uptime.

If state monitoring tools are connected to the system, successful completion can also be tracked with their help.

This update can be performed through the master domain administrator application, via the API, or manually inside the container.

Update procedure via the application

Step 1. Log in to the master domain under an account with the "admin" role. Open the "Settings" application:

root

Step 2. Select the "System/Update" section:

up 01 region

Step 3. Upload the archive to the server. Click the upload icon to select a file from disk or use the link, select the file or specify the url (where the update file is available), click "Upload", and wait for the upload to finish. After the upload completes the file name is automatically inserted into the "Update file" field.

up 03 select and upload

Step 4. Initiate preparation for the update by clicking "Prepare":

up 04 wait prepare

Step 5. Preparation is a lengthy procedure; depending on the number of servers it may take 5-10 minutes. The application regularly polls the update process state and displays its output in the left list. The displayed list enumerates the cluster nodes responsible for the update. Each of them goes through the states: idle .. prepare .. ready. Completion of preparation is clear from the "ready" state of all items in the left list:

up 05 prepare finished

Step 6. Once this state is reached (all ready), you can continue the update and initiate a system restart on the new version, or wait for a more suitable moment. For example, waiting for the load to subside or for a maintenance window.

When you click "Apply", a dialog first appears listing all states. It is intended to help avoid hasty update application when not all objects in the list have become ready. This is what a false start looks like:

up 06 false start

This is what the confirmation window looks like in normal mode:

up 08 confirm

Step 7. After confirming the start of the update, the system begins restarting. Both the web server and API access temporarily disappear. In the applications this looks as follows:

up 09 apply

After startup the state of the nodes responsible for the update is displayed again. All servers show the new version:

up 10 after

Step 8. In the "System/Nodes" section you can observe node restarts and uptime resets. By sorting by uptime you can monitor the loading progress. Immediately after restart and for the first 10 minutes the node state is shown with a red icon. For the first hour — with a yellow icon, and after that — with a green icon.

up 11 nodes

Step 9. By switching to the "System/State" section you can get /system/state information. An empty list is the criterion that the update was performed correctly:

up 12 status

Step 10. In the "Home" section, after pressing F5 in the browser, information about the new version is displayed:

up 13 general

Step 11. After 10 minutes no red icons should remain in node monitoring:

up 14 nodes yellow

API

The update process is managed via the master domain API available to accounts with the "admin" role.

Commands:

  • POST /api/admin/v1/update/upload - upload the update file (zip archive).

  • POST /api/admin/v1/update/downloadfrom - download the update file (by the server) from the specified url (zip archive).

  • POST /api/admin/v1/update/prepare - initiate update preparation; requires the update archive name as a parameter.

  • GET /api/admin/v1/update/get_upstate - read the current state of the update (preparation) process.

  • POST /api/admin/v1/update/apply - initiate application of the prepared update.

Separate monitoring API:

Limitations

The described update method cannot be used in the following cases:

  • For a major update (the first version index changes).

  • The docker image underwent significant changes, such as an OS change, a change in the loading method, and others.

  • The update version is lower than or equal to the installed one.

  • Update to 1.12 and newer from a version below 1.11.9: first update the system to 1.11.9 (Rollback to version 1.11).

In these cases, when an update is attempted, the server returns information about the need for an upgrade.

If not all servers are available at the time of the update but the system is operational, the available server set is updated. In this case some microservices may not load and will wait for their followers in order to change the structure of distributed tables in the distributed storage between them. This happens if the unavailable servers host instances of Active-Passive microservices with distributed storage whose tables were changed in the new version.

Unavailable servers must subsequently be deployed from the new version image.

Therefore, when updating with some servers unavailable, it is recommended to immediately activate a configuration where the unavailable servers are disabled or removed.