Skip to content

Feature Request: Support onDelete-like policy for Azure File share deletion behavior when reclaimPolicy=Delete #3065

@fourhu

Description

@fourhu

Is your feature request related to a problem?/Why is this needed

Yes.

In Azure File CSI driver, when a dynamically provisioned PV is deleted with StorageClass.reclaimPolicy=Delete, users currently cannot configure a CSI-level deletion behavior (for example an onDelete-like policy used by some other NFS/SMB CSI drivers).
As a result, there is no built-in way to keep the underlying Azure File share for data preservation scenarios while still using the Delete reclaim workflow for Kubernetes resources.

This is needed for:

  • safer production operations (avoid unintended data loss),
  • migration/rollback workflows,
  • better parity with user expectations from other file CSI ecosystems.

Describe the solution you'd like in detail

Add support for a StorageClass parameter (name can follow project conventions, e.g. onDelete) to control backend share behavior when PV deletion is triggered.

Suggested behavior:

  • onDelete: delete (default, backward-compatible with current behavior)
  • onDelete: retain (do not delete underlying Azure File share; only remove Kubernetes-side objects/attachments)

Implementation direction (high-level):

  1. Parse the new parameter from StorageClass.
  2. In controller DeleteVolume flow, branch deletion logic based on this parameter.
  3. Keep default behavior unchanged when parameter is not set.
  4. Add tests:
    • default path remains unchanged
    • retain path keeps the backend Azure File share after PV deletion
  5. Document parameter usage and examples in driver docs.

Describe alternatives you've considered

  1. Use reclaimPolicy: Retain at StorageClass/PV level.

    • This retains PV object semantics but does not provide CSI-level fine-grained delete behavior under Delete policy path.
  2. Manual out-of-band protection (scripts/runbooks to snapshot or recreate shares).

    • Operationally complex, error-prone, and hard to standardize.
  3. Admission/policy controls to block PVC/PV deletion in some namespaces.

    • Helps reduce accidents but does not solve storage-driver-level lifecycle control.

Additional context

  • Repository: kubernetes-sigs/azurefile-csi-driver
  • I can help validate behavior in AKS/Azure Kubernetes environments if a design/PR is proposed.
  • If maintainers prefer a different parameter name/value convention, I’m happy to align and help test.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions