Skip to content

Commit 12871aa

Browse files
Avoid showing an extra error when resizing volume fails (zalando#350)
Do not show 'persistent volumes are not compatible' errors for the volumes that failed to be resized because of the other reasons (i.e. the new size is smaller than the existing one).
1 parent accbe20 commit 12871aa

File tree

1 file changed

+10
-5
lines changed

1 file changed

+10
-5
lines changed

pkg/cluster/volumes.go

Lines changed: 10 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -91,7 +91,8 @@ func (c *Cluster) listPersistentVolumes() ([]*v1.PersistentVolume, error) {
9191
func (c *Cluster) resizeVolumes(newVolume spec.Volume, resizers []volumes.VolumeResizer) error {
9292
c.setProcessName("resizing volumes")
9393

94-
totalCompatible := 0
94+
var totalIncompatible int
95+
9596
newQuantity, err := resource.ParseQuantity(newVolume.Size)
9697
if err != nil {
9798
return fmt.Errorf("could not parse volume size: %v", err)
@@ -100,7 +101,6 @@ func (c *Cluster) resizeVolumes(newVolume spec.Volume, resizers []volumes.Volume
100101
if err != nil {
101102
return fmt.Errorf("could not list persistent volumes: %v", err)
102103
}
103-
104104
for _, pv := range pvs {
105105
volumeSize := quantityToGigabyte(pv.Spec.Capacity[v1.ResourceStorage])
106106
if volumeSize >= newSize {
@@ -109,11 +109,12 @@ func (c *Cluster) resizeVolumes(newVolume spec.Volume, resizers []volumes.Volume
109109
}
110110
continue
111111
}
112+
compatible := false
112113
for _, resizer := range resizers {
113114
if !resizer.VolumeBelongsToProvider(pv) {
114115
continue
115116
}
116-
totalCompatible++
117+
compatible = true
117118
if !resizer.IsConnectedToProvider() {
118119
err := resizer.ConnectToProvider()
119120
if err != nil {
@@ -146,9 +147,13 @@ func (c *Cluster) resizeVolumes(newVolume spec.Volume, resizers []volumes.Volume
146147
}
147148
c.logger.Debugf("successfully updated persistent volume %q", pv.Name)
148149
}
150+
if !compatible {
151+
c.logger.Warningf("volume %q is incompatible with all available resizing providers", pv.Name)
152+
totalIncompatible++
153+
}
149154
}
150-
if len(pvs) > 0 && totalCompatible == 0 {
151-
return fmt.Errorf("could not resize EBS volumes: persistent volumes are not compatible with existing resizing providers")
155+
if totalIncompatible > 0 {
156+
return fmt.Errorf("could not resize EBS volumes: some persistent volumes are not compatible with existing resizing providers")
152157
}
153158
return nil
154159
}

0 commit comments

Comments
 (0)