Skip to content

Commit 851abbc

Browse files
authored
Disable discard_unpacked_layers for containerd >= 2.1 (#12821)
Only set `discard_unpacked_layers` in the CRI image config for containerd versions earlier than 2.1.0. Starting with containerd v2.1, the CRI plugin uses the Transfer Service for image pulls by default. The `discard_unpacked_layers` option is incompatible with the Transfer Service and triggers containerd to fall back to local image pulls, logging a warning. This change prevents unsupported configuration from being applied on newer containerd versions, avoiding runtime warnings and ensuring default image pull behavior. Signed-off-by: Ali Afsharzadeh <afsharzadeh8@gmail.com>
1 parent 17c7236 commit 851abbc

2 files changed

Lines changed: 4 additions & 2 deletions

File tree

roles/container-engine/containerd/defaults/main.yml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -35,8 +35,8 @@ containerd_default_base_runtime_spec_patch:
3535
hard: "{{ containerd_base_runtime_spec_rlimit_nofile }}"
3636
soft: "{{ containerd_base_runtime_spec_rlimit_nofile }}"
3737

38-
# Can help reduce disk usage
39-
# https://github.com/containerd/containerd/discussions/6295
38+
# Only for containerd < 2.1; discard unpacked layers to save disk space
39+
# https://github.com/containerd/containerd/blob/release/2.1/docs/cri/config.md#image-pull-configuration-since-containerd-v21
4040
containerd_discard_unpacked_layers: true
4141

4242
containerd_base_runtime_specs:

roles/container-engine/containerd/templates/config.toml.j2

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -76,7 +76,9 @@ oom_score = {{ containerd_oom_score }}
7676

7777
[plugins."io.containerd.cri.v1.images"]
7878
snapshotter = "{{ containerd_snapshotter }}"
79+
{% if containerd_discard_unpacked_layers and containerd_version is version('2.1.0', '<') %}
7980
discard_unpacked_layers = {{ containerd_discard_unpacked_layers | lower }}
81+
{% endif %}
8082
image_pull_progress_timeout = "{{ containerd_image_pull_progress_timeout }}"
8183
[plugins."io.containerd.cri.v1.images".pinned_images]
8284
sandbox = "{{ pod_infra_image_repo }}:{{ pod_infra_image_tag }}"

0 commit comments

Comments
 (0)