syahra712 opened a new pull request, #888:
URL: https://github.com/apache/solr-operator/pull/888

   Fixes #828.
   
   ## The bug
   
   `Reconcile` has no deletion branch. A SolrCloud with a `deletionTimestamp` 
goes through the full reconcile (ZK, services, ConfigMap, StatefulSet…) before 
it reaches `reconcileStorageFinalizer`. If any step on the way returns an 
error, the storage finalizer is never removed and the SolrCloud can't be 
deleted.
   
   The case from the issue: when `providedConfigMap` is already gone (Helm 
deletes it in the same uninstall/upgrade), the lookup returns `NotFound` on 
every pass, so the CR is stuck for good.
   
   ## The fix
   
   When the SolrCloud is being deleted, `Reconcile` now goes straight to a 
small `reconcileDeletion` that only handles the storage finalizer. Owned 
resources are garbage collected by Kubernetes, so nothing else needs 
reconciling on that path.
   
   - It uses the live StatefulSet's selector to find the PVCs, the same as 
before.
   - If the StatefulSet is already gone (e.g. foreground deletion), it falls 
back to `SharedLabels()`. That is the selector the operator always generates 
for the StatefulSet, and the StatefulSet controller copies the selector's 
labels onto every PVC it creates (`getPersistentVolumeClaims` in 
`pkg/controller/statefulset/stateful_set_utils.go`).
   - The "no selector labels → don't touch PVCs" guard and the 15s retry when 
PVC cleanup fails are kept as they were.
   
   ## Tests
   
   New spec in `solrcloud_controller_storage_test.go`: a SolrCloud with a 
provided ConfigMap and `VolumeReclaimPolicy: Delete`. The test deletes the 
ConfigMap, then the SolrCloud, and expects the SolrCloud to go away.
   
   - Without the fix it times out, and the operator logs `ConfigMap 
"provided-config-deleted-first" not found` on every reconcile, same as in the 
issue.
   - With the fix it passes. The existing "PVC Delete on Reclaim" deletion spec 
also still passes.
   
   The full `go test ./api/... ./controllers/...` run passes (78 specs) against 
envtest 1.37.0, and so do `make check-format vet check-generated 
check-manifests`.
   
   AI-assisted (Claude)
   


-- 
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