Skip to content

Commit

Permalink
Fix tests
Browse files Browse the repository at this point in the history
  • Loading branch information
mandre committed Oct 6, 2023
1 parent c095bff commit fe50028
Show file tree
Hide file tree
Showing 9 changed files with 32 additions and 18 deletions.
8 changes: 4 additions & 4 deletions api/v1alpha7/types.go
Original file line number Diff line number Diff line change
Expand Up @@ -178,10 +178,10 @@ type AdditionalBlockDevice struct {
// 2. Add a new field for swap partitions
// 3. Don't add fields, the block device will be blank and can't be used for swap partitions.

// Name of the Cinder volume in the context of a machine.
// It will be combined with the machine name to make the actual volume name.
// Required if SourceType is "volume"
Name string `json:"name,omitempty"`
// Name of the block device in the context of a machine.
// It will be combined with the machine name to make the actual cinder
// volume name, and will be used for tagging the block device.
Name string `json:"name"`
// Size is the size in GB of the block device.
Size int `json:"diskSize"`
// VolumeType is the volume type of the volume.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3791,10 +3791,10 @@ spec:
description: Size is the size in GB of the block device.
type: integer
name:
description: Name of the Cinder volume in the context
description: Name of the block device in the context
of a machine. It will be combined with the machine
name to make the actual volume name. Required if SourceType
is "volume"
name to make the actual cinder volume name, and will
be used for tagging the block device.
type: string
volumeType:
description: VolumeType is the volume type of the volume.
Expand All @@ -3803,6 +3803,7 @@ spec:
required:
- blockDeviceType
- diskSize
- name
type: object
type: array
x-kubernetes-list-map-keys:
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -1635,10 +1635,11 @@ spec:
device.
type: integer
name:
description: Name of the Cinder volume in the
description: Name of the block device in the
context of a machine. It will be combined
with the machine name to make the actual volume
name. Required if SourceType is "volume"
with the machine name to make the actual cinder
volume name, and will be used for tagging
the block device.
type: string
volumeType:
description: VolumeType is the volume type of
Expand All @@ -1648,6 +1649,7 @@ spec:
required:
- blockDeviceType
- diskSize
- name
type: object
type: array
x-kubernetes-list-map-keys:
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -1180,9 +1180,10 @@ spec:
description: Size is the size in GB of the block device.
type: integer
name:
description: Name of the Cinder volume in the context of a machine.
description: Name of the block device in the context of a machine.
It will be combined with the machine name to make the actual
volume name. Required if SourceType is "volume"
cinder volume name, and will be used for tagging the block
device.
type: string
volumeType:
description: VolumeType is the volume type of the volume. If
Expand All @@ -1191,6 +1192,7 @@ spec:
required:
- blockDeviceType
- diskSize
- name
type: object
type: array
x-kubernetes-list-map-keys:
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -979,10 +979,10 @@ spec:
description: Size is the size in GB of the block device.
type: integer
name:
description: Name of the Cinder volume in the context
description: Name of the block device in the context
of a machine. It will be combined with the machine
name to make the actual volume name. Required if SourceType
is "volume"
name to make the actual cinder volume name, and will
be used for tagging the block device.
type: string
volumeType:
description: VolumeType is the volume type of the volume.
Expand All @@ -991,6 +991,7 @@ spec:
required:
- blockDeviceType
- diskSize
- name
type: object
type: array
x-kubernetes-list-map-keys:
Expand Down
4 changes: 1 addition & 3 deletions pkg/cloud/services/compute/instance.go
Original file line number Diff line number Diff line change
Expand Up @@ -494,7 +494,6 @@ func (s *Service) getBlockDevices(eventObject runtime.Object, instanceSpec *Inst
var bdUUID string
var sourceType bootfromvolume.SourceType
var destinationType bootfromvolume.DestinationType
var bdSize int
if blockDeviceSpec.BlockDeviceType == "volume" {
blockDevice, err := s.getOrCreateVolumeBuilder(eventObject, instanceSpec, blockDeviceSpec, "", fmt.Sprintf("Additional block device for %s", instanceSpec.Name))
if err != nil {
Expand All @@ -506,7 +505,6 @@ func (s *Service) getBlockDevices(eventObject runtime.Object, instanceSpec *Inst
} else if blockDeviceSpec.BlockDeviceType == "local" {
sourceType = bootfromvolume.SourceBlank
destinationType = bootfromvolume.DestinationLocal
bdSize = blockDeviceSpec.Size
} else {
return []bootfromvolume.BlockDevice{}, fmt.Errorf("invalid block device type %s", blockDeviceSpec.BlockDeviceType)
}
Expand All @@ -517,7 +515,7 @@ func (s *Service) getBlockDevices(eventObject runtime.Object, instanceSpec *Inst
UUID: bdUUID,
BootIndex: -1,
DeleteOnTermination: true,
VolumeSize: bdSize,
VolumeSize: blockDeviceSpec.Size,
Tag: blockDeviceSpec.Name,
})
}
Expand Down
8 changes: 8 additions & 0 deletions pkg/cloud/services/compute/instance_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -665,6 +665,7 @@ func TestService_ReconcileInstance(t *testing.T) {
},
{
BlockDeviceType: "local",
Name: "local-device",
Size: 10,
},
}
Expand Down Expand Up @@ -715,13 +716,16 @@ func TestService_ReconcileInstance(t *testing.T) {
"boot_index": float64(-1),
"delete_on_termination": true,
"destination_type": "volume",
"volume_size": float64(50),
"tag": "etcd",
},
{
"source_type": "blank",
"destination_type": "local",
"boot_index": float64(-1),
"delete_on_termination": true,
"volume_size": float64(10),
"tag": "local-device",
},
}
expectCreateServer(r.compute, createMap, false)
Expand Down Expand Up @@ -777,6 +781,8 @@ func TestService_ReconcileInstance(t *testing.T) {
"boot_index": float64(-1),
"delete_on_termination": true,
"destination_type": "volume",
"volume_size": float64(50),
"tag": "etcd",
},
}
expectCreateServer(r.compute, createMap, false)
Expand Down Expand Up @@ -833,6 +839,8 @@ func TestService_ReconcileInstance(t *testing.T) {
"boot_index": float64(-1),
"delete_on_termination": true,
"destination_type": "volume",
"volume_size": float64(50),
"tag": "etcd",
},
}
expectCreateServer(r.compute, createMap, false)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -11,3 +11,4 @@
name: extravol
- diskSize: 1
blockDeviceType: local
name: etcd
Original file line number Diff line number Diff line change
Expand Up @@ -15,3 +15,4 @@
availabilityZone: ${OPENSTACK_FAILURE_DOMAIN}
- diskSize: 1
blockDeviceType: local
name: etcd

0 comments on commit fe50028

Please sign in to comment.