Skip to content

cephfs: add SetSubVolCSIMetadata to set CSI metadata on subvolumes#6174

Merged
mergify[bot] merged 1 commit intoceph:develfrom
iPraveenParihar:cephfs/backfill-csi-metadata
Mar 25, 2026
Merged

cephfs: add SetSubVolCSIMetadata to set CSI metadata on subvolumes#6174
mergify[bot] merged 1 commit intoceph:develfrom
iPraveenParihar:cephfs/backfill-csi-metadata

Conversation

@iPraveenParihar
Copy link
Copy Markdown
Contributor

@iPraveenParihar iPraveenParihar commented Mar 10, 2026

Describe what this PR does

Add support for setting CSI metadata (PV/PVC info) on CephFS subvolumes. The PV controller now distinguishes between CephFS and RBD PVs and dispatches accordingly.

Future concerns

List items that are not part of the PR and do not impact it's
functionality, but are work items that can be taken up subsequently.

Checklist:

  • Commit Message Formatting: Commit titles and messages follow guidelines in the developer guide.
  • Reviewed the developer guide on Submitting a Pull Request
  • Pending release notes updated with breaking and/or notable changes for the next major release.
  • Documentation has been updated, if necessary.
  • Unit tests have been added, if necessary.
  • Integration tests have been added, if necessary.

Show available bot commands

These commands are normally not required, but in case of issues, leave any of
the following bot commands in an otherwise empty comment in this PR:

  • /retest ci/centos/<job-name>: retest the <job-name> after unrelated
    failure (please report the failure too!)

