Skip to content

Recreate the StatefulSet after a PVC expansion so that pods added by a scale-up get the expanded size - #931

Draft
janhoy wants to merge 4 commits into
apache:mainfrom
janhoy:gh-927-pvc-expansion-scaleup
Draft

janhoy wants to merge 4 commits into
apache:mainfrom
janhoy:gh-927-pvc-expansion-scaleup

Conversation

@janhoy

@janhoy janhoy commented Dec 3, 2026 •

Copy link
Copy Markdown
Contributor

🤖 AI Assisted

Fixes #927

  • After a PVC expansion the StatefulSet's volumeClaimTemplates kept the original size, so a pod added by a later scale-up got a small data PVC.
  • The operator now recreates the StatefulSet when the storageMinimumSize annotation exceeds the template size: delete with propagationPolicy: Orphan, then create a copy with the expanded size. Pods are not touched.
  • A solr.apache.org/recreate-statefulset finalizer keeps the deleted StatefulSet until the copy is made, so the clusterOp lock/queue, replicas and other annotations survive.
  • A SolrCloud deleted mid-recreation still finishes it, so no StatefulSet or pods are left behind.
  • Docs: solr-cloud-crd.adoc, a v0.11.0 upgrade note, and a changelog entry in helm/solr-operator/Chart.yaml.

Tests:

  • make test → ok github.com/apache/solr-operator/controllers 127.853s (new spec "Persistent Data - Scale up after PVC expansion")
  • make prepare, make build, make lint DOCS_LINT=, operator-check-docs, make check-git → pass
  • e2e not run here; "E2E - SolrCloud - Storage / Persistent Data - Expansion / Fully Expands" covers it (added a template size assertion)

@janhoy janhoy modified the milestones: v0.10.0, main (v1.0.0) Dec 3, 2026
@janhoy
janhoy marked this pull request as ready for review December 3, 2026 15:58
@janhoy
janhoy requested a balanced review from Copilot December 3, 2026 15:58

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🟡 Changes recommended

StatefulSet recreation can lose replica counts and operation locks, potentially triggering scale-down without replica evacuation, and can leave orphaned pods after SolrCloud deletion.

2 open issues
What changed in this PR

Addresses #927 by recreating StatefulSets after PVC expansion so later scale-ups use the expanded storage size.

Changes:

  • Adds expansion detection and StatefulSet recreation with orphaned pods.
  • Adds controller and end-to-end assertions for updated claim templates.
  • Documents the behavior and upgrade implications.
File Description
tests/​e2e/​solrcloud_storage_test.go Checks the expanded claim-template size.
helm/​solr-operator/​Chart.yaml Adds a changelog entry.
docs/​modules/​upgrade-notes/​pages/​upgrade-notes.adoc Explains recreation after upgrading.
docs/​modules/​solr-cloud/​pages/​solr-cloud-crd.adoc Documents recreation during expansion.
controllers/​util/​solr_util.go Adds the finalizer constant and expansion detection helper.
controllers/​solrcloud_controller.go Implements recreation and interrupted-deletion handling.
controllers/​solrcloud_controller_storage_test.go Tests recreation and preserved StatefulSet state.

Review effort: Balanced

Comment on lines +1299 to +1300
controllerutil.RemoveFinalizer(statefulSet, util.SolrStatefulSetRecreateFinalizer)
if err = r.Update(ctx, statefulSet); err != nil {

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🤖 Fixed in fc9dfe0. The replacement StatefulSet (replicas, annotations, owner refs) is saved in a ConfigMap before the finalizer is removed, and restored if the operator is interrupted.

Comment thread controllers/solrcloud_controller.go Outdated
Comment on lines +1321 to +1323
if err := r.finishStatefulSetRecreation(ctx, statefulSet, logger); err != nil {
return reconcile.Result{}, err
}

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🤖 Fixed in fc9dfe0. When the SolrCloud is deleted mid-recreation, the StatefulSet is released, its orphaned pods are deleted and the saved ConfigMap is removed.

… orphaned pods when the SolrCloud is deleted meanwhile

Generated-By: Claude Code
@janhoy
janhoy marked this pull request as draft December 4, 2026 08:14

This branch has not been deployed

No deployments
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

A pod added by scale-up after a PVC expansion gets the original disk size

2 participants