Skip to content

machine: add --cachedrive-size flag to run and update#4805

Merged
dangra merged 1 commit intomasterfrom
machine-cache-drive
Apr 7, 2026
Merged

machine: add --cachedrive-size flag to run and update#4805
dangra merged 1 commit intomasterfrom
machine-cache-drive

Conversation

@dangra
Copy link
Copy Markdown
Member

@dangra dangra commented Apr 7, 2026

Summary

  • Adds --cachedrive-size to sharedFlags (available on both fly machine run and fly machine update)
  • Accepts a plain number in MB or human-readable size (e.g. 512mb, 10gb)
  • Setting --cachedrive-size 0 disables the cache drive (CacheDrive set to nil)
  • Bumps fly-go to v0.4.3 which includes the MachineCacheDrive type

Test plan

  • fly machine run --cachedrive-size 1024 <image> — boots with a 1 GB cache drive
  • fly machine update --cachedrive-size 2gb <id> — updates existing machine with a 2 GB cache drive
  • fly machine update --cachedrive-size 0 <id> — removes cache drive
  • Invalid size (e.g. --cachedrive-size -1) returns a clear error

Copilot AI review requested due to automatic review settings April 7, 2026 21:23
Copy link
Copy Markdown

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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-size to shared machine flags with human-readable size parsing.
  • Apply --cachedrive-size during machine config determination, including 0CacheDrive=nil.
  • Bump github.com/superfly/fly-go dependency to v0.4.3 to pick up MachineCacheDrive.

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.

Comment on lines +765 to +777
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)}
}
Copy link

Copilot AI Apr 7, 2026

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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.

Copilot uses AI. Check for mistakes.
@dangra dangra merged commit 0576dbd into master Apr 7, 2026
28 checks passed
@dangra dangra deleted the machine-cache-drive branch April 7, 2026 21:57
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants