janhoy opened a new issue, #927:
URL: https://github.com/apache/solr-operator/issues/927

   🤖 *This issue was written by an AI assistant (Claude) on behalf of @janhoy, 
based on a test of the v0.10.0 RC1 artifacts.*
   
   ## Summary
   
   After the operator has expanded the data PVCs of a SolrCloud (#709 / #712), 
a pod that is added later by increasing `spec.replicas` gets a data PVC of the 
**original** size, and the operator never expands it. The cluster ends up with 
nodes of different disk sizes, without any event or log message saying so.
   
   ## Why it happens
   
   Kubernetes does not allow `volumeClaimTemplates` of a StatefulSet to be 
changed, so the expansion works around the template instead of updating it:
   
   - `expandPVCs` patches each existing PVC to the new size.
   - `handlePvcExpansion` then records the new size in the 
`solr.apache.org/storageMinimumSize` annotation on the StatefulSet and its pod 
template, which triggers the rolling restart.
   - The StatefulSet's `volumeClaimTemplates` keeps the size the StatefulSet 
was created with. The code that would compare and copy the templates in 
`CopyStatefulSetFields` (`controllers/util/common.go`) is commented out for the 
same reason.
   
   When the StatefulSet is scaled up afterwards, Kubernetes creates the new 
pod's PVC from that stale template. The operator does not correct it, because 
`determinePvcExpansionClusterOpLockIfNecessary` decides whether an expansion is 
needed by comparing the requested size with the `storageMinimumSize` 
annotation, and those already match.
   
   ## How to reproduce
   
   Tested with the v0.10.0 RC1 operator image and CRDs in a kind cluster 
(Kubernetes 1.37), using the kubernetes-csi hostpath driver, whose storage 
class has `allowVolumeExpansion: true`.
   
   1. Create a SolrCloud with 3 replicas and persistent storage of `1Gi` on a 
storage class that allows expansion.
   2. Change the storage request to `2Gi`. The operator runs the `PVCExpansion` 
cluster operation followed by `RollingUpdate`, and all three PVCs end up at 
`2Gi`. This part works as documented.
   3. Look at the StatefulSet: the annotation 
`solr.apache.org/storageMinimumSize` is `2Gi`, while 
`spec.volumeClaimTemplates[0].spec.resources.requests.storage` is still `1Gi`.
   4. Scale `spec.replicas` from 3 to 4.
   
   Result:
   
   ```
   data-<cloud>-solrcloud-0 req=2Gi cap=2Gi
   data-<cloud>-solrcloud-1 req=2Gi cap=2Gi
   data-<cloud>-solrcloud-2 req=2Gi cap=2Gi
   data-<cloud>-solrcloud-3 req=1Gi cap=1Gi
   ```
   
   The fourth PVC was still at `1Gi` a couple of minutes later. Expected: 
`2Gi`, the size in the SolrCloud spec.
   
   Raising the storage request once more (to `3Gi`) brings all four PVCs to 
`3Gi`, so that is a workaround, but the next scale-up starts from `1Gi` again.
   
   ## Possible solution
   
   Recreate the StatefulSet with orphaned pods after the PVCs are expanded: 
once all PVCs have reached the new size, delete the StatefulSet with 
`propagationPolicy: Orphan` and let the next reconcile create it again with the 
new size in `volumeClaimTemplates`. The pods and PVCs survive the deletion and 
are adopted by the new StatefulSet, and the rolling restart can follow as it 
does today. This is the same thing people do by hand today (`kubectl delete sts 
--cascade=orphan`), and it fixes the template for good, so every pod created 
later gets the right size.
   
   A smaller alternative would be to compare each PVC with the requested size 
on every reconcile, instead of only comparing the request with the annotation. 
That catches the new PVC, but the new pod would still start on the small disk 
and be restarted after the expansion.
   
   If neither makes it into v0.10.0, a note in the documentation of PVC 
expansion and in the upgrade notes would help, since the difference in disk 
size is easy to miss.
   


-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: [email protected]

For queries about this service, please contact Infrastructure at:
[email protected]


---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]

Reply via email to