@@ -137,7 +137,6 @@ func (c *Cluster) syncUnderlyingEBSVolume() error {
137137 for _ , s := range errors {
138138 c .logger .Warningf (s )
139139 }
140- // c.logger.Errorf("failed to modify %d of %d volumes", len(c.EBSVolumes), len(errors))
141140 }
142141 return nil
143142}
@@ -149,7 +148,11 @@ func (c *Cluster) populateVolumeMetaData() error {
149148 if err != nil {
150149 return fmt .Errorf ("could not list persistent volumes: %v" , err )
151150 }
152- c .logger .Debugf ("found %d volumes, size of known volumes %d" , len (pvs ), len (c .EBSVolumes ))
151+ if len (pvs ) == 0 {
152+ c .EBSVolumes = make (map [string ]volumes.VolumeProperties )
153+ return fmt .Errorf ("no persistent volumes found" )
154+ }
155+ c .logger .Debugf ("found %d persistent volumes, size of known volumes %d" , len (pvs ), len (c .EBSVolumes ))
153156
154157 volumeIds := []string {}
155158 var volumeID string
@@ -167,7 +170,7 @@ func (c *Cluster) populateVolumeMetaData() error {
167170 return err
168171 }
169172
170- if len (currentVolumes ) != len (c .EBSVolumes ) {
173+ if len (currentVolumes ) != len (c .EBSVolumes ) && len ( c . EBSVolumes ) > 0 {
171174 c .logger .Debugf ("number of ebs volumes (%d) discovered differs from already known volumes (%d)" , len (currentVolumes ), len (c .EBSVolumes ))
172175 }
173176
@@ -205,7 +208,7 @@ func (c *Cluster) syncVolumeClaims() error {
205208
206209// syncVolumes reads all persistent volumes and checks that their size matches the one declared in the statefulset.
207210func (c * Cluster ) syncEbsVolumes () error {
208- c .setProcessName ("syncing EBS and Claims volumes" )
211+ c .setProcessName ("syncing EBS volumes" )
209212
210213 act , err := c .volumesNeedResizing ()
211214 if err != nil {
@@ -451,29 +454,17 @@ func quantityToGigabyte(q resource.Quantity) int64 {
451454}
452455
453456func (c * Cluster ) executeEBSMigration () error {
454- if ! c .OpConfig .EnableEBSGp3Migration {
455- return nil
456- }
457- c .logger .Infof ("starting EBS gp2 to gp3 migration" )
458-
459457 pvs , err := c .listPersistentVolumes ()
460458 if err != nil {
461459 return fmt .Errorf ("could not list persistent volumes: %v" , err )
462460 }
463- c .logger .Debugf ("found %d volumes, size of known volumes %d" , len (pvs ), len (c .EBSVolumes ))
464-
465- volumeIds := []string {}
466- var volumeID string
467- for _ , pv := range pvs {
468- volumeID , err = c .VolumeResizer .ExtractVolumeID (pv .Spec .AWSElasticBlockStore .VolumeID )
469- if err != nil {
470- continue
471- }
472-
473- volumeIds = append (volumeIds , volumeID )
461+ if len (pvs ) == 0 {
462+ c .logger .Warningf ("no persistent volumes found - skipping EBS migration" )
463+ return nil
474464 }
465+ c .logger .Debugf ("found %d volumes, size of known volumes %d" , len (pvs ), len (c .EBSVolumes ))
475466
476- if len (volumeIds ) == len (c .EBSVolumes ) {
467+ if len (pvs ) == len (c .EBSVolumes ) {
477468 hasGp2 := false
478469 for _ , v := range c .EBSVolumes {
479470 if v .VolumeType == "gp2" {
@@ -487,15 +478,10 @@ func (c *Cluster) executeEBSMigration() error {
487478 }
488479 }
489480
490- awsVolumes , err := c .VolumeResizer .DescribeVolumes (volumeIds )
491- if nil != err {
492- return err
493- }
494-
495481 var i3000 int64 = 3000
496482 var i125 int64 = 125
497483
498- for _ , volume := range awsVolumes {
484+ for _ , volume := range c . EBSVolumes {
499485 if volume .VolumeType == "gp2" && volume .Size < c .OpConfig .EnableEBSGp3MigrationMaxSize {
500486 c .logger .Infof ("modifying EBS volume %s to type gp3 migration (%d)" , volume .VolumeID , volume .Size )
501487 err = c .VolumeResizer .ModifyVolume (volume .VolumeID , aws .String ("gp3" ), & volume .Size , & i3000 , & i125 )
0 commit comments