Skip to content

Commit 46a3047

Browse files
pipexgitbook-bot
authored andcommitted
GITBOOK-217: Fix update strategy documentation
1 parent 1f9a4e4 commit 46a3047

1 file changed

Lines changed: 13 additions & 17 deletions

File tree

pages/learn/deploy/release-strategy/update-strategies.md

Lines changed: 13 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@ excerpt: Choosing an update strategy for your balena devices
55

66
# Controlling the update strategy
77

8-
With the balena device supervisor version 1.3, we added the ability to choose the update strategy on devices, that is, the order and way in which the steps to perform an update are executed. You can check whether your Supervisor has the appropriate version in the "Supervisor version" entry in the device dashboard page. These update strategies allow users to choose between four modes that are suited for different applications, depending on available resources and the possible need to have a container running at all times.
8+
It is possible to control the order and way in which the steps to perform an update are executed by the balena device supervisor by defining a specific _update strategy_. The strategy allow users to choose between four modes that are suited for different applications, depending on available resources and the possible need to have a container running at all times.
99

1010
Update strategies can be applied by setting a [docker-compose label](../../../reference/supervisor/docker-compose.md#labels). The two labels that are involved are:
1111

@@ -21,28 +21,26 @@ Setting the `io.balena.update.strategy` label to a valid value selects the updat
2121

2222
which are explained below. The `io.balena.update.handover-timeout` label is only used in the `hand-over` strategy, and its use is explained in the [strategy's description](update-strategies.md#hand-over).
2323

24-
{% hint style="warning" %}
25-
Prior to balena Supervisor v7.23.0 the strategy was controlled by two configuration variables, `RESIN_SUPERVISOR_UPDATE_STRATEGY` and `RESIN_SUPERVISOR_HANDOVER_TIMEOUT`, which had the same effect as the labels do today. This mechanism for controlling the strategy is considered _deprecated_ and may be removed in the future.
26-
{% endhint %}
27-
28-
All update strategies below honor the [fleet update locks](../../../external-docs/update-locking.md) which you can use prevent updates temporarily.
24+
All update strategies below honor the [device update locks](update-locking.md) which you can use prevent updates temporarily.
2925

3026
## download-then-kill
3127

3228
This is the default strategy, and it is selected if the variable is not set or if it has an invalid value. Its behavior corresponds to the way balena traditionally works:
3329

34-
* When an update is available, the Supervisor downloads the new container image.
35-
* Once the download is complete, the Supervisor kills the container for the old version.
36-
* Immediately afterwards, the Supervisor creates and starts the container for the new version, and then deletes the old image.
30+
* When an update is available, the Supervisor downloads the new service image.
31+
* Once the download is complete, the Supervisor kills the container for the old service version.
32+
* Immediately afterwards, the Supervisor creates and starts the container for the new service version, and then deletes the old image.
3733

3834
This strategy is suited for the general case of container update, where resources are not particularly constrained (as pulling the new image while the old container runs takes up some extra RAM), and when a zero-downtime update is not necessary but we still want to keep downtime to a minimum.
3935

36+
Is important to notice that the while the strategy is set per service, the supervisor waits until all images for the target release have been downloaded before killing any running services. 
37+
4038
## kill-then-download
4139

4240
This strategy is meant for resource-constrained scenarios or when the images be pulled are particularly large, so we need to keep RAM usage to the minimum, albeit at the cost of some extra downtime. It works as follows:
4341

44-
* When an update is available, the Supervisor kills the container for the old version.
45-
* After this, the Supervisor downloads the image for the new version.
42+
* When an update is available, the Supervisor kills the container for the old service version.
43+
* After this, the Supervisor downloads the image for the new service version.
4644
* Once the download is complete, the Supervisor creates and starts the new container, and deletes the old image from disk.
4745

4846
## delete-then-download
@@ -57,19 +55,17 @@ This strategy is meant for resource-constrained scenarios or when the images be
5755
This strategy is only recommended for extreme low storage scenarios, where the available storage cannot even fit the target [image deltas](../delta.md). For most cases, using the default strategy or the `kill-then-download` strategy (if memory usage is a concern), and ensuring [deltas are enabled](../delta.md) is the recommended approach.
5856
{% endhint %}
5957

60-
{% hint style="warning" %}
61-
**Requires Supervisor >= v2.5.1**
62-
{% endhint %}
63-
6458
## hand-over
6559

6660
This strategy is suited for scenarios where there are enough resources and it is critical that the downtime is _zero_, that is, that the app runs continually even during an update. For this strategy to work properly, the user has to consider the way the update works and include code to perform a handover between the old and new releases. Its behavior is as follows:
6761

6862
* When an update is available, the Supervisor downloads the new image.
6963
* When the download is complete, the Supervisor creates and starts the new container, _without killing the old one_.
7064
* The old and new releases should communicate between each other so that the old one frees any resources that the new one needs (e.g. device files, database locks, etc) and the new version can start running fully.
71-
* Once this "handover" is performed between the releases (old or new), your service must signal to the Supervisor that the old version is ready to be killed, by creating a file at `/data/resin-kill-me`.
65+
* Once this "handover" is performed between the releases (old or new), your service must signal to the Supervisor that the old version is ready to be killed, by creating a file at the path configured under the environment variable `BALENA_SERVICE_HANDOVER_COMPLETE_PATH`.
7266
* When the Supervisor detects that the file has been created, the Supervisor kills the old container and deletes it from disk.
7367
* If the file is not created after a time defined by the `io.balena.update.handover-timeout` label, the Supervisor kills the old version.
7468

75-
The `io.balena.update.handover-timeout` label defines this timeout in milliseconds, and defaults to 60000 (i.e. 1 minute). The communication between the old and new versions has to be implemented by the user in whatever way they see fit, for example by having the old version listen on a socket or port and having an endpoint for the new version to announce it's ready to take over. It is important to note that both versions will share the `/data` folder and network namespace, so they can use any of those to communicate.
69+
The `io.balena.update.handover-timeout` label defines this timeout in milliseconds, and defaults to 60000 (i.e. 1 minute). The communication between the old and new versions has to be implemented by the user in whatever way they see fit, for example by having the old version listen on a socket or port and having an endpoint for the new version to announce it's ready to take over. It is important to note that both versions will share the folder at `BALENA_SERVICE_HANDOVER_COMPLETE_PATH` and the network namespace, so they can use any of those to communicate.  
70+
71+
It's also important to note that because the handover requires both the current and target service containers to run at the same time, they cannot configure conflicting resources, for instance, if the old container exposes a port on the host network, the new container will fail to start with a `port is already allocated` error.

0 commit comments

Comments
 (0)