Skip to content

Commit 773d4f8

Browse files
committed
do not call EBS api when there are no pvs
1 parent cc72695 commit 773d4f8

File tree

2 files changed

+7
-10
lines changed

2 files changed

+7
-10
lines changed

pkg/cluster/cluster.go

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -149,7 +149,6 @@ func New(cfg Config, kubeClient k8sutil.KubernetesClient, pgSpec acidv1.Postgres
149149
cluster.EBSVolumes = make(map[string]volumes.VolumeProperties)
150150
if cfg.OpConfig.StorageResizeMode != "pvc" || cfg.OpConfig.EnableEBSGp3Migration {
151151
cluster.VolumeResizer = &volumes.EBSVolumeResizer{AWSRegion: cfg.OpConfig.AWSRegion}
152-
153152
}
154153

155154
return cluster

pkg/cluster/volumes.go

Lines changed: 7 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -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.
207210
func (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,11 +454,6 @@ func quantityToGigabyte(q resource.Quantity) int64 {
451454
}
452455

453456
func (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)

0 commit comments

Comments
 (0)