From 7f7cca16fa476c769beab8677e313b16af82e6dd Mon Sep 17 00:00:00 2001 From: Alex Lyn Date: Thu, 9 Apr 2026 15:47:22 +0800 Subject: [PATCH] kata-deploy: Complete containerd config for erofs snapshotter Add missing containerd configuration items for erofs snapshotter to enable fsmerged erofs feature: Add snapshotter plugin configuration: - default_size: "10G" # can be customized - max_unmerged_layers: 1 # Fixed with 1 These configurations align with the documentation in docs/how-to/how-to-use-fsmerged-erofs-with-kata.md Step 2, ensuring the CI workflow run-k8s-tests-coco-nontee-with-erofs-snapshotter can properly configure containerd for erofs fsmerged rootfs. Signed-off-by: Alex Lyn --- .../binary/src/artifacts/snapshotters.rs | 42 +++++++++++++++++-- 1 file changed, 38 insertions(+), 4 deletions(-) diff --git a/tools/packaging/kata-deploy/binary/src/artifacts/snapshotters.rs b/tools/packaging/kata-deploy/binary/src/artifacts/snapshotters.rs index fb49f35d5a..c757bcdd97 100644 --- a/tools/packaging/kata-deploy/binary/src/artifacts/snapshotters.rs +++ b/tools/packaging/kata-deploy/binary/src/artifacts/snapshotters.rs @@ -12,10 +12,7 @@ use log::info; use std::fs; use std::path::Path; -pub async fn configure_erofs_snapshotter( - _config: &Config, - configuration_file: &Path, -) -> Result<()> { +pub async fn configure_erofs_snapshotter(config: &Config, configuration_file: &Path) -> Result<()> { info!("Configuring erofs-snapshotter"); toml_utils::set_toml_value( @@ -40,6 +37,43 @@ pub async fn configure_erofs_snapshotter( ".plugins.\"io.containerd.snapshotter.v1.erofs\".set_immutable", "true", )?; + // Turn off fsmerge unless we are configuring for a Rust shim below. Writing 0 + // first keeps behavior explicit and resets a stale max_unmerged_layers in this + // drop-in after switching away from Rust / fsmerged EROFS on the same node. + toml_utils::set_toml_value( + configuration_file, + ".plugins.\"io.containerd.snapshotter.v1.erofs\".max_unmerged_layers", + "0", + )?; + + // The remaining settings only apply to runtime-rs (rust shim) which + // supports fsmerged EROFS. The go runtime does not, so we leave the + // differ and snapshotter plugins at their defaults for it. + let is_rust_shim = config.shims_for_arch.iter().any(|s| utils::is_rust_shim(s)); + if is_rust_shim { + // Erofs differ plugin options (requires erofs-utils >= 1.8.2 on the host). + toml_utils::set_toml_value( + configuration_file, + ".plugins.\"io.containerd.differ.v1.erofs\".mkfs_options", + "[\"-T0\",\"--mkfs-time\",\"--sort=none\"]", + )?; + toml_utils::set_toml_value( + configuration_file, + ".plugins.\"io.containerd.differ.v1.erofs\".enable_tar_index", + "false", + )?; + + toml_utils::set_toml_value( + configuration_file, + ".plugins.\"io.containerd.snapshotter.v1.erofs\".default_size", + "\"10G\"", + )?; + toml_utils::set_toml_value( + configuration_file, + ".plugins.\"io.containerd.snapshotter.v1.erofs\".max_unmerged_layers", + "1", + )?; + } Ok(()) }