Skip to content

Commit f9a14b8

Browse files
authored
fix: fly volume fork --require-unique-zone should be default (#3955)
Checking `flag.IsSpecified` makes its default false.
1 parent f086b4f commit f9a14b8

File tree

2 files changed

+17
-6
lines changed

2 files changed

+17
-6
lines changed

internal/command/volumes/fork.go

Lines changed: 1 addition & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -105,11 +105,6 @@ func runFork(ctx context.Context) error {
105105
machinesOnly = fly.Pointer(flag.GetBool(ctx, "machines-only"))
106106
}
107107

108-
var requireUniqueZone *bool
109-
if flag.IsSpecified(ctx, "require-unique-zone") {
110-
requireUniqueZone = fly.Pointer(flag.GetBool(ctx, "require-unique-zone"))
111-
}
112-
113108
region := flag.GetString(ctx, "region")
114109

115110
var attachedMachineImage string
@@ -131,7 +126,7 @@ func runFork(ctx context.Context) error {
131126
input := fly.CreateVolumeRequest{
132127
Name: name,
133128
MachinesOnly: machinesOnly,
134-
RequireUniqueZone: requireUniqueZone,
129+
RequireUniqueZone: fly.Pointer(flag.GetBool(ctx, "require-unique-zone")),
135130
SourceVolumeID: &vol.ID,
136131
ComputeRequirements: computeRequirements,
137132
ComputeImage: attachedMachineImage,

test/preflight/fly_volume_test.go

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -35,6 +35,7 @@ func TestVolume(t *testing.T) {
3535
t.Run("Extend", WithParallel(testVolumeExtend))
3636
t.Run("List", WithParallel(testVolumeLs))
3737
t.Run("CreateFromDestroyedVolSnapshot", WithParallel(testVolumeCreateFromDestroyedVolSnapshot))
38+
t.Run("Fork", WithParallel(testVolumeFork))
3839
}
3940

4041
func testVolumeExtend(t *testing.T) {
@@ -122,6 +123,21 @@ func testVolumeLs(t *testing.T) {
122123
}, 5*time.Minute, 10*time.Second)
123124
}
124125

126+
func testVolumeFork(t *testing.T) {
127+
f := testlib.NewTestEnvFromEnv(t)
128+
appName := f.CreateRandomAppMachines()
129+
130+
var original *fly.Volume
131+
j := f.Fly("vol create --json --app %s --region %s --yes foobar", appName, f.PrimaryRegion())
132+
j.StdOutJSON(&original)
133+
134+
var fork *fly.Volume
135+
j = f.Fly("vol fork --json --app %s --region %s %s", appName, f.PrimaryRegion(), original.ID)
136+
j.StdOutJSON(&fork)
137+
138+
assert.NotEqual(t, original.Zone, fork.Zone, "forked volume should be in a different zone")
139+
}
140+
125141
func testVolumeCreateFromDestroyedVolSnapshot(tt *testing.T) {
126142
t := testLogger{tt}
127143

0 commit comments

Comments
 (0)