@@ -25,6 +25,7 @@ import (
25
25
"net/http"
26
26
"reflect"
27
27
goruntime "runtime"
28
+ "strings"
28
29
"time"
29
30
30
31
batchv1 "k8s.io/api/batch/v1"
@@ -600,22 +601,36 @@ func (r *ClusterReconciler) ReconcilePVCs(ctx context.Context, cluster *apiv1.Cl
600
601
return fmt .Errorf ("while parsing PVC size %v: %w" , cluster .Spec .StorageConfiguration .Size , err )
601
602
}
602
603
604
+ var walQuantity * resource.Quantity
605
+
606
+ if cluster .Spec .WalStorage != nil {
607
+ q , err := resource .ParseQuantity (cluster .Spec .WalStorage .Size )
608
+ if err != nil {
609
+ return fmt .Errorf ("while parsing WAL PVC size %v: %w" , cluster .Spec .WalStorage .Size , err )
610
+ }
611
+ walQuantity = & q
612
+ }
613
+
603
614
for idx := range resources .pvcs .Items {
604
615
oldPVC := resources .pvcs .Items [idx ].DeepCopy ()
616
+ q := quantity
617
+ if strings .HasSuffix (oldPVC .Name , apiv1 .WalArchiveVolumeSuffix ) && walQuantity != nil {
618
+ q = * walQuantity
619
+ }
605
620
oldQuantity , ok := resources .pvcs .Items [idx ].Spec .Resources .Requests ["storage" ]
606
621
607
622
switch {
608
623
case ! ok :
609
624
// Missing storage requirement for PVC
610
625
fallthrough
611
626
612
- case oldQuantity .AsDec ().Cmp (quantity .AsDec ()) == - 1 :
627
+ case oldQuantity .AsDec ().Cmp (q .AsDec ()) == - 1 :
613
628
// Increasing storage resources
614
- resources .pvcs .Items [idx ].Spec .Resources .Requests ["storage" ] = quantity
629
+ resources .pvcs .Items [idx ].Spec .Resources .Requests ["storage" ] = q
615
630
if err = r .Patch (ctx , & resources .pvcs .Items [idx ], client .MergeFrom (oldPVC )); err != nil {
616
631
// Decreasing resources is not possible
617
632
contextLogger .Error (err , "error while changing PVC storage requirement" ,
618
- "from" , oldQuantity , "to" , quantity ,
633
+ "from" , oldQuantity , "to" , q ,
619
634
"pvcName" , resources .pvcs .Items [idx ].Name )
620
635
621
636
// We are reaching two errors in two different conditions:
@@ -625,10 +640,10 @@ func (r *ClusterReconciler) ReconcilePVCs(ctx context.Context, cluster *apiv1.Cl
625
640
// about it
626
641
}
627
642
628
- case oldQuantity .AsDec ().Cmp (quantity .AsDec ()) == 1 :
643
+ case oldQuantity .AsDec ().Cmp (q .AsDec ()) == 1 :
629
644
// Decreasing resources is not possible
630
645
contextLogger .Info ("cannot decrease storage requirement" ,
631
- "from" , oldQuantity , "to" , quantity ,
646
+ "from" , oldQuantity , "to" , q ,
632
647
"pvcName" , resources .pvcs .Items [idx ].Name )
633
648
}
634
649
}
0 commit comments