Skip to content

Commit 2f40ac8

Browse files
Matt PryorEmilienM
Matt Pryor
authored andcommitted
UPSTREAM 1668: Additional data volumes for machines
We now have the ability for a machine to have additional block devices to be attached. Here is an example on how to use `additionalBlockDevices` for adding additional Cinder volumes attached to the server instance: ```yaml additionalBlockDevices: - nameSuffix: dbvol1 size: 50 volumeType: my-volume-type availabilityZone: az0 tag: database ``` Co-authored-by: Matt Pryor <[email protected]> Co-authored-by: Emilien Macchi <[email protected]> (cherry picked from commit 94d9690)
1 parent 084aab5 commit 2f40ac8

19 files changed

+668
-194
lines changed

api/v1alpha5/conversion.go

+4
Original file line numberDiff line numberDiff line change
@@ -433,3 +433,7 @@ func Convert_v1alpha5_OpenStackClusterStatus_To_v1alpha7_OpenStackClusterStatus(
433433

434434
return nil
435435
}
436+
437+
func Convert_v1alpha7_OpenStackMachineSpec_To_v1alpha5_OpenStackMachineSpec(in *infrav1.OpenStackMachineSpec, out *OpenStackMachineSpec, s conversion.Scope) error {
438+
return autoConvert_v1alpha7_OpenStackMachineSpec_To_v1alpha5_OpenStackMachineSpec(in, out, s)
439+
}

api/v1alpha5/zz_generated.conversion.go

+6-10
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

api/v1alpha6/conversion.go

+7-4
Original file line numberDiff line numberDiff line change
@@ -60,13 +60,12 @@ func restorev1alpha7MachineSpec(previous *infrav1.OpenStackMachineSpec, dst *inf
6060
// PropagateUplinkStatus has been added in v1alpha7.
6161
// We restore the whole Ports since they are anyway immutable.
6262
dst.Ports = previous.Ports
63+
dst.AdditionalBlockDevices = previous.AdditionalBlockDevices
6364
}
6465

