[Bug]: PVC VolumeAttributesClass reconciliation issues redundant PATCH updates · Issue #11194 · cloudnative-pg/cloudnative-pg · GitHub
Skip to content

[Bug]: PVC VolumeAttributesClass reconciliation issues redundant PATCH updates #11194

Description

@andrew-farries

Is there an existing issue already for this bug?

  • I have searched for an existing issue, and could not find anything. I believe this is a new bug.

I have read the troubleshooting guide

  • I have read the troubleshooting guide and I think this is a new bug.

I am running a supported version of CloudNativePG

  • I have read the troubleshooting guide and I think this is a new bug.

Contact Details

andrew.farries@xata.io

Version

1.30.0

What version of Kubernetes are you using?

1.31

What is your Kubernetes environment?

Cloud: Amazon EKS

How did you install the operator?

YAML manifest

What happened?

Reconciliation of Cluster resources that set volumeAttributesClassName in a pvcTemplate always issues a redundant, empty PATCH operation against each of the cluster's PVCs, even when the PVC already carries the expected value. This is caused by an incorrect comparison here:

The guard in reconcileVolumeAttributeClass compares two *string pointers with ==, which tests pointer identity rather than value equality. Since the template's pointer and the PVC's pointer never share an allocation, the comparison only succeeds when both sides are nil — with a volumeAttributesClass configured, it fails on every reconciliation.

The impact is limited to wasted API-server traffic: because the assigned value is identical, the computed merge patch is empty ({}), so the PVC is not actually modified. The existing unit test doesn't catch this because it assigns the same pointer to both the PVC and the template.

Introduced in #7885.

Cluster resource

Relevant log output

Code of Conduct

  • I agree to follow this project's Code of Conduct

Activity

  1. dosubot commented on Jul 14, 2026

    @dosubot

    Hi @andrew-farries! I'm Dosu and I'm helping the CloudNativePG team.

    Your analysis is correct. The comparison at line 111 [1] checks pointer identity (== on two *string values) rather than dereferenced value equality, so it will always fall through to the PATCH path when volumeAttributesClassName is set — even when the values are already identical.

    As you noted, the existing unit test for the "does nothing if VolumeAttributesClassName is already the expected value" case [2] reuses the same string variable for both the PVC and the template, which means both pointers share an address and the == check happens to pass — masking the bug in tests.

    A fix would be to replace the pointer comparison with a value-aware comparison, e.g. using ptr.Equal:

    if ptr.Equal(expectedVolumeAttributesClassName, pvc.Spec.VolumeAttributesClassName) {
        return nil
    }

    And the test should be updated to use independently allocated *string values (e.g. via ptr.To("value") for each side) to properly exercise the comparison.

    To reply, just mention @dosu.


    Share context across your team and agents. Try Dosu.

    Leave Feedback Learn about cloudnative-pg with Dosu Add Dosu to your team

  2. added this to the 1.30.1 milestone on Jul 15, 2026
  3. added 3 commits that reference this issue on Jul 17, 2026
    abb18c6
    4926ad1
    7095c2e
  4. added a commit that references this issue on Jul 17, 2026
    1462ab1
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

Labels

bug 🐛Something isn't working

Type

Projects

Milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions