@@ -2775,8 +2775,7 @@ func (r *Reconciler) reconcileRepos(ctx context.Context,
2775
2775
repoVols := []* corev1.PersistentVolumeClaim {}
2776
2776
var replicaCreateRepo v1beta1.PGBackRestRepo
2777
2777
2778
- autogrow := feature .Enabled (ctx , feature .AutoGrowVolumes )
2779
- if autogrow {
2778
+ if feature .Enabled (ctx , feature .AutoGrowVolumes ) {
2780
2779
// get the autogrow annotations so that the correct volume size values can be
2781
2780
// used and the cluster status can be updated
2782
2781
errors = append (errors , r .getRepoHostVolumeRequests (ctx , postgresCluster ))
@@ -2829,34 +2828,37 @@ func (r *Reconciler) getRepoHostVolumeRequests(ctx context.Context,
2829
2828
cluster * v1beta1.PostgresCluster ) error {
2830
2829
2831
2830
pods := & corev1.PodList {}
2832
- err := errors .WithStack (
2831
+ if err := errors .WithStack (
2833
2832
r .Client .List (ctx , pods ,
2834
2833
client .InNamespace (cluster .Namespace ),
2835
2834
client.MatchingLabelsSelector {
2836
2835
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
2856
2857
}
2857
2858
}
2858
2859
}
2859
- return err
2860
+
2861
+ return nil
2860
2862
}
2861
2863
2862
2864
// +kubebuilder:rbac:groups="",resources="pods",verbs={get,list}
0 commit comments