From c9ade3f9fdfc6b4ca0013445d76c134ff7574965 Mon Sep 17 00:00:00 2001 From: Oliver Rahner Date: Sat, 3 Oct 2026 09:07:32 +0200 Subject: [PATCH] helm: compare PVC sizes numerically in the volume resize hook (#11575) include always returns a string, so gt compared the rendered quantities (e.g. "1.2884901888e+11" vs "6.442450944e+10") lexically. Growing a volume from 60Gi to 100Gi/120Gi or 500Gi to 1Ti emitted no kubectl patch: the StatefulSet was recreated with the new volumeClaimTemplate but the PVC kept its old size. Shrinks such as 120Gi -> 60Gi emitted a patch instead. Pipe both values through float64 before comparing. --- k8s/charts/seaweedfs/templates/shared/_helpers.tpl | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/k8s/charts/seaweedfs/templates/shared/_helpers.tpl b/k8s/charts/seaweedfs/templates/shared/_helpers.tpl index 86ee839d1..63812f091 100644 --- a/k8s/charts/seaweedfs/templates/shared/_helpers.tpl +++ b/k8s/charts/seaweedfs/templates/shared/_helpers.tpl @@ -504,8 +504,9 @@ true {{- $pvcName := printf "%s-%s-%s-%d" $dir.name $seaweedfsName $volumeName $e }} {{- $currentPVC := (lookup "v1" "PersistentVolumeClaim" $.Release.Namespace $pvcName) }} {{- if $currentPVC }} -{{- $oldSize := include "seaweedfs.resource-quantity" $currentPVC.spec.resources.requests.storage }} -{{- $newSize := include "seaweedfs.resource-quantity" $desiredSize }} +{{- /* include returns a string such as "6.442450944e+10"; convert back to a number, or gt compares lexically */}} +{{- $oldSize := include "seaweedfs.resource-quantity" $currentPVC.spec.resources.requests.storage | float64 }} +{{- $newSize := include "seaweedfs.resource-quantity" $desiredSize | float64 }} {{- if gt $newSize $oldSize }} {{- $commands = append $commands (printf "kubectl patch pvc %s-%s-%s-%d -p '{\"spec\":{\"resources\":{\"requests\":{\"storage\":\"%s\"}}}}'" $dir.name $seaweedfsName $volumeName $e $desiredSize) }} {{- end }}