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(()) }