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

[cinder-csi-plugin] Validate volume capabilities in RPC call CreateVolume #2729

Open
wants to merge 1 commit into
base: master
Choose a base branch
from

Conversation

nschad
Copy link

@nschad nschad commented Nov 20, 2024

What this PR does / why we need it:

Cinder currently only supports VolumeCapability_AccessMode_SINGLE_NODE_WRITER, therefore we should not allow it to provision volumes with AccessMode RWX. This will only lead to "errors" when replica > 1.

Additionally, the spec states (as I understand it) that the CreateVolume RPC call must support all specified volume capabilities, which was not the case previously. So this is why I added the check here.

Example of Error Message in K8s

 Warning  ProvisioningFailed    2s (x2 over 3s)  cinder.csi.openstack.org_csi-driver-controller-foo  failed to provision volume with StorageClass "bar": rpc error: code = InvalidArgument desc = volume access mode MULTI_NODE_MULTI_WRITER not supported

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

Special notes for reviewers:

Release note:

[cinder-csi-plugin] Enforce VolumeCapabilities when creating volumes.

@k8s-ci-robot k8s-ci-robot added the release-note Denotes a PR that will be considered when it comes time to generate release notes. label Nov 20, 2024
Copy link

CLA Not Signed

@k8s-ci-robot k8s-ci-robot added the cncf-cla: no Indicates the PR's author has not signed the CNCF CLA. label Nov 20, 2024
@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 dulek for approval. For more information see the Kubernetes Code Review Process.

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

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
Copy link
Contributor

Welcome @nschad!

It looks like this is your first PR to kubernetes/cloud-provider-openstack 🎉. Please refer to our pull request process documentation to help your PR have a smooth ride to approval.

You will be prompted by a bot to use commands during the review process. Do not be afraid to follow the prompts! It is okay to experiment. Here is the bot commands documentation.

You can also check if kubernetes/cloud-provider-openstack has its own contribution guidelines.

You may want to refer to our testing guide if you run into trouble with your tests not passing.

If you are having difficulty getting your pull request seen, please follow the recommended escalation practices. Also, for tips and tricks in the contribution process you may want to read the Kubernetes contributor cheat sheet. We want to make sure your contribution gets all the attention it needs!

Thank you, and welcome to Kubernetes. 😃

@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 Nov 20, 2024
@k8s-ci-robot
Copy link
Contributor

Hi @nschad. 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.

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 size/S Denotes a PR that changes 10-29 lines, ignoring generated files. label Nov 20, 2024
@kayrus
Copy link
Contributor

kayrus commented Nov 20, 2024

@nschad thanks for the PR. can you share a detailed step-by-step instructions on how to reproduce a problem?

@nschad
Copy link
Author

nschad commented Nov 20, 2024

@nschad thanks for the PR. can you share a detailed step-by-step instructions on how to reproduce a problem?

Sure

  1. Create a Deployment with an Volume in RWX mode.
apiVersion: apps/v1
kind: Deployment
metadata:
  name: simple-deployment
spec:
  replicas: 2
  selector:
    matchLabels:
      app: simple-app
  template:
    metadata:
      labels:
        app: simple-app
    spec:
      containers:
      - name: simple-container
        image: nginx
        volumeMounts:
        - mountPath: /mnt/data
          name: simple-volume
      volumes:
      - name: simple-volume
        persistentVolumeClaim:
          claimName: simple-pvc

---
apiVersion: v1
kind: PersistentVolumeClaim
metadata:
  name: simple-pvc
spec:
  accessModes:
    - ReadWriteMany  # RWX access mode
  resources:
    requests:
      storage: 5Gi
  1. Watch the Volume be successfully bounded to Pod 1/Node A and embrace the error you will definitely get when your Pod 2 on Node B can't attach the volume, because cinder doesn't do MULTI_NODE_MULTI_POD

In my opinion the volume shouldn't be provisioned in the first place with AccessMode RWX. That is exactly what this PR does.

@kayrus
Copy link
Contributor

kayrus commented Nov 20, 2024

In my opinion the volume shouldn't be provisioned in the first place with AccessMode RWX. That is exactly what this PR does.

I see, but I wonder whether this can be considered as a default behavior for someone else. Do you know what's the behavior of other CSI drivers, e.g. GCE or AWS?

UPD: basically I expect that csi-provisioner handles this and doesn't allow to create a ReadWriteMany volume based on the CSI plugin capabilities.

@nschad
Copy link
Author

nschad commented Nov 21, 2024

In my opinion the volume shouldn't be provisioned in the first place with AccessMode RWX. That is exactly what this PR does.

I see, but I wonder whether this can be considered as a default behavior for someone else. Do you know what's the behavior of other CSI drivers, e.g. GCE or AWS?

Yes, for example:

UPD: basically I expect that csi-provisioner handles this and doesn't allow to create a ReadWriteMany volume based on the CSI plugin capabilities.

Yeah maybe but it's just not the reality currently. There is the RPC call ValidateVolumeCapabilities (also implemented here) but that only gets called AFAIK for pre-provisioned volumes which is for us like 0.01% of the use case.

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 Denotes a PR that will be considered when it comes time to generate release notes. size/S Denotes a PR that changes 10-29 lines, ignoring generated files.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants