Default volume migration done.

This commit is contained in:
Jan Mußler
2020-12-07 17:52:02 +01:00
parent 6bb78c8de2
commit 9e095e49d8
6 changed files with 83 additions and 25 deletions
+1 -9
View File
@@ -65,14 +65,6 @@ type kubeResources struct {
//PVCs are treated separately
}
type EBSVolume struct {
volumeId string
volumeType string
size int64
iops int32
throughput int32
}
// Cluster describes postgresql cluster
type Cluster struct {
kubeResources
@@ -98,7 +90,7 @@ type Cluster struct {
processMu sync.RWMutex // protects the current operation for reporting, no need to hold the master mutex
specMu sync.RWMutex // protects the spec for reporting, no need to hold the master mutex
ConnectionPooler map[PostgresRole]*ConnectionPoolerObjects
EBSVolumes map[string]EBSVolume
EBSVolumes map[string]volumes.VolumeProperties
VolumeResizer volumes.VolumeResizer
}
+5
View File
@@ -55,7 +55,12 @@ func (c *Cluster) Sync(newSpec *acidv1.Postgresql) error {
c.logger.Debugf("syncing volumes using %q storage resize mode", c.OpConfig.StorageResizeMode)
if c.OpConfig.EnableEBSGp3Migration {
c.executeEBSMigration()
}
if c.OpConfig.StorageResizeMode == "mixed" {
// mixed op uses AWS API to adjust size,throughput,iops and calls pvc chance for file system resize
// resize pvc to adjust filesystem size until better K8s support
if err = c.syncVolumeClaims(); err != nil {
+28
View File
@@ -251,3 +251,31 @@ func getPodNameFromPersistentVolume(pv *v1.PersistentVolume) *spec.NamespacedNam
func quantityToGigabyte(q resource.Quantity) int64 {
return q.ScaledValue(0) / (1 * constants.Gigabyte)
}
func (c *Cluster) executeEBSMigration() error {
if !c.OpConfig.EnableEBSGp3Migration {
return nil
}
pvs, _, err := c.listVolumesWithManifestSize(c.Spec.Volume)
if err != nil {
return fmt.Errorf("could not list persistent volumes: %v", err)
}
volumeIds := []string{}
for _, pv := range pvs {
volumeIds = append(volumeIds, pv.Spec.AWSElasticBlockStore.VolumeID)
}
awsVolumes, err := c.VolumeResizer.DescribeVolumes(volumeIds)
for _, volume := range awsVolumes {
if volume.VolumeType == "gp2" && volume.Size < c.OpConfig.EnableEBSGp3MaxSize {
c.logger.Info("Modifying EBS volume %s to type gp3 (%s)", volume.VolumeID, volume.Size)
c.VolumeResizer.ModifyVolume(volume.VolumeID, "gp3", volume.Size, 3000, 125)
}
c.EBSVolumes[volume.VolumeID] = volume
}
return nil
}