machine: add --cachedrive-size flag to run and update#4805
Conversation
There was a problem hiding this comment.
Pull request overview
Adds support for configuring a Machine cache drive size via CLI flags on both fly machine run and fly machine update, including disabling the cache drive by setting the size to 0.
Changes:
- Add
--cachedrive-sizeto shared machine flags with human-readable size parsing. - Apply
--cachedrive-sizeduring machine config determination, including0→CacheDrive=nil. - Bump
github.com/superfly/fly-godependency to v0.4.3 to pick upMachineCacheDrive.
Reviewed changes
Copilot reviewed 2 out of 3 changed files in this pull request and generated 1 comment.
| File | Description |
|---|---|
| internal/command/machine/run.go | Introduces the --cachedrive-size flag and updates config building to set/unset CacheDrive. |
| go.mod | Updates fly-go dependency to v0.4.3 for cache drive type support. |
| go.sum | Updates module checksums for the fly-go v0.4.3 bump. |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
| if flag.IsSpecified(ctx, "cachedrive-size") { | ||
| sizeMB, err := helpers.ParseSize(flag.GetString(ctx, "cachedrive-size"), units.RAMInBytes, units.MiB) | ||
| if err != nil { | ||
| return machineConf, fmt.Errorf("invalid cachedrive size: %w", err) | ||
| } | ||
| if sizeMB < 0 { | ||
| return machineConf, fmt.Errorf("--cachedrive-size must not be negative") | ||
| } | ||
| if sizeMB == 0 { | ||
| machineConf.CacheDrive = nil | ||
| } else { | ||
| machineConf.CacheDrive = &fly.MachineCacheDrive{SizeMB: uint64(sizeMB)} | ||
| } |
There was a problem hiding this comment.
The new --cachedrive-size behavior (parsing sizes, applying to machineConf.CacheDrive, and supporting 0 to remove it) isn’t covered by the existing preflight integration tests. There are already similar flag tests (e.g. TestFlyMachineRun_rootfsSize in test/preflight/fly_machine_test.go); please add coverage for run/update/remove cases and a negative/invalid input case to prevent regressions.
Summary
--cachedrive-sizetosharedFlags(available on bothfly machine runandfly machine update)512mb,10gb)--cachedrive-size 0disables the cache drive (CacheDriveset to nil)fly-goto v0.4.3 which includes theMachineCacheDrivetypeTest plan
fly machine run --cachedrive-size 1024 <image>— boots with a 1 GB cache drivefly machine update --cachedrive-size 2gb <id>— updates existing machine with a 2 GB cache drivefly machine update --cachedrive-size 0 <id>— removes cache drive--cachedrive-size -1) returns a clear error