Skip to content

Commit 6028125

Browse files
committed
Fix conversion of BFV images
Root volumes in v1alpha4 can only specify root volume image by UUID. We were translating this to use Image from the parent, which requires a name, not a UUID. In v1alpha5 we can also have the ImageUUID field, so we translate to that instead.
1 parent 944b265 commit 6028125

File tree

2 files changed

+24
-5
lines changed

2 files changed

+24
-5
lines changed

api/v1alpha4/conversion.go

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -250,7 +250,7 @@ func Convert_v1alpha4_Instance_To_v1alpha5_Instance(in *Instance, out *infrav1.I
250250
return err
251251
}
252252
if in.RootVolume != nil && in.RootVolume.Size > 0 {
253-
out.Image = in.RootVolume.SourceUUID
253+
out.ImageUUID = in.RootVolume.SourceUUID
254254
}
255255
return nil
256256
}
@@ -260,7 +260,7 @@ func Convert_v1alpha5_Instance_To_v1alpha4_Instance(in *infrav1.Instance, out *I
260260
return err
261261
}
262262
if in.RootVolume != nil && in.RootVolume.Size > 0 {
263-
out.RootVolume.SourceUUID = in.Image
263+
out.RootVolume.SourceUUID = in.ImageUUID
264264
out.Image = ""
265265
}
266266
return nil
@@ -271,7 +271,7 @@ func Convert_v1alpha4_OpenStackMachineSpec_To_v1alpha5_OpenStackMachineSpec(in *
271271
return err
272272
}
273273
if in.RootVolume != nil && in.RootVolume.Size > 0 {
274-
out.Image = in.RootVolume.SourceUUID
274+
out.ImageUUID = in.RootVolume.SourceUUID
275275
}
276276
return nil
277277
}
@@ -281,7 +281,7 @@ func Convert_v1alpha5_OpenStackMachineSpec_To_v1alpha4_OpenStackMachineSpec(in *
281281
return err
282282
}
283283
if in.RootVolume != nil && in.RootVolume.Size > 0 {
284-
out.RootVolume.SourceUUID = in.Image
284+
out.RootVolume.SourceUUID = in.ImageUUID
285285
out.Image = ""
286286
}
287287
return nil

api/v1alpha4/conversion_test.go

Lines changed: 20 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -270,7 +270,26 @@ func TestFuzzyConversion(t *testing.T) {
270270
func(v1alpha5MachineSpec *infrav1.OpenStackMachineSpec, c fuzz.Continue) {
271271
c.FuzzNoCustom(v1alpha5MachineSpec)
272272

273-
v1alpha5MachineSpec.ImageUUID = ""
273+
// In v1alpha4 boot from volume only supports
274+
// image by UUID, and boot from local only
275+
// suppots image by name
276+
if v1alpha5MachineSpec.RootVolume != nil && v1alpha5MachineSpec.RootVolume.Size > 0 {
277+
v1alpha5MachineSpec.Image = ""
278+
} else {
279+
v1alpha5MachineSpec.ImageUUID = ""
280+
}
281+
},
282+
func(v1alpha5Instance *infrav1.Instance, c fuzz.Continue) {
283+
c.FuzzNoCustom(v1alpha5Instance)
284+
285+
// In v1alpha4 boot from volume only supports
286+
// image by UUID, and boot from local only
287+
// suppots image by name
288+
if v1alpha5Instance.RootVolume != nil && v1alpha5Instance.RootVolume.Size > 0 {
289+
v1alpha5Instance.Image = ""
290+
} else {
291+
v1alpha5Instance.ImageUUID = ""
292+
}
274293
},
275294
func(v1alpha5RootVolume *infrav1.RootVolume, c fuzz.Continue) {
276295
c.FuzzNoCustom(v1alpha5RootVolume)

0 commit comments

Comments
 (0)