@mergify mergify bot added the component/cephfs Issues related to CephFS label Mar 10, 2026
@iPraveenParihar iPraveenParihar force-pushed the cephfs/backfill-csi-metadata branch from 4c9d310 to e7fb4f3 Compare March 11, 2026 04:27
@iPraveenParihar iPraveenParihar marked this pull request as ready for review March 11, 2026 11:34
// CephFS PVs always have "fsName" in their volume attributes (required
// StorageClass parameter), while RBD PVs do not.
_, isCephFS := pv.Spec.CSI.VolumeAttributes["fsName"]
if isCephFS {
Copy link
Copy Markdown
Member

@nixpanic nixpanic Mar 17, 2026

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Instead of doing a if-return-action and standard-action, put the difference in handling in a switch/case. This makes the code easier to read and better maintainable.

With this approach, it is not clear if there should be a rbdVolID != volumeHandler check for CephFS too. Possibly it was missed as it is done at the end of the function.

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

For CephFS, we are only setting the CSI metadata and no new volumeID is generated to compare. rbdVolID != volumeHandler is only for RBD PVC.

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yes, I understand that, but we try to keep this generic flow in functions:

  • validate parameters, return on error
  • do something, return on error
  • do something else, return on error
  • final things
  • return success

The point is, that the if isCephFS { section returns from the function on success. This isn't structured well, as CephFS/RBD are handled both in this function, but not equally (for the lack of better phrasing).

To keep the understandable and clear readable structure above, it is better to handle the differences between CephFS/RBD in a switch (or if/else if you prefer that).

My 1st impression was that the handling for CephFS/RBD should be done in their own functions. But because it is a single call for CephFS, and only two actions for RBD, placing them inside a switch statement is clean enough.

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

With only two cases, I'll prefer if/else directly.

@iPraveenParihar iPraveenParihar force-pushed the cephfs/backfill-csi-metadata branch from 82cc455 to ab3b7d6 Compare March 23, 2026 05:58
Comment on lines +141 to +145
// Determine PV type from volume attributes and dispatch accordingly.
// CephFS PVs always have "fsName" in their volume attributes (required
// StorageClass parameter), while RBD PVs do not.
_, isCephFS := pv.Spec.CSI.VolumeAttributes["fsName"]
if isCephFS {
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

use type cmdline flag as used with cephcsi cmd

with default as rbd

flag.StringVar(&conf.Vtype, "type", "", "driver type [rbd|cephfs|nfs|nvmeof|liveness|controller]")

ceph-csi/cmd/cephcsi.go

Lines 174 to 179 in 46123d6

// select driver name based on volume type
switch conf.Vtype {
case util.RBDType:
return rbdDefaultName
case util.CephFsType:
return cephFSDefaultName

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@Rakshith-R we already pass type=controller for the omap sidecars.

@nixpanic
Copy link
Copy Markdown
Member

Can be rebased and ok-to-test'd once #6197 is merged.

@iPraveenParihar
Copy link
Copy Markdown
Contributor Author

@Mergifyio rebase

Add support for setting CSI metadata (PV/PVC info) on CephFS
subvolumes. The PV controller now distinguishes between CephFS
and RBD PVs and dispatches accordingly.

Signed-off-by: Praveen M <m.praveen@ibm.com>
@mergify
Copy link
Copy Markdown
Contributor

mergify bot commented Mar 25, 2026

rebase

✅ Branch has been successfully rebased

@ceph-csi-bot ceph-csi-bot force-pushed the cephfs/backfill-csi-metadata branch from ab3b7d6 to 196d60a Compare March 25, 2026 07:47
@iPraveenParihar
Copy link
Copy Markdown
Contributor Author

/test ci/centos/mini-e2e-helm/k8s-1.35

@iPraveenParihar
Copy link
Copy Markdown
Contributor Author

/test ci/centos/mini-e2e/k8s-1.35

@iPraveenParihar
Copy link
Copy Markdown
Contributor Author

/retest ci/centos/mini-e2e/k8s-1.35

@nixpanic
Copy link
Copy Markdown
Member

@Mergifyio rebase

@nixpanic nixpanic added the ok-to-test Label to trigger E2E tests label Mar 25, 2026
@ceph-csi-bot
Copy link
Copy Markdown
Collaborator

/test ci/centos/k8s-e2e-external-storage/1.33

@ceph-csi-bot
Copy link
Copy Markdown
Collaborator

/test ci/centos/upgrade-tests-cephfs

@ceph-csi-bot
Copy link
Copy Markdown
Collaborator

/test ci/centos/k8s-e2e-external-storage/1.35

@ceph-csi-bot
Copy link
Copy Markdown
Collaborator

/test ci/centos/k8s-e2e-external-storage/1.34

@ceph-csi-bot
Copy link
Copy Markdown
Collaborator

/test ci/centos/mini-e2e-helm/k8s-1.33

@ceph-csi-bot
Copy link
Copy Markdown
Collaborator

/test ci/centos/upgrade-tests-rbd

@ceph-csi-bot
Copy link
Copy Markdown
Collaborator

/test ci/centos/mini-e2e-helm/k8s-1.34

@ceph-csi-bot
Copy link
Copy Markdown
Collaborator

/test ci/centos/mini-e2e-helm/k8s-1.35

@ceph-csi-bot
Copy link
Copy Markdown
Collaborator

/test ci/centos/mini-e2e/k8s-1.33

@ceph-csi-bot
Copy link
Copy Markdown
Collaborator

/test ci/centos/mini-e2e/k8s-1.34

@ceph-csi-bot
Copy link
Copy Markdown
Collaborator

/test ci/centos/mini-e2e/k8s-1.35

@mergify
Copy link
Copy Markdown
Contributor

mergify bot commented Mar 25, 2026

rebase

☑️ Nothing to do, the required conditions are not met

Details
  • any of:
    • #commits-behind > 0 [📌 rebase requirement]
    • -linear-history [📌 rebase requirement]
  • -closed [📌 rebase requirement]
  • -conflict [📌 rebase requirement]
  • queue-position = -1 [📌 rebase requirement]

@nixpanic nixpanic removed the ok-to-test Label to trigger E2E tests label Mar 25, 2026
@mergify mergify bot merged commit 9ca3fa1 into ceph:devel Mar 25, 2026
36 of 37 checks passed
@mergify
Copy link
Copy Markdown
Contributor

mergify bot commented Mar 25, 2026

Merge Queue Status

  • Entered queue2026-03-25 16:52 UTC · Rule: default
  • Checks skipped · PR is already up-to-date
  • Merged2026-03-25 16:52 UTC · at 196d60a6c307ae12bcf7d06bf273aaab7900bbdc

This pull request spent 5 seconds in the queue, with no time running CI.

Required conditions to merge

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

component/cephfs Issues related to CephFS

Projects

None yet

Development

Successfully merging this pull request may close these issues.

5 participants