Skip to content

Block shared disks from being attached to pod VMs #3346

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

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

Conversation

skogta
Copy link
Contributor

@skogta skogta commented Jun 19, 2025

What this PR does / why we need it:
RWX shared disks are supported only for VM service VMs. So if someone tries to attach such a volume to a pod VM, CSI driver should fail that request.

Testing done:
Created an RWX PVC with block volume mode and attached it to a pod. The pod did not come to running and it had the expected error on describing it:

Name:             pod1
Namespace:        test
Priority:         0
Service Account:  default
Node:             lvn-dvm-10-161-214-178.dvm.lvn.broadcom.net/
Labels:           <none>
Annotations:      vmware-system-image-references: {"test-container":"busybox-f462ad8139900f32e74c30158195dda0e3d9ec8e-v61241"}
Status:           Pending
IP:               
IPs:              <none>
Containers:
  test-container:
    Image:      gcr.io/google_containers/busybox:1.24
    Port:       <none>
    Host Port:  <none>
    Command:
      /bin/sh
      -c
      echo 'Hello! This is Pod1' >> /mnt/volume1/index.html && while true ; do sleep 2 ; done
    Environment:  <none>
    Mounts:
      /mnt/volume1 from test-volume (rw)
      /var/run/secrets/kubernetes.io/serviceaccount from kube-api-access-7p9fr (ro)
Conditions:
  Type           Status
  PodScheduled   True 
Volumes:
  test-volume:
    Type:       PersistentVolumeClaim (a reference to a PersistentVolumeClaim in the same namespace)
    ClaimName:  rwx-pvc-block
    ReadOnly:   false
  kube-api-access-7p9fr:
    Type:                    Projected (a volume that contains injected data from multiple sources)
    TokenExpirationSeconds:  3607
    ConfigMapName:           kube-root-ca.crt
    ConfigMapOptional:       <nil>
    DownwardAPI:             true
QoS Class:                   BestEffort
Node-Selectors:              <none>
Tolerations:                 node.kubernetes.io/not-ready:NoExecute op=Exists for 300s
                             node.kubernetes.io/unreachable:NoExecute op=Exists for 300s
Events:
  Type     Reason              Age               From                     Message
  ----     ------              ----              ----                     -------
  Normal   Scheduled           12s               default-scheduler        Successfully assigned test/pod1 to lvn-dvm-10-161-214-178.dvm.lvn.broadcom.net
  Normal   Image               12s               image-controller         Image busybox-f462ad8139900f32e74c30158195dda0e3d9ec8e-v61241 bound successfully
  Warning  FailedAttachVolume  1s (x5 over 11s)  attachdetach-controller  AttachVolume.Attach failed for volume "pvc-464dd9eb-85ca-4a67-b070-d70d510dbd1d" : rpc error: code = Unknown desc = Shared disks are not supportd for PodVMs. Invalid request {VolumeId:f71edf26-8d20-4f95-8e76-4727255426be NodeId:lvn-dvm-10-161-214-178.dvm.lvn.broadcom.net VolumeCapability:block:<> access_mode:<mode:MULTI_NODE_MULTI_WRITER >  Readonly:false Secrets:map[] VolumeContext:map[storage.kubernetes.io/csiProvisionerIdentity:1750324078186-4714-csi.vsphere.vmware.com type:vSphere CNS Block Volume] XXX_NoUnkeyedLiteral:{} XXX_unrecognized:[] XXX_sizecache:0}

Also created RWO volume with volumemode as block and RWO volume with no volumemode provided. They were both able to attach to the pod sucessfully.

@k8s-ci-robot
Copy link
Contributor

[APPROVALNOTIFIER] This PR is NOT APPROVED

This pull-request has been approved by: skogta
Once this PR has been reviewed and has the lgtm label, please assign gohilankit for approval. For more information see the 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 k8s-ci-robot added the cncf-cla: yes Indicates the PR's author has signed the CNCF CLA. label Jun 19, 2025
@skogta skogta marked this pull request as draft June 19, 2025 09:15
@k8s-ci-robot k8s-ci-robot added needs-ok-to-test Indicates a PR that requires an org member to verify it is safe to test. do-not-merge/work-in-progress Indicates that a PR should not merge because it is a work in progress. labels Jun 19, 2025
@k8s-ci-robot
Copy link
Contributor

Hi @skogta. Thanks for your PR.

I'm waiting for a kubernetes-sigs 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 Jun 19, 2025
@skogta skogta marked this pull request as ready for review June 19, 2025 09:43
@k8s-ci-robot k8s-ci-robot removed the do-not-merge/work-in-progress Indicates that a PR should not merge because it is a work in progress. label Jun 19, 2025
@k8s-ci-robot k8s-ci-robot requested a review from divyenpatel June 19, 2025 09:43
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
cncf-cla: yes Indicates the PR's author has signed the CNCF CLA. needs-ok-to-test Indicates a PR that requires an org member to verify it is safe to test. 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.

2 participants