Skip to content

Commit

Permalink
enabled hotplug for sss bootvolume and made volumes property optional
Browse files Browse the repository at this point in the history
  • Loading branch information
mraduinea-ionos committed Sep 17, 2024
1 parent 086ec6c commit da0e11a
Show file tree
Hide file tree
Showing 5 changed files with 24 additions and 22 deletions.
11 changes: 6 additions & 5 deletions apis/compute/v1alpha1/statefulserverset_types.go
Original file line number Diff line number Diff line change
Expand Up @@ -108,11 +108,12 @@ type StatefulServerSetParameters struct {
// on which the server will be created.
//
// +kubebuilder:validation:Required
DatacenterCfg DatacenterConfig `json:"datacenterConfig"`
Template ServerSetTemplate `json:"template"`
BootVolumeTemplate BootVolumeTemplate `json:"bootVolumeTemplate"`
Lans []StatefulServerSetLan `json:"lans"`
Volumes []StatefulServerSetVolume `json:"volumes"`
DatacenterCfg DatacenterConfig `json:"datacenterConfig"`
Template ServerSetTemplate `json:"template"`
BootVolumeTemplate BootVolumeTemplate `json:"bootVolumeTemplate"`
Lans []StatefulServerSetLan `json:"lans"`
// +kubebuilder:validation:Optional
Volumes []StatefulServerSetVolume `json:"volumes"`
// IdentityConfigMap is the configMap from which the identity of the ACTIVE server in the ServerSet is read. The configMap
// should be created separately. The stateful serverset only reads the status from it. If it does not find it, it sets
// the first server as the ACTIVE.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -141,11 +141,12 @@ func fromSSSetToVolume(cr *v1alpha1.StatefulServerSet, name string, replicaIndex
DeletionPolicy: cr.GetDeletionPolicy(),
},
ForProvider: v1alpha1.VolumeParameters{
DatacenterCfg: cr.Spec.ForProvider.DatacenterCfg,
Name: generateProviderNameFromIndex(cr.Spec.ForProvider.Volumes[volumeIndex].Metadata.Name, volumeIndex),
AvailabilityZone: serverset.GetZoneFromIndex(replicaIndex),
Size: cr.Spec.ForProvider.Volumes[volumeIndex].Spec.Size,
Type: cr.Spec.ForProvider.Volumes[volumeIndex].Spec.Type,
DatacenterCfg: cr.Spec.ForProvider.DatacenterCfg,
Name: generateProviderNameFromIndex(cr.Spec.ForProvider.Volumes[volumeIndex].Metadata.Name, volumeIndex),
AvailabilityZone: serverset.GetZoneFromIndex(replicaIndex),
Size: cr.Spec.ForProvider.Volumes[volumeIndex].Spec.Size,
Type: cr.Spec.ForProvider.Volumes[volumeIndex].Spec.Type,
DiscVirtioHotPlug: true,
},
}}
if cr.Spec.ForProvider.Volumes[volumeIndex].Spec.Image != "" {
Expand Down
15 changes: 8 additions & 7 deletions internal/controller/serverset/bootvolume_controller.go
Original file line number Diff line number Diff line change
Expand Up @@ -216,13 +216,14 @@ func fromServerSetToVolume(cr *v1alpha1.ServerSet, name string, replicaIndex, ve
DeletionPolicy: cr.GetDeletionPolicy(),
},
ForProvider: v1alpha1.VolumeParameters{
DatacenterCfg: cr.Spec.ForProvider.DatacenterCfg,
Name: name,
AvailabilityZone: GetZoneFromIndex(replicaIndex),
Size: cr.Spec.ForProvider.BootVolumeTemplate.Spec.Size,
Type: cr.Spec.ForProvider.BootVolumeTemplate.Spec.Type,
Image: cr.Spec.ForProvider.BootVolumeTemplate.Spec.Image,
UserData: cr.Spec.ForProvider.BootVolumeTemplate.Spec.UserData,
DatacenterCfg: cr.Spec.ForProvider.DatacenterCfg,
Name: name,
AvailabilityZone: GetZoneFromIndex(replicaIndex),
Size: cr.Spec.ForProvider.BootVolumeTemplate.Spec.Size,
Type: cr.Spec.ForProvider.BootVolumeTemplate.Spec.Type,
Image: cr.Spec.ForProvider.BootVolumeTemplate.Spec.Image,
UserData: cr.Spec.ForProvider.BootVolumeTemplate.Spec.UserData,
DiscVirtioHotPlug: true,
},
}}
if cr.Spec.ForProvider.BootVolumeTemplate.Spec.ImagePassword != "" {
Expand Down
8 changes: 4 additions & 4 deletions internal/controller/volumeselector/volumeselector.go
Original file line number Diff line number Diff line change
Expand Up @@ -228,10 +228,10 @@ func (c *externalVolumeselector) attachVolume(ctx context.Context, datacenterID,
}

func (c *externalVolumeselector) areVolumesAndServersReady(volumeList v1alpha1.VolumeList, serverList v1alpha1.ServerList) bool {
if len(volumeList.Items) == 0 {
c.log.Info("volumeselector no Volumes found")
return false
}
//if len(volumeList.Items) == 0 {
// c.log.Info("volumeselector no Volumes found")
// return false
//}
if len(serverList.Items) == 0 {
c.log.Info("volumeselector no Servers found")
return false
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -597,7 +597,6 @@ spec:
- lans
- replicas
- template
- volumes
type: object
managementPolicies:
default:
Expand Down

0 comments on commit da0e11a

Please sign in to comment.