Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix: fly volume fork --require-unique-zone should be default #3955

Merged
merged 1 commit into from
Sep 20, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
7 changes: 1 addition & 6 deletions internal/command/volumes/fork.go
Original file line number Diff line number Diff line change
Expand Up @@ -105,11 +105,6 @@ func runFork(ctx context.Context) error {
machinesOnly = fly.Pointer(flag.GetBool(ctx, "machines-only"))
}

var requireUniqueZone *bool
if flag.IsSpecified(ctx, "require-unique-zone") {
requireUniqueZone = fly.Pointer(flag.GetBool(ctx, "require-unique-zone"))
}

region := flag.GetString(ctx, "region")

var attachedMachineImage string
Expand All @@ -131,7 +126,7 @@ func runFork(ctx context.Context) error {
input := fly.CreateVolumeRequest{
Name: name,
MachinesOnly: machinesOnly,
RequireUniqueZone: requireUniqueZone,
RequireUniqueZone: fly.Pointer(flag.GetBool(ctx, "require-unique-zone")),
SourceVolumeID: &vol.ID,
ComputeRequirements: computeRequirements,
ComputeImage: attachedMachineImage,
Expand Down
16 changes: 16 additions & 0 deletions test/preflight/fly_volume_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,7 @@ func TestVolume(t *testing.T) {
t.Run("Extend", WithParallel(testVolumeExtend))
t.Run("List", WithParallel(testVolumeLs))
t.Run("CreateFromDestroyedVolSnapshot", WithParallel(testVolumeCreateFromDestroyedVolSnapshot))
t.Run("Fork", WithParallel(testVolumeFork))
}

func testVolumeExtend(t *testing.T) {
Expand Down Expand Up @@ -122,6 +123,21 @@ func testVolumeLs(t *testing.T) {
}, 5*time.Minute, 10*time.Second)
}

func testVolumeFork(t *testing.T) {
f := testlib.NewTestEnvFromEnv(t)
appName := f.CreateRandomAppMachines()

var original *fly.Volume
j := f.Fly("vol create --json --app %s --region %s --yes foobar", appName, f.PrimaryRegion())
j.StdOutJSON(&original)

var fork *fly.Volume
j = f.Fly("vol fork --json --app %s --region %s %s", appName, f.PrimaryRegion(), original.ID)
j.StdOutJSON(&fork)

assert.NotEqual(t, original.Zone, fork.Zone, "forked volume should be in a different zone")
}

func testVolumeCreateFromDestroyedVolSnapshot(tt *testing.T) {
t := testLogger{tt}

Expand Down
Loading