Skip to content

Commit 6d45c3d

Browse files
authored
Merge pull request #208437 from bishal41/Module-Image-Garbage-Collection
Image garbage collection
2 parents c071648 + 78c5cf0 commit 6d45c3d

File tree

2 files changed

+54
-4
lines changed

2 files changed

+54
-4
lines changed

articles/iot-edge/iot-edge-modules.md

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -19,8 +19,8 @@ Azure IoT Edge lets you deploy and manage business logic on the edge in the form
1919

2020
* A **module image** is a package containing the software that defines a module.
2121
* A **module instance** is the specific unit of computation running the module image on an IoT Edge device. The module instance is started by the IoT Edge runtime.
22-
* A **module identity** is a piece of information (including security credentials) stored in IoT Hub, that is associated to each module instance.
23-
* A **module twin** is a JSON document stored in IoT Hub, that contains state information for a module instance, including metadata, configurations, and conditions.
22+
* A **module identity** is a piece of information (including security credentials) stored in IoT Hub that is associated to each module instance.
23+
* A **module twin** is a JSON document stored in IoT Hub that contains state information for a module instance, including metadata, configurations, and conditions.
2424

2525
## Module images and instances
2626

@@ -63,7 +63,6 @@ await client.OpenAsync();
6363
// Get the module twin
6464
Twin twin = await client.GetTwinAsync();
6565
```
66-
6766
## Offline capabilities
6867

6968
Azure IoT Edge modules can operate offline indefinitely after syncing with IoT Hub at least once. IoT Edge devices can also extend this offline capability to other IoT devices. For more information, see [Understand extended offline capabilities for IoT Edge devices, modules, and child devices](offline-capabilities.md).

articles/iot-edge/production-checklist.md

Lines changed: 52 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -88,6 +88,7 @@ Once your IoT Edge device connects, be sure to continue configuring the Upstream
8888
* Reduce memory space used by the IoT Edge hub
8989
* Use correct module images in deployment manifests
9090
* Be mindful of twin size limits when using custom modules
91+
* Configure how updates to modules are applied
9192

9293
### Be consistent with upstream protocol
9394

@@ -148,13 +149,38 @@ If you deploy a large number of modules, you might exhaust this twin size limit.
148149
- Store any configuration in the custom module twin, which has its own limit.
149150
- Store some configuration that points to a non-space-limited location (that is, to a blob store).
150151

151-
## Container management
152+
::: moniker range=">=iotedge-1.4"
153+
### Configure how updates to modules are applied
154+
When a deployment is updated, Edge Agent receives the new configuration as a twin update. If the new configuration has new or updated module images, by default, Edge Agent sequentially processes each module:
155+
1. The updated image is downloaded
156+
1. The running module is stopped
157+
1. A new module instance is started
158+
1. The next module update is processed
159+
160+
In some cases, for example when dependencies exist between modules, it may be desirable to first download all updated module images before restarting any running modules. This module update behavior can be configured by setting an IoT Edge Agent environment variable `ModuleUpdateMode` to string value `WaitForAllPulls`. For more information, see [IoT Edge Environment Variables](https://github.com/Azure/iotedge/blob/main/doc/EnvironmentVariables.md).
161+
162+
```JSON
163+
"modulesContent": {
164+
"$edgeAgent": {
165+
"properties.desired": {
166+
...
167+
"systemModules": {
168+
"edgeAgent": {
169+
"env": {
170+
"ModuleUpdateMode": {
171+
"value": "WaitForAllPulls"
172+
}
173+
...
174+
```
175+
::: moniker-end
176+
### Container management
152177

153178
* **Important**
154179
* Use tags to manage versions
155180
* Manage volumes
156181
* **Helpful**
157182
* Store runtime containers in your private registry
183+
* Configure image garbage collection
158184

159185
### Use tags to manage versions
160186

@@ -194,6 +220,31 @@ Next, be sure to update the image references in the deployment.template.json fil
194220

195221
`"image": "<registry name and server>/azureiotedge-hub:1.1",`
196222

223+
::: moniker range=">=iotedge-1.4"
224+
### Configure image garbage collection
225+
Image garbage collection is a feature in IoT Edge v1.4 and later to automatically clean up Docker images that are no longer used by IoT Edge modules. It only deletes Docker images that were pulled by the IoT Edge runtime as part of a deployment. Deleting unused Docker images helps conserve disk space.
226+
227+
The feature is implemented in IoT Edge's host component, the `aziot-edged` service and enabled by default. Cleanup is done every day at midnight (device local time) and removes unused Docker images that were last used seven days ago. The parameters to control cleanup behavior are set in the `config.toml` and explained later in this section. If parameters aren't specified in the configuration file, the default values are applied.
228+
229+
For example, the following is the `config.toml` image garbage collection section using default values:
230+
231+
```toml
232+
[image_garbage_collection]
233+
enabled = true
234+
cleanup_recurrence = "1d"
235+
image_age_cleanup_threshold = "7d"
236+
cleanup_time = "00:00"
237+
```
238+
The following table describes image garbage collection parameters. All parameters are **optional** and can be set individually to change the default settings.
239+
240+
| Parameter | Description | Required | Default value |
241+
|-----------|-------------|----------|---------------|
242+
| `enabled` | Enables the image garbage collection. You may choose to disable the feature by changing this setting to `false`. | Optional | true |
243+
| `cleanup_recurrence` | Controls the recurrence frequency of the cleanup task. Must be specified as a multiple of days and can't be less than one day. <br><br> For example: 1d, 2d, 6d, etc. | Optional | 1d |
244+
| `image_age_cleanup_threshold` | Defines the minimum age threshold of unused images before considering for cleanup and must be specified in days. You can specify as *0d* to clean up the images as soon as they're removed from the deployment. <br><br> Images are considered unused *after* they've been removed from the deployment. | Optional | 7d |
245+
| `cleanup_time` | Time of day, *in device local time*, when the cleanup task runs. Must be in 24-hour HH:MM format. | Optional | 00:00 |
246+
247+
::: moniker-end
197248
## Networking
198249

199250
* **Helpful**

0 commit comments

Comments
 (0)