Skip to content

chore(controller): stop reporting spurious VolumeClaimTemplates changes on every reconcile - #587

Open
miledxz wants to merge 1 commit into
mainfrom
volume-claim-template-fix
Open

miledxz wants to merge 1 commit into
mainfrom
volume-claim-template-fix

Conversation

@miledxz

@miledxz miledxz commented Sep 15, 2026

Copy link
Copy Markdown
Contributor

Problem

Since v1.6.0 (#519) every Dragonfly instance with a persistentVolumeClaimSpec logs

VolumeClaimTemplates change detected but cannot be applied to an existing StatefulSet; ...

and emits a Warning ImmutableField event on each reconcile, including fresh installs and operator restarts, even though the PVC spec was never changed.

reconcileResources compared stsDesired.Spec.VolumeClaimTemplates with the live templates using reflect.DeepEqual. The API server adds fields the operator never sets, so the two sides are never byte-equal:

- apiVersion: v1                 # added
  kind: PersistentVolumeClaim    # added
  spec:
    volumeMode: Filesystem       # defaulted
  status:
    phase: Pending               # added

Reproduced and verified on a kind cluster (Kubernetes v1.34)

Copilot AI lite review requested due to automatic review settings September 15, 2026 20:34
@miledxz miledxz changed the title chore(controller): stop reporting spurious VolumeClaimTemplates chang… chore(controller): stop reporting spurious VolumeClaimTemplates changes on every reconcile Sep 15, 2026

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

Add the requested comparison tests and normalize the dataSource/dataSourceRef pair.

Get a fresh assessment by requesting another Copilot review.

Pull request overview

This PR updates StatefulSet PVC template comparison to avoid spurious immutable-field warnings caused by Kubernetes-populated defaults.

Changes:

  • Adds normalized PVC template equality checks.
  • Normalizes the default volumeMode before comparison.
File summaries
File Summary
internal/controller/dragonfly_instance.go Implementation reviewed; tests are needed for normalized defaults and real changes, and dataSource/dataSourceRef synchronization must also be normalized.
Review details

Suppressed comments (1)

internal/controller/dragonfly_instance.go:786

  • This still compares the full PVC spec after normalizing only volumeMode. Kubernetes also synchronizes dataSource and dataSourceRef when one is supplied (the CRD exposes both), so a template created from a spec containing only one of them can come back with both and trigger this warning on every reconcile. Normalize that pair (or apply the Kubernetes PVC defaults to both operands) before comparing.
		if !equality.Semantic.DeepEqual(defaultedPVCSpec(d.Spec), defaultedPVCSpec(e.Spec)) {
			return false
  • Files reviewed: 1/1 changed files
  • Comments generated: 1
  • Review effort level: Lite

💡 Add a code-review agent skill or configure MCP servers for context-aware, tailored reviews. Learn more in the docs.

Comment thread internal/controller/dragonfly_instance.go
@miledxz
miledxz requested a review from Abhra303 September 15, 2026 20:44
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

2 participants