Skip to content

Conversation

@aa1ex
Copy link

@aa1ex aa1ex commented Feb 2, 2026

Description

When spec.storage contains only volumeMount entries (e.g. emptyDir) without volumeClaimTemplate, the operator incorrectly set PersistenceEnabled=true, causing an empty volumeClaimTemplates entry in the resulting StatefulSet. This led to unnecessary (and possibly broken) PVC provisioning.

Root cause: PersistenceEnabled was set based solely on cr.Spec.Storage != nil, without checking whether volumeClaimTemplate is actually populated. Since the Storage struct is non-nil whenever any storage is configured (including volumeMount-only with emptyDir), the operator always treated it as a request for a PersistentVolumeClaim.

Changes:

  • Added storageHasVolumeClaimTemplate() helper in statefulset.go that checks whether VolumeClaimTemplate has meaningful content (AccessModes, Resources.Requests, StorageClassName, or VolumeName)
  • Redis standalone and replication: replaced cr.Spec.Storage != nil with storageHasVolumeClaimTemplate() for both container and init container params
  • Redis cluster init container: aligned the check with the existing container params logic (PersistenceEnabled != nil && *PersistenceEnabled)
  • Added unit tests for storageHasVolumeClaimTemplate

Type of change

  • Bug fix (non-breaking change which fixes an issue)

Checklist

  • Tests have been added/modified and all tests pass.
  • Functionality/bugs have been confirmed to be unchanged or fixed.
  • I have performed a self-review of my own code.
  • Documentation has been updated or added where necessary.

Additional Context

Users who have volumeClaimTemplate properly configured are not affected — behavior is unchanged for them. The fix only removes the incorrect empty PVC creation for volumeMount-only storage configurations.

When spec.storage contains only volumeMount entries (e.g. emptyDir)
without volumeClaimTemplate, the operator incorrectly set
PersistenceEnabled=true, causing an empty volumeClaimTemplates entry
in the StatefulSet. Check whether volumeClaimTemplate is actually
populated before enabling persistence.

Signed-off-by: Aleksandrov Aleksandr <aaleksandrov.cy@gmail.com>
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.

1 participant