Skip to content

[cinder-csi-plugin] Add mkfsOptions StorageClass parameter#3084

Open
rybnico wants to merge 1 commit intokubernetes:masterfrom
rybnico:feature/add-mkfs-options
Open

[cinder-csi-plugin] Add mkfsOptions StorageClass parameter#3084
rybnico wants to merge 1 commit intokubernetes:masterfrom
rybnico:feature/add-mkfs-options

Conversation

@rybnico
Copy link

@rybnico rybnico commented Mar 17, 2026

What this PR does / why we need it:

Add support for a new mkfsOptions StorageClass parameter that allows cluster admins to pass custom mkfs flags when formatting volumes. This is particularly useful for Ceph-backed storage where passing -E nodiscard to mkfs.ext4 can dramatically speed up provisioning (e.g. from ~7 minutes to seconds for a 100 GB volume).

The parameter value is comma-separated, with each token further split on whitespace to produce individual mkfs command-line arguments. Example: mkfsOptions: "-E nodiscard,-O ^metadata_csum"

Implementation:

  • Extract mkfsOptions from StorageClass params in CreateVolume and pass via VolumeContext (both new-volume and idempotent early-return paths)
  • Parse mkfsOptions in NodeStageVolume using parseMkfsOptions() helper
  • Use FormatAndMountSensitiveWithFormatOptions() from k8s.io/mount-utils to pass format options separately from mount options
  • No behavior change when mkfsOptions is not set

Which issue this PR fixes(if applicable):
fixes #3068

Special notes for reviewers:
Inspired by the Ceph CSI implementation (ceph/ceph-csi#621).

Release note:

NONE

Add support for a new `mkfsOptions` StorageClass parameter that allows
cluster admins to pass custom mkfs flags when formatting volumes. This
is particularly useful for Ceph-backed storage where passing
`-E nodiscard` to mkfs.ext4 can dramatically speed up provisioning
(e.g. from ~7 minutes to seconds for a 100 GB volume).

The parameter value is comma-separated, with each token further split
on whitespace to produce individual mkfs command-line arguments.
Example: `mkfsOptions: "-E nodiscard,-O ^metadata_csum"`

Implementation:
- Extract mkfsOptions from StorageClass params in CreateVolume and pass
  via VolumeContext (both new-volume and idempotent early-return paths)
- Parse mkfsOptions in NodeStageVolume using parseMkfsOptions() helper
- Use FormatAndMountSensitiveWithFormatOptions() from k8s.io/mount-utils
  to pass format options separately from mount options
- No behavior change when mkfsOptions is not set

Inspired by the Ceph CSI implementation (ceph/ceph-csi#621).

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
@k8s-ci-robot k8s-ci-robot added the release-note-none Denotes a PR that doesn't merit a release note. label Mar 17, 2026
@linux-foundation-easycla
Copy link

linux-foundation-easycla bot commented Mar 17, 2026

CLA Missing ID CLA Not Signed

One or more co-authors of this pull request were not found. You must specify co-authors in commit message trailer via:

Co-authored-by: name <email>

Supported Co-authored-by: formats include:

  1. Anything <id+login@users.noreply.github.com> - it will locate your GitHub user by id part.
  2. Anything <login@users.noreply.github.com> - it will locate your GitHub user by login part.
  3. Anything <public-email> - it will locate your GitHub user by public-email part. Note that this email must be made public on Github.
  4. Anything <other-email> - it will locate your GitHub user by other-email part but only if that email was used before for any other CLA as a main commit author.
  5. login <any-valid-email> - it will locate your GitHub user by login part, note that login part must be at least 3 characters long.

Please update your commit message(s) by doing git commit --amend and then git push [--force] and then request re-running CLA check via commenting on this pull request:

/easycla

@k8s-ci-robot k8s-ci-robot added the needs-ok-to-test Indicates a PR that requires an org member to verify it is safe to test. label Mar 17, 2026
@k8s-ci-robot
Copy link
Contributor

Hi @rybnico. Thanks for your PR.

I'm waiting for a kubernetes 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 the cncf-cla: no Indicates the PR's author has not signed the CNCF CLA. label Mar 17, 2026
@k8s-ci-robot
Copy link
Contributor

[APPROVALNOTIFIER] This PR is NOT APPROVED

This pull-request has been approved by:
Once this PR has been reviewed and has the lgtm label, please assign stephenfin for approval. 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 the size/L Denotes a PR that changes 100-499 lines, ignoring generated files. label Mar 17, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

cncf-cla: no Indicates the PR's author has not signed the CNCF CLA. needs-ok-to-test Indicates a PR that requires an org member to verify it is safe to test. release-note-none Denotes a PR that doesn't merit a release note. 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.

[cinder-csi-plugin] Add 'mkfsOptions' parameter

2 participants