@@ -57,17 +57,12 @@ func (r *Reconciler) storeDesiredRequest(
5757 // determine if the appropriate volume limit is set
5858 limitSet := limitIsSet (cluster , volumeType , host )
5959
60- // if nil, volume does not exist
61- if limitSet == nil {
60+ // if the limit is not set or the volume does not exist do not return the new value
61+ if ! limitSet {
6262 return ""
6363 }
6464
65- // if the volume exists but the limit is not set, do not return the new value
66- if ! * limitSet {
67- return desiredRequestBackup
68- }
69-
70- if * limitSet && current .Value () > previous .Value () {
65+ if limitSet && current .Value () > previous .Value () {
7166 r .Recorder .Eventf (cluster , corev1 .EventTypeNormal , "VolumeAutoGrow" ,
7267 "%s volume expansion to %v requested for %s/%s." ,
7368 volumeType , current .String (), cluster .Name , host )
@@ -85,7 +80,7 @@ func (r *Reconciler) storeDesiredRequest(
8580
8681// limitIsSet determines if the limit is set for a given volume type and returns
8782// either a corresponding boolean value or nil if the volume is not defined.
88- func limitIsSet (cluster * v1beta1.PostgresCluster , volumeType , instanceSetName string ) * bool {
83+ func limitIsSet (cluster * v1beta1.PostgresCluster , volumeType , instanceSetName string ) bool {
8984
9085 switch {
9186
@@ -94,19 +89,17 @@ func limitIsSet(cluster *v1beta1.PostgresCluster, volumeType, instanceSetName st
9489 case volumeType == "pgData" :
9590 for _ , specInstance := range cluster .Spec .InstanceSets {
9691 if specInstance .Name == instanceSetName {
97- limitSet := ! specInstance .DataVolumeClaimSpec .Resources .Limits .Storage ().IsZero ()
98- return & limitSet
92+ return ! specInstance .DataVolumeClaimSpec .Resources .Limits .Storage ().IsZero ()
9993 }
10094 }
10195 case volumeType == "pgWAL" :
10296 for _ , specInstance := range cluster .Spec .InstanceSets {
10397 // return nil if volume is not defined
10498 if specInstance .Name == instanceSetName && specInstance .WALVolumeClaimSpec == nil {
105- return nil
99+ return false
106100 }
107101 if specInstance .Name == instanceSetName && specInstance .WALVolumeClaimSpec != nil {
108- limitSet := ! specInstance .WALVolumeClaimSpec .Resources .Limits .Storage ().IsZero ()
109- return & limitSet
102+ return ! specInstance .WALVolumeClaimSpec .Resources .Limits .Storage ().IsZero ()
110103 }
111104 }
112105 // VolumeType for the repository host volumes should be in the form 'repoN'
@@ -116,16 +109,15 @@ func limitIsSet(cluster *v1beta1.PostgresCluster, volumeType, instanceSetName st
116109 for _ , specRepo := range cluster .Spec .Backups .PGBackRest .Repos {
117110 // return nil if volume is not defined
118111 if specRepo .Name == volumeType && specRepo .Volume == nil {
119- return nil
112+ return false
120113 }
121114 if specRepo .Name == volumeType && specRepo .Volume != nil {
122- limitSet := ! specRepo .Volume .VolumeClaimSpec .Resources .Limits .Storage ().IsZero ()
123- return & limitSet
115+ return ! specRepo .Volume .VolumeClaimSpec .Resources .Limits .Storage ().IsZero ()
124116 }
125117 }
126118 }
127119
128- return nil
120+ return false
129121
130122}
131123
0 commit comments