Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add subDir parameter support in VolumeSnapshotClass #869

Open
bells17 opened this issue Feb 22, 2025 · 2 comments
Open

Add subDir parameter support in VolumeSnapshotClass #869

bells17 opened this issue Feb 22, 2025 · 2 comments
Assignees

Comments

@bells17
Copy link

bells17 commented Feb 22, 2025

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

Currently, the subDir parameter is supported in StorageClass, allowing PVCs to be created inside a specific folder. This is particularly useful for organizing and separating data by directories in the NFS CSI driver.

However, when creating snapshots via VolumeSnapshot, there is no option to specify subDir. As a result, snapshots are always stored in the root directory of the NFS server, with names like snapshot-<snapshotUID>.
https://github.com/kubernetes-csi/external-snapshotter/blob/v8.2.0/pkg/sidecar-controller/csi_handler.go#L87

Describe the solution you'd like in detail

VolumeSnapshotClass should support the subDir parameter, just like StorageClass. This would allow snapshots to be stored in the same subdirectory as their corresponding PVCs when using the NFS CSI driver.

Since VolumeSnapshotClass already has a parameters field, this change would require modifications to the CSI driver and would not impact any Kubernetes core components or external-snapshotter behavior.

Proposed Parameter Handling:

The subDir parameter should be processed within the CSI driver to determine the directory where snapshots are stored. Below is an example configuration:

apiVersion: snapshot.storage.k8s.io/v1
kind: VolumeSnapshotClass
metadata:
name: my-snapshot-class
parameters:
subDir: "snapshots"
  • If subDir is specified, the snapshot will be stored inside the given subdirectory.
  • If not specified, the default behavior (storing in the root directory) remains unchanged.

Describe alternatives you've considered

  • Manually moving snapshots to the desired subdirectory after creation, which is not ideal due to automation and access control limitations. Additionally, the VolumeSnapshotContent.status.snapshotHandle would also need to be manually updated, which is not supported by Kubernetes and can lead to inconsistencies.

Additional context

This feature would be particularly beneficial for this CSI driver, where organizing snapshots in specific directories can improve manageability. Allowing users to specify subDir in VolumeSnapshotClass ensures consistency in snapshot placement and improves manageability.

Additionally, modifying subDir does not affect existing snapshots. Since parameters in VolumeSnapshotClass cannot be modified after creation, users must create a new VolumeSnapshotClass with the desired subDir. Moreover, the snapshotHandle stored in VolumeSnapshotContent.status includes folder information, ensuring that restoring snapshots remains unaffected by subDir changes.

Expected Directory Structure Change

Current Behavior:

/nfs-root/snapshot-<snapshotUID>

Proposed Behavior with subDir: snapshots:

/nfs-root/snapshots/snapshot-<snapshotUID>
@bells17
Copy link
Author

bells17 commented Mar 3, 2025

/assign

@andyzhangx
Copy link
Member

the VolumeSnapshotClass supports share parameter (it's / by default), which means you could create a dedicated subdir in root dir to store snapshot, original snapshot volume id does not contain subDir which means this could be a breaking change if we support subDir in VolumeSnapshotClass since we also need to add subDir into snapshot volume id if we want to support subDir in VolumeSnapshotClass

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

No branches or pull requests

2 participants