From 02bf5651e7f59d576706a75901537b42e333bb06 Mon Sep 17 00:00:00 2001 From: Fedor Korotkov Date: Sun, 14 Sep 2025 12:38:57 -0400 Subject: [PATCH] tart clone: make pruning limit configurable (#1126) * tart clone: make pruning limit configurable * Fixed compilation --- Sources/tart/Commands/Clone.swift | 5 ++++- docs/faq.md | 2 ++ 2 files changed, 6 insertions(+), 1 deletion(-) diff --git a/Sources/tart/Commands/Clone.swift b/Sources/tart/Commands/Clone.swift index a6064c6..0b38850 100644 --- a/Sources/tart/Commands/Clone.swift +++ b/Sources/tart/Commands/Clone.swift @@ -31,6 +31,9 @@ struct Clone: AsyncParsableCommand { @Flag(help: .hidden) var deduplicate: Bool = false + @Option(help: ArgumentHelp("limit automatic pruning to n gigabytes", valueName: "n")) + var pruneLimit: UInt = 100 + func validate() throws { if newName.contains("/") { throw ValidationError(" should be a local name") @@ -77,7 +80,7 @@ struct Clone: AsyncParsableCommand { // So, once we clone the VM let's try to claim the rest of space for the VM to run without errors. let unallocatedBytes = try sourceVM.sizeBytes() - sourceVM.allocatedSizeBytes() // Avoid reclaiming an excessive amount of disk space. - let reclaimBytes = min(unallocatedBytes, 100 * 1024 * 1024 * 1024) + let reclaimBytes = min(unallocatedBytes, Int(pruneLimit) * 1024 * 1024 * 1024) if reclaimBytes > 0 { try Prune.reclaimIfNeeded(UInt64(reclaimBytes), sourceVM) } diff --git a/docs/faq.md b/docs/faq.md index 0ef4dd6..a4a9dfe 100644 --- a/docs/faq.md +++ b/docs/faq.md @@ -166,6 +166,8 @@ Tart does have an analogue of Anka Controller for managing VMs across a cluster In case there's not enough space to fit the newly pulled or cloned VM image, Tart will remove the least recently accessed VMs from OCI cache and `.ipsw` files from IPSW cache until enough free space is available. +The `tart clone` command limits this automatic pruning to 100 GB by default to avoid removing too many cached items. You can change this limit with the `--prune-limit` option (in gigabytes). + To disable this functionality, set the `TART_NO_AUTO_PRUNE` environment variable either globally: ```shell