From 9fdc54acb3468da7b1f97edb0a16d975a3241e99 Mon Sep 17 00:00:00 2001 From: Chris Warren Date: Mon, 26 Jan 2026 16:20:04 -0500 Subject: [PATCH 1/2] fix: Use Cmp() instead of AsInt64() for volume size comparison AsInt64() fails for fractional storage quantities like "2.2Ti" because they are internally stored as milli-units (e.g., "2418925581107200m"). When AsInt64() cannot represent the value as an integer in the base unit, it returns (0, false). The code was ignoring the false return value, causing valid volume expansions like 2Ti -> 2.2Ti to be incorrectly rejected as "shrinking". Cmp() correctly handles all quantity formats by comparing the actual values regardless of internal representation. Co-Authored-By: Claude Opus 4.5 --- controllers/druid/volume_expansion.go | 14 +++++++------- 1 file changed, 7 insertions(+), 7 deletions(-) diff --git a/controllers/druid/volume_expansion.go b/controllers/druid/volume_expansion.go index 3ae6ee07..f059ec93 100644 --- a/controllers/druid/volume_expansion.go +++ b/controllers/druid/volume_expansion.go @@ -134,11 +134,12 @@ func scalePVCForSts(ctx context.Context, sdk client.Client, nodeSpec *v1alpha1.D // Validate Request, shrinking of pvc not supported // desired size cant be less than current size // in that case re-create sts/pvc which is a user execute manual step + // + // Use Cmp() instead of AsInt64() because AsInt64() fails for quantities + // with non-integer values like "2.2Ti" which are stored as milli-units. + desiredVsCurrent := desVolumeClaimTemplateSize[i].Cmp(currVolumeClaimTemplateSize[i]) - desiredSize, _ := desVolumeClaimTemplateSize[i].AsInt64() - currentSize, _ := currVolumeClaimTemplateSize[i].AsInt64() - - if desiredSize < currentSize { + if desiredVsCurrent < 0 { e := fmt.Errorf("Request for Shrinking of sts pvc size [sts:%s] in [namespace:%s] is not Supported", sts.(*appsv1.StatefulSet).Name, sts.(*appsv1.StatefulSet).Namespace) logger.Error(e, e.Error(), "name", drd.Name, "namespace", drd.Namespace) emitEvent.EmitEventGeneric(drd, "DruidOperatorPvcReSizeFail", "", err) @@ -147,7 +148,7 @@ func scalePVCForSts(ctx context.Context, sdk client.Client, nodeSpec *v1alpha1.D // In case size dont match and dessize > currsize, delete the sts using casacde=false / propagation policy set to orphan // The operator on next reconcile shall create the sts with latest changes - if desiredSize != currentSize { + if desiredVsCurrent != 0 { msg := fmt.Sprintf("Detected Change in VolumeClaimTemplate Sizes for Statefuleset [%s] in Namespace [%s], desVolumeClaimTemplateSize: [%s], currVolumeClaimTemplateSize: [%s]\n, deleteing STS [%s] with casacde=false]", sts.(*appsv1.StatefulSet).Name, sts.(*appsv1.StatefulSet).Namespace, desVolumeClaimTemplateSize[i].String(), currVolumeClaimTemplateSize[i].String(), sts.(*appsv1.StatefulSet).Name) logger.Info(msg) emitEvent.EmitEventGeneric(drd, "DruidOperatorPvcReSizeDetected", msg, nil) @@ -164,8 +165,7 @@ func scalePVCForSts(ctx context.Context, sdk client.Client, nodeSpec *v1alpha1.D // In case size dont match, patch the pvc with the desiredsize from druid CR for p := range pvcSize { - pSize, _ := pvcSize[p].AsInt64() - if desiredSize != pSize { + if desVolumeClaimTemplateSize[i].Cmp(pvcSize[p]) != 0 { // use deepcopy patch := client.MergeFrom(pvcList[p].(*v1.PersistentVolumeClaim).DeepCopy()) pvcList[p].(*v1.PersistentVolumeClaim).Spec.Resources.Requests[v1.ResourceStorage] = desVolumeClaimTemplateSize[i] From 586e9e592c95f77af760988eee8129e22e44f8b0 Mon Sep 17 00:00:00 2001 From: Chris Warren Date: Tue, 27 Jan 2026 12:13:59 -0500 Subject: [PATCH 2/2] ci: trigger rebuild (kubelet timeout was infra flake)