Skip to content

feat(volume): support VolumeAttributesClass in the cluster manifest - #3218

Open
monotek wants to merge 1 commit into
zalando:masterfrom
monotek:feat/volume-attributes-class
Open

monotek wants to merge 1 commit into
zalando:masterfrom
monotek:feat/volume-attributes-class

Conversation

@monotek

@monotek monotek commented Nov 4, 2026

Copy link
Copy Markdown

Problem description

There is no way to set a VolumeAttributesClass on the data volumes. That class is how Kubernetes changes IOPS and throughput of existing volumes in place, without the AWS-only mixed resize mode.

This PR adds an optional spec.volume.volumeAttributesClass. The operator sets it on the volume claim template and updates the existing PVCs, and the CSI driver then modifies the volumes without restarting the pods.

 Update / Sync
   syncVolumes                          # Update: now also runs with storage_resize_mode "off"
     syncUnderlyingEBSVolume            # mixed mode
+      skip iops/throughput/type when a class is set
     syncVolumeClaims
       grow size                        # skipped with mode "off"/"ebs"
+      set volumeAttributesClassName    # if set in manifest and different
   generateStatefulSet
     volume claim template
+      volumeAttributesClassName

Removing the field leaves the class on existing PVCs.

Merge danger: two-way door; blast radius opt-in. Clusters without the field get no template change and no StatefulSet replacement. One behaviour change for everyone: with storage_resize_mode: off, an update now also syncs PVC annotations, as the periodic sync already did.

Details

Evidence

New tests TestVolumeAttributesClass (PVC template) and TestSyncVolumeAttributesClass (live PVCs):

before: template class = nil, PVC class = nil        -> FAIL (expected "gp3-fast")
after:  template class = "gp3-fast"
        PVCs of the cluster:     nil -> "gp3-fast", "gp3-slow" -> "gp3-fast"
        storage_resize_mode off: nil -> "gp3-fast"
        field removed:           "gp3-slow" stays
        PVC of another cluster:  unchanged             -> PASS

go test ./...: 358 passed. hack/verify-codegen.sh: up to date.

Known limits

  • Needs Kubernetes 1.34+ (or the VolumeAttributesClass feature gate) and a CSI driver that supports ModifyVolume. If the API server drops the field, the operator keeps trying to set it on every sync.
  • AWS allows one modification per EBS volume about every 6 hours, so a size change and a class change in the same sync can make the second one fail.

Linked issues

None found.

Checklist

Thanks for submitting a pull request to the Postgres Operator project.
Please, ensure your contribution matches the following items:

  • Your go code is formatted. Your IDE should do it automatically for you.
  • You have updated generated code when introducing new fields to the acid.zalan.do api package.
  • New configuration options are reflected in CRD validation, helm charts and sample manifests.
  • New functionality is covered by unit and/or e2e tests.
  • You have checked existing open PRs for possible overlay and referenced them.

🤖 Generated with Claude Code

Add spec.volume.volumeAttributesClass to the postgresql CRD. The operator
sets it on the statefulset's data volume claim template and updates the
existing persistent volume claims in place, so the CSI driver can modify
the volumes without recreating them.

- Volume claims are synced on update regardless of storage_resize_mode;
  only size changes stay gated by it.
- In mixed mode the operator no longer changes iops, throughput or type
  through the AWS API when a class is set.
- Removing the field keeps the class on existing volume claims.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
@monotek
monotek marked this pull request as ready for review November 4, 2026 18:52
@FxKu FxKu added the minor label Nov 10, 2026
@FxKu FxKu added this to the wishlist milestone Nov 10, 2026
@FxKu FxKu moved this to Waiting for review in Postgres Operator Nov 10, 2026

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

Projects

Status: Waiting for review

Development

Successfully merging this pull request may close these issues.

2 participants