mirror of
https://github.com/zalando/postgres-operator.git
synced 2026-10-01 03:22:08 +02:00
let executeEBSMigration operator on cluster.EBSVolumes
This commit is contained in:
+1
-1
@@ -69,7 +69,7 @@ func (c *Cluster) Sync(newSpec *acidv1.Postgresql) error {
|
||||
return err
|
||||
}
|
||||
|
||||
if c.OpConfig.EnableEBSGp3Migration {
|
||||
if c.OpConfig.EnableEBSGp3Migration && len(c.EBSVolumes) > 0 {
|
||||
err = c.executeEBSMigration()
|
||||
if nil != err {
|
||||
return err
|
||||
|
||||
+6
-18
@@ -458,20 +458,13 @@ func (c *Cluster) executeEBSMigration() error {
|
||||
if err != nil {
|
||||
return fmt.Errorf("could not list persistent volumes: %v", err)
|
||||
}
|
||||
if len(pvs) == 0 {
|
||||
c.logger.Warningf("no persistent volumes found - skipping EBS migration")
|
||||
return nil
|
||||
}
|
||||
c.logger.Debugf("found %d volumes, size of known volumes %d", len(pvs), len(c.EBSVolumes))
|
||||
|
||||
volumeIds := []string{}
|
||||
var volumeID string
|
||||
for _, pv := range pvs {
|
||||
volumeID, err = c.VolumeResizer.ExtractVolumeID(pv.Spec.AWSElasticBlockStore.VolumeID)
|
||||
if err != nil {
|
||||
continue
|
||||
}
|
||||
|
||||
volumeIds = append(volumeIds, volumeID)
|
||||
}
|
||||
|
||||
if len(volumeIds) == len(c.EBSVolumes) {
|
||||
if len(pvs) == len(c.EBSVolumes) {
|
||||
hasGp2 := false
|
||||
for _, v := range c.EBSVolumes {
|
||||
if v.VolumeType == "gp2" {
|
||||
@@ -485,15 +478,10 @@ func (c *Cluster) executeEBSMigration() error {
|
||||
}
|
||||
}
|
||||
|
||||
awsVolumes, err := c.VolumeResizer.DescribeVolumes(volumeIds)
|
||||
if nil != err {
|
||||
return err
|
||||
}
|
||||
|
||||
var i3000 int64 = 3000
|
||||
var i125 int64 = 125
|
||||
|
||||
for _, volume := range awsVolumes {
|
||||
for _, volume := range c.EBSVolumes {
|
||||
if volume.VolumeType == "gp2" && volume.Size < c.OpConfig.EnableEBSGp3MigrationMaxSize {
|
||||
c.logger.Infof("modifying EBS volume %s to type gp3 migration (%d)", volume.VolumeID, volume.Size)
|
||||
err = c.VolumeResizer.ModifyVolume(volume.VolumeID, aws.String("gp3"), &volume.Size, &i3000, &i125)
|
||||
|
||||
@@ -224,7 +224,10 @@ func TestMigrateEBS(t *testing.T) {
|
||||
resizer.EXPECT().ModifyVolume(gomock.Eq("ebs-volume-1"), gomock.Eq(aws.String("gp3")), gomock.Any(), gomock.Any(), gomock.Any()).Return(nil)
|
||||
|
||||
cluster.VolumeResizer = resizer
|
||||
cluster.executeEBSMigration()
|
||||
err := cluster.populateVolumeMetaData()
|
||||
assert.NoError(t, err)
|
||||
err = cluster.executeEBSMigration()
|
||||
assert.NoError(t, err)
|
||||
}
|
||||
|
||||
func initTestVolumesAndPods(client k8sutil.KubernetesClient, namespace, clustername string, labels labels.Set, volumes []testVolume) {
|
||||
|
||||
Reference in New Issue
Block a user