Skip to content

Commit 02bf565

Browse files
authored
tart clone: make pruning limit configurable (#1126)
* tart clone: make pruning limit configurable * Fixed compilation
1 parent 96c89ad commit 02bf565

File tree

2 files changed

+6
-1
lines changed

2 files changed

+6
-1
lines changed

Sources/tart/Commands/Clone.swift

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -31,6 +31,9 @@ struct Clone: AsyncParsableCommand {
3131
@Flag(help: .hidden)
3232
var deduplicate: Bool = false
3333

34+
@Option(help: ArgumentHelp("limit automatic pruning to n gigabytes", valueName: "n"))
35+
var pruneLimit: UInt = 100
36+
3437
func validate() throws {
3538
if newName.contains("/") {
3639
throw ValidationError("<new-name> should be a local name")
@@ -77,7 +80,7 @@ struct Clone: AsyncParsableCommand {
7780
// So, once we clone the VM let's try to claim the rest of space for the VM to run without errors.
7881
let unallocatedBytes = try sourceVM.sizeBytes() - sourceVM.allocatedSizeBytes()
7982
// Avoid reclaiming an excessive amount of disk space.
80-
let reclaimBytes = min(unallocatedBytes, 100 * 1024 * 1024 * 1024)
83+
let reclaimBytes = min(unallocatedBytes, Int(pruneLimit) * 1024 * 1024 * 1024)
8184
if reclaimBytes > 0 {
8285
try Prune.reclaimIfNeeded(UInt64(reclaimBytes), sourceVM)
8386
}

docs/faq.md

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -166,6 +166,8 @@ Tart does have an analogue of Anka Controller for managing VMs across a cluster
166166

167167
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.
168168

169+
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).
170+
169171
To disable this functionality, set the `TART_NO_AUTO_PRUNE` environment variable either globally:
170172

171173
```shell

0 commit comments

Comments
 (0)