6566
func restorev1alpha7Bastion(previous **infrav1.Bastion, dst **infrav1.Bastion) {
66-
// PropagateUplinkStatus has been added in v1alpha7.
67-
// We restore the whole Ports since they are anyway immutable.
68-
if *previous != nil && (*previous).Instance.Ports != nil && *dst != nil && (*dst).Instance.Ports != nil {
69-
(*dst).Instance.Ports = (*previous).Instance.Ports
67+
if *previous != nil && *dst != nil {
68+
restorev1alpha7MachineSpec(&(*previous).Instance, &(*dst).Instance)
7069
}
7170
}
7271

@@ -646,3 +645,7 @@ func Convert_v1alpha6_OpenStackClusterStatus_To_v1alpha7_OpenStackClusterStatus(
646645

647646
return nil
648647
}
648+
649+
func Convert_v1alpha7_OpenStackMachineSpec_To_v1alpha6_OpenStackMachineSpec(in *infrav1.OpenStackMachineSpec, out *OpenStackMachineSpec, s apiconversion.Scope) error {
650+
return autoConvert_v1alpha7_OpenStackMachineSpec_To_v1alpha6_OpenStackMachineSpec(in, out, s)
651+
}

api/v1alpha6/zz_generated.conversion.go

+6-10
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

api/v1alpha7/openstackmachine_types.go

+5
Original file line numberDiff line numberDiff line change
@@ -84,6 +84,11 @@ type OpenStackMachineSpec struct {
8484
// The volume metadata to boot from
8585
RootVolume *RootVolume `json:"rootVolume,omitempty"`
8686

87+
// AdditionalBlockDevices is a list of specifications for additional block devices to attach to the server instance
88+
// +listType=map
89+
// +listMapKey=name
90+
AdditionalBlockDevices []AdditionalBlockDevice `json:"additionalBlockDevices,omitempty"`
91+
8792
// The server group to assign the machine to
8893
ServerGroupID string `json:"serverGroupID,omitempty"`
8994

api/v1alpha7/types.go

+14
Original file line numberDiff line numberDiff line change
@@ -163,6 +163,20 @@ type RootVolume struct {
163163
AvailabilityZone string `json:"availabilityZone,omitempty"`
164164
}
165165

166+
type AdditionalBlockDevice struct {
167+
// Name of the Cinder volume in the context of a machine.
168+
// It will be combined with the machine name to make the actual volume name.
169+
Name string `json:"name"`
170+
// Size is the size in GB of the volume.
171+
Size int `json:"diskSize"`
172+
// VolumeType is the volume type of the volume.
173+
// If omitted, the default type will be used.
174+
VolumeType string `json:"volumeType,omitempty"`
175+
// AvailabilityZone is the volume availability zone to create the volume in.
176+
// If omitted, the availability zone of the server will be used.
177+
AvailabilityZone string `json:"availabilityZone,omitempty"`
178+
}
179+
166180
// NetworkStatus contains basic information about an existing neutron network.
167181
type NetworkStatus struct {
168182
Name string `json:"name"`

api/v1alpha7/zz_generated.deepcopy.go

+20
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

config/crd/bases/infrastructure.cluster.x-k8s.io_openstackclusters.yaml

+30
Original file line numberDiff line numberDiff line change
@@ -3770,6 +3770,36 @@ spec:
37703770
instance:
37713771
description: Instance for the bastion itself
37723772
properties:
3773+
additionalBlockDevices:
3774+
description: AdditionalBlockDevices is a list of specifications
3775+
for additional block devices to attach to the server instance
3776+
items:
3777+
properties:
3778+
availabilityZone:
3779+
description: AvailabilityZone is the volume availability
3780+
zone to create the volume in. If omitted, the availability
3781+
zone of the server will be used.
3782+
type: string
3783+
diskSize:
3784+
description: Size is the size in GB of the volume.
3785+
type: integer
3786+
name:
3787+
description: Name of the Cinder volume in the context
3788+
of a machine. It will be combined with the machine
3789+
name to make the actual volume name.
3790+
type: string
3791+
volumeType:
3792+
description: VolumeType is the volume type of the volume.
3793+
If omitted, the default type will be used.
3794+
type: string
3795+
required:
3796+
- diskSize
3797+
- name
3798+
type: object
3799+
type: array
3800+
x-kubernetes-list-map-keys:
3801+
- name
3802+
x-kubernetes-list-type: map
37733803
cloudName:
37743804
description: The name of the cloud to use from the clouds
37753805
secret

config/crd/bases/infrastructure.cluster.x-k8s.io_openstackclustertemplates.yaml

+34
Original file line numberDiff line numberDiff line change
@@ -1610,6 +1610,40 @@ spec:
16101610
instance:
16111611
description: Instance for the bastion itself
16121612
properties:
1613+
additionalBlockDevices:
1614+
description: AdditionalBlockDevices is a list of specifications
1615+
for additional block devices to attach to the server
1616+
instance
1617+
items:
1618+
properties:
1619+
availabilityZone:
1620+
description: AvailabilityZone is the volume
1621+
availability zone to create the volume in.
1622+
If omitted, the availability zone of the server
1623+
will be used.
1624+
type: string
1625+
diskSize:
1626+
description: Size is the size in GB of the volume.
1627+
type: integer
1628+
name:
1629+
description: Name of the Cinder volume in the
1630+
context of a machine. It will be combined
1631+
with the machine name to make the actual volume
1632+
name.
1633+
type: string
1634+
volumeType:
1635+
description: VolumeType is the volume type of
1636+
the volume. If omitted, the default type will
1637+
be used.
1638+
type: string
1639+
required:
1640+
- diskSize
1641+
- name
1642+
type: object
1643+
type: array
1644+
x-kubernetes-list-map-keys:
1645+
- name
1646+
x-kubernetes-list-type: map
16131647
cloudName:
16141648
description: The name of the cloud to use from the
16151649
clouds secret

config/crd/bases/infrastructure.cluster.x-k8s.io_openstackmachines.yaml

+30
Original file line numberDiff line numberDiff line change
@@ -1159,6 +1159,36 @@ spec:
11591159
spec:
11601160
description: OpenStackMachineSpec defines the desired state of OpenStackMachine.
11611161
properties:
1162+
additionalBlockDevices:
1163+
description: AdditionalBlockDevices is a list of specifications for
1164+
additional block devices to attach to the server instance
1165+
items:
1166+
properties:
1167+
availabilityZone:
1168+
description: AvailabilityZone is the volume availability zone
1169+
to create the volume in. If omitted, the availability zone
1170+
of the server will be used.
1171+
type: string
1172+
diskSize:
1173+
description: Size is the size in GB of the volume.
1174+
type: integer
1175+
name:
1176+
description: Name of the Cinder volume in the context of a machine.
1177+
It will be combined with the machine name to make the actual
1178+
volume name.
1179+
type: string
1180+
volumeType:
1181+
description: VolumeType is the volume type of the volume. If
1182+
omitted, the default type will be used.
1183+
type: string
1184+
required:
1185+
- diskSize
1186+
- name
1187+
type: object
1188+
type: array
1189+
x-kubernetes-list-map-keys:
1190+
- name
1191+
x-kubernetes-list-type: map
11621192
cloudName:
11631193
description: The name of the cloud to use from the clouds secret
11641194
type: string

config/crd/bases/infrastructure.cluster.x-k8s.io_openstackmachinetemplates.yaml

+30
Original file line numberDiff line numberDiff line change
@@ -958,6 +958,36 @@ spec:
958958
description: Spec is the specification of the desired behavior
959959
of the machine.
960960
properties:
961+
additionalBlockDevices:
962+
description: AdditionalBlockDevices is a list of specifications
963+
for additional block devices to attach to the server instance
964+
items:
965+
properties:
966+
availabilityZone:
967+
description: AvailabilityZone is the volume availability
968+
zone to create the volume in. If omitted, the availability
969+
zone of the server will be used.
970+
type: string
971+
diskSize:
972+
description: Size is the size in GB of the volume.
973+
type: integer
974+
name:
975+
description: Name of the Cinder volume in the context
976+
of a machine. It will be combined with the machine
977+
name to make the actual volume name.
978+
type: string
979+
volumeType:
980+
description: VolumeType is the volume type of the volume.
981+
If omitted, the default type will be used.
982+
type: string
983+
required:
984+
- diskSize
985+
- name
986+
type: object
987+
type: array
988+
x-kubernetes-list-map-keys:
989+
- name
990+
x-kubernetes-list-type: map
961991
cloudName:
962992
description: The name of the cloud to use from the clouds
963993
secret

controllers/openstackmachine_controller.go

+12-11
Original file line numberDiff line numberDiff line change
@@ -455,17 +455,18 @@ func (r *OpenStackMachineReconciler) getOrCreate(logger logr.Logger, cluster *cl
455455

456456
func machineToInstanceSpec(openStackCluster *infrav1.OpenStackCluster, machine *clusterv1.Machine, openStackMachine *infrav1.OpenStackMachine, userData string) *compute.InstanceSpec {
457457
instanceSpec := compute.InstanceSpec{
458-
Name: openStackMachine.Name,
459-
Image: openStackMachine.Spec.Image,
460-
ImageUUID: openStackMachine.Spec.ImageUUID,
461-
Flavor: openStackMachine.Spec.Flavor,
462-
SSHKeyName: openStackMachine.Spec.SSHKeyName,
463-
UserData: userData,
464-
Metadata: openStackMachine.Spec.ServerMetadata,
465-
ConfigDrive: openStackMachine.Spec.ConfigDrive != nil && *openStackMachine.Spec.ConfigDrive,
466-
RootVolume: openStackMachine.Spec.RootVolume,
467-
ServerGroupID: openStackMachine.Spec.ServerGroupID,
468-
Trunk: openStackMachine.Spec.Trunk,
458+
Name: openStackMachine.Name,
459+
Image: openStackMachine.Spec.Image,
460+
ImageUUID: openStackMachine.Spec.ImageUUID,
461+
Flavor: openStackMachine.Spec.Flavor,
462+
SSHKeyName: openStackMachine.Spec.SSHKeyName,
463+
UserData: userData,
464+
Metadata: openStackMachine.Spec.ServerMetadata,
465+
ConfigDrive: openStackMachine.Spec.ConfigDrive != nil && *openStackMachine.Spec.ConfigDrive,
466+
RootVolume: openStackMachine.Spec.RootVolume,
467+
AdditionalBlockDevices: openStackMachine.Spec.AdditionalBlockDevices,
468+
ServerGroupID: openStackMachine.Spec.ServerGroupID,
469+
Trunk: openStackMachine.Spec.Trunk,
469470
}
470471

471472
// Add the failure domain only if specified

0 commit comments

Comments
 (0)