Skip to content

Support cachingMode modification through VolumeAttributeClass#3472

Draft
Copilot wants to merge 5 commits intomasterfrom
copilot/support-changing-caching-mode
Draft

Support cachingMode modification through VolumeAttributeClass#3472
Copilot wants to merge 5 commits intomasterfrom
copilot/support-changing-caching-mode

Conversation

Copy link

Copilot AI commented Jan 20, 2026

Problem

The cachingMode parameter could only be set at volume creation time. Users needed to recreate volumes to change caching behavior.

Solution

Add cachingMode support to ControllerModifyVolume. Since cachingMode is an attachment-level property (not persisted in Azure disk metadata), the driver validates the parameter and the external-resizer updates the PV's volumeAttributes. The new caching mode applies on next attachment.

Changes

  • Validation logic

    • Added ValidateCachingModeForSKU() function to validate compatibility (PremiumV2_LRS and UltraSSD_LRS require None)
    • Shared between ParseDiskParameters() and ControllerModifyVolume()
  • ControllerModifyVolume

    • Parse and validate cachingMode from MutableParameters
    • Added getDiskSKUName() helper for safe SKU extraction
  • Documentation

    • Updated VolumeAttributeClass parameter table
    • Added example configurations

Example Usage

apiVersion: storage.k8s.io/v1alpha1
kind: VolumeAttributesClass
metadata:
  name: azure-disk-caching-readonly
driverName: disk.csi.azure.com
parameters:
  cachingMode: "ReadOnly"

After patching a PVC to use this VAC, the caching mode changes take effect when the volume is re-attached (pod restart, node restart, etc.).

Warning

Firewall rules blocked me from connecting to one or more addresses (expand for details)

I tried to connect to the following addresses, but was blocked by firewall rules:

  • login.microsoftonline.com
    • Triggering command: /tmp/go-build1834556328/b001/azuredisk.test /tmp/go-build1834556328/b001/azuredisk.test -test.testlogfile=/tmp/go-build1834556328/b001/testlog.txt -test.paniconexit0 -test.timeout=10m0s -test.v=true driver/azuredisk-errorsas cfg ux_amd64/vet /fileserviceprop/opt/hostedtoolcache/go/1.24.11/x64/pkg/tool/linux_amd64/vet /fileserviceprop-atomic -lang=go1.24 ux_amd64/vet -o 412366/b1103/_pk-errorsas k/azuredisk-csi--ifaceassert ux_amd64/vet tion_v1/reflectiumount tion_v1/reflecti/tmp/kubelet-detect-safe-umount373984403 -lang=go1.24 ux_amd64/vet (dns block)
    • Triggering command: /tmp/go-build85801472/b1217/azuredisk.test /tmp/go-build85801472/b1217/azuredisk.test -test.testlogfile=/tmp/go-build85801472/b1217/testlog.txt -test.paniconexit0 -test.gocoverdir=/tmp/go-build85801472/b1217/gocoverdir -test.timeout=10m0s -test.v=true cfg ux_amd64/vet til.go k8s.io/client-go/tmp/kubelet-detect-safe-umount2871886555 -lang=go1.24 ux_amd64/vet (dns block)

If you need me to access, download, or install something from one of these locations, you can either:

Original prompt

This section details on the original issue you should resolve

<issue_title>Support changing cachingMode through VolumeAttributeClass</issue_title>
<issue_description>Is your feature request related to a problem?/Why is this needed

Right now, the only way to change the cachingMode of a volume seems to be to re-create it. It would be great if this would be possible through a VolumeAttributeClass.

Describe the solution you'd like in detail

Describe alternatives you've considered

Additional context

</issue_description>

Comments on the Issue (you are @copilot in this section)


✨ Let Copilot coding agent set things up for you — coding agent works faster and does higher quality work when set up for your repo.

@k8s-ci-robot k8s-ci-robot added do-not-merge/work-in-progress Indicates that a PR should not merge because it is a work in progress. needs-ok-to-test Indicates a PR that requires an org member to verify it is safe to test. labels Jan 20, 2026
@k8s-ci-robot
Copy link
Contributor

Hi @Copilot. Thanks for your PR.

I'm waiting for a kubernetes-sigs member to verify that this patch is reasonable to test. If it is, they should reply with /ok-to-test on its own line. Until that is done, I will not automatically test new commits in this PR, but the usual testing commands by org members will still work. Regular contributors should join the org to skip this step.

Once the patch is verified, the new status will be reflected by the ok-to-test label.

I understand the commands that are listed here.

Details

Instructions for interacting with me using PR comments are available here. If you have questions or suggestions related to my behavior, please file an issue against the kubernetes-sigs/prow repository.

@k8s-ci-robot k8s-ci-robot added size/XS Denotes a PR that changes 0-9 lines, ignoring generated files. cncf-cla: yes Indicates the PR's author has signed the CNCF CLA. labels Jan 20, 2026
- Parse and validate cachingMode from MutableParameters in ControllerModifyVolume
- Add validation for PremiumV2_LRS and UltraSSD_LRS (only None caching mode)
- Add comprehensive unit tests for cachingMode modification scenarios
- Update documentation (driver-parameters.md and modifyvolume README)
- Add example VolumeAttributesClass with cachingMode

Co-authored-by: andyzhangx <4178417+andyzhangx@users.noreply.github.com>
@k8s-ci-robot
Copy link
Contributor

[APPROVALNOTIFIER] This PR is NOT APPROVED

This pull-request has been approved by: Copilot
Once this PR has been reviewed and has the lgtm label, please ask for approval from andyzhangx. For more information see the Code Review Process.

The full list of commands accepted by this bot can be found here.

Details Needs approval from an approver in each of these files:

Approvers can indicate their approval by writing /approve in a comment
Approvers can cancel approval by writing /approve cancel in a comment

@k8s-ci-robot k8s-ci-robot added size/L Denotes a PR that changes 100-499 lines, ignoring generated files. and removed size/XS Denotes a PR that changes 0-9 lines, ignoring generated files. labels Jan 20, 2026
Copilot AI and others added 3 commits January 20, 2026 15:05
- Extract ValidateCachingModeForSKU function to eliminate code duplication
- Rename targetSKU to effectiveSKU for better clarity
- Add comprehensive unit tests for ValidateCachingModeForSKU
- Update both ParseDiskParameters and ControllerModifyVolume to use shared validation

Co-authored-by: andyzhangx <4178417+andyzhangx@users.noreply.github.com>
- Add getDiskSKUName helper function to simplify nested nil checks
- Fix typo in GetAttachDiskInitialDelay comment

Co-authored-by: andyzhangx <4178417+andyzhangx@users.noreply.github.com>
Copilot AI changed the title [WIP] Support changing cachingMode through VolumeAttributeClass Support cachingMode modification through VolumeAttributeClass Jan 20, 2026
Copilot AI requested a review from andyzhangx January 20, 2026 15:17
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

cncf-cla: yes Indicates the PR's author has signed the CNCF CLA. do-not-merge/work-in-progress Indicates that a PR should not merge because it is a work in progress. needs-ok-to-test Indicates a PR that requires an org member to verify it is safe to test. size/L Denotes a PR that changes 100-499 lines, ignoring generated files.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Support changing cachingMode through VolumeAttributeClass

3 participants