@@ -2775,8 +2775,7 @@ func (r *Reconciler) reconcileRepos(ctx context.Context,
27752775 repoVols := []* corev1.PersistentVolumeClaim {}
27762776 var replicaCreateRepo v1beta1.PGBackRestRepo
27772777
2778- autogrow := feature .Enabled (ctx , feature .AutoGrowVolumes )
2779- if autogrow {
2778+ if feature .Enabled (ctx , feature .AutoGrowVolumes ) {
27802779 // get the autogrow annotations so that the correct volume size values can be
27812780 // used and the cluster status can be updated
27822781 errors = append (errors , r .getRepoHostVolumeRequests (ctx , postgresCluster ))
@@ -2829,34 +2828,37 @@ func (r *Reconciler) getRepoHostVolumeRequests(ctx context.Context,
28292828 cluster * v1beta1.PostgresCluster ) error {
28302829
28312830 pods := & corev1.PodList {}
2832- err := errors .WithStack (
2831+ if err := errors .WithStack (
28332832 r .Client .List (ctx , pods ,
28342833 client .InNamespace (cluster .Namespace ),
28352834 client.MatchingLabelsSelector {
28362835 Selector : naming .PGBackRestDedicatedLabels (cluster .Name ).AsSelector ()},
2837- ))
2838-
2839- if len (pods .Items ) == 1 {
2840- // there should only ever be one repo host Pod
2841- repoHost := pods .Items [0 ]
2842-
2843- if cluster .Status .PGBackRest != nil {
2844- var backupRequest string
2845- for i := range cluster .Status .PGBackRest .Repos {
2846- if repoHost .Annotations ["suggested-" + cluster .Status .PGBackRest .Repos [i ].Name + "-pvc-size" ] != "" {
2847- // get the backup request from the status, if it is set
2848- backupRequest = cluster .Status .PGBackRest .Repos [i ].DesiredRepoVolume
2849-
2850- value := r .storeDesiredRequest (ctx , cluster , cluster .Status .PGBackRest .Repos [i ].Name , "repo-host" ,
2851- repoHost .Annotations ["suggested-" + cluster .Status .PGBackRest .Repos [i ].Name + "-pvc-size" ], backupRequest )
2852- if err == nil {
2853- cluster .Status .PGBackRest .Repos [i ].DesiredRepoVolume = value
2854- }
2855- }
2836+ )); err != nil {
2837+ return err
2838+ }
2839+
2840+ // there should only ever be one repo host Pod
2841+ if len (pods .Items ) != 1 {
2842+ return errors .Errorf ("Found %d pgBackRest repo host Pods. Expected 1." , len (pods .Items ))
2843+ }
2844+ repoHost := pods .Items [0 ]
2845+
2846+ if cluster .Status .PGBackRest != nil {
2847+ var backupRequest string
2848+ for i := range cluster .Status .PGBackRest .Repos {
2849+ if repoHost .Annotations ["suggested-" + cluster .Status .PGBackRest .Repos [i ].Name + "-pvc-size" ] != "" {
2850+ // get the backup request from the status, if it is set
2851+ backupRequest = cluster .Status .PGBackRest .Repos [i ].DesiredRepoVolume
2852+
2853+ value := r .storeDesiredRequest (ctx , cluster , cluster .Status .PGBackRest .Repos [i ].Name , "repo-host" ,
2854+ repoHost .Annotations ["suggested-" + cluster .Status .PGBackRest .Repos [i ].Name + "-pvc-size" ], backupRequest )
2855+
2856+ cluster .Status .PGBackRest .Repos [i ].DesiredRepoVolume = value
28562857 }
28572858 }
28582859 }
2859- return err
2860+
2861+ return nil
28602862}
28612863
28622864// +kubebuilder:rbac:groups="",resources="pods",verbs={get,list}
0 commit comments