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

AccessMode doesn't work properly within PVC #47333

Closed
pkutishch opened this issue Jun 12, 2017 · 14 comments
Closed

AccessMode doesn't work properly within PVC #47333

pkutishch opened this issue Jun 12, 2017 · 14 comments
Labels
lifecycle/rotten Denotes an issue or PR that has aged beyond stale and will be auto-closed. sig/storage Categorizes an issue or PR as relevant to SIG Storage.

Comments

@pkutishch
Copy link

Kubernetes version (use kubectl version):
Client Version: version.Info{Major:"1", Minor:"6", GitVersion:"v1.6.2", GitCommit:"477efc3cbe6a7effca06bd1452fa356e2201e1ee", GitTreeState:"clean", BuildDate:"2017-04-19T20:33:11Z", GoVersion:"go1.7.5", Compiler:"gc", Platform:"linux/amd64"}
Server Version: version.Info{Major:"1", Minor:"6", GitVersion:"v1.6.3", GitCommit:"0480917b552be33e2dba47386e51decb1a211df6", GitTreeState:"clean", BuildDate:"2017-05-10T15:38:08Z", GoVersion:"go1.7.5", Compiler:"gc", Platform:"linux/amd64"}

Environment:
NAME="Container Linux by CoreOS"
ID=coreos
VERSION=1381.1.0
VERSION_ID=1381.1.0
BUILD_ID=2017-04-25-2232
PRETTY_NAME="Container Linux by CoreOS 1381.1.0 (Ladybug)"
ANSI_COLOR="38;5;75"
HOME_URL="https://coreos.com/"
BUG_REPORT_URL="https://issues.coreos.com"
COREOS_BOARD="amd64-usr"

Access modes for PVC resources does not work as expected, for example if using dynamic provision with ROX mode, for glusterFS provisioner it allows perform write operation on volume moreover it can be used as RWX.

I expect when using accessModes it should work properly, at least if i creating RO volume it should be mounted as RO

Create PVC with AccessMode param as ReadOnlyMany, then assign it to POD and try to write something, for example touch <path/to/mount>/test, you should be able to write file in "ReadOnly" filesystem

@k8s-github-robot
Copy link

@pkutishch There are no sig labels on this issue. Please add a sig label by:
(1) mentioning a sig: @kubernetes/sig-<team-name>-misc
(2) specifying the label manually: /sig <label>

Note: method (1) will trigger a notification to the team. You can find the team list here and label list here

@k8s-github-robot k8s-github-robot added the needs-sig Indicates an issue or PR lacks a `sig/foo` label and requires one. label Jun 12, 2017
@pkutishch
Copy link
Author

pkutishch commented Jun 12, 2017

@kubernetes/sig-storage

@xiangpengzhao
Copy link
Contributor

/sig storage

@k8s-ci-robot k8s-ci-robot added the sig/storage Categorizes an issue or PR as relevant to SIG Storage. label Jun 12, 2017
@k8s-github-robot k8s-github-robot removed the needs-sig Indicates an issue or PR lacks a `sig/foo` label and requires one. label Jun 12, 2017
@wongma7
Copy link
Contributor

wongma7 commented Jun 12, 2017

The only function AccessModes has right now is at binding time, for ensuring a PVC gets a PV with the AccessModes it wants: think of it as a first-class labelselector. And the way kubernetes thinks of it is that RWO is a subset of RWM, so a provisioned RWM glusterfs volume satisfies your claim. But I agree this is a bug, we should provision ReadOnly when ReadOnly is explicitly requested.

The value of the ReadOnly setting of PersistentVolumeSource (which is what says "mount w/ ro") can be totally independent of the AccessModes, i.e. you can have a PV with RWM AccessModes but ReadOnly set true. But the provisioners are in a position to be smarter and set ReadOnly according to what AccessModes were requested.

Let me plug #47274, when it's merged provisioners will stop ignoring AccessModes, they will start parsing it on per-plugin basis, but for a different reason than what's requested here. Like this, when implemented it will be a "breaking bugfix," & so we will need approval before we break stuff

@gnufied
Copy link
Member

gnufied commented Jun 12, 2017

@pkutishch what does your pod definition looks like? You can specify read-only: true when specify claimName in your pod specs and that should be honored during mount-time (if it isn't , it is a bug).

@wongma7 yeah, I think we can indeed set ReadOnly field of PersistentVolumeSource depending on requested AccessMode in PVC.

@xingzhou
Copy link
Contributor

@wongma7 and @gnufied, any plans to fully enforce the access mode? I submitted a ticket on this before #37465. If we specify RWO, it means that we should only attach this volume to only one node.

@gnufied
Copy link
Member

gnufied commented Jun 13, 2017

There are 2 separate issues here.

a. AccessMode is not applied at mount time. So if user specifies ROX, volumes are still mounted as RW. As @wongma7 said, this is because AccessMode is only used during binding phase and forgotten later on. This problem is relatively easier to solve and I think we can set ReadOnly on volumes if ROX accessmode is specified in PVC.

b. Another problem of course is, k8s doesn't enforces accessMode check during pod creation/scheduling. i.e - a RWO PVC can be used from multiple pods and that inevitably fails (unless with some luck, 2 pods land on same node). We have merged #45346 PR, which prevents attach operation from happening if volume is attached elsewhere. That PR only applies to Cinder and Azure. The problem that we are seeing is - in many cases users aren't aware that they aren't supposed to use same PVC in 2 pods or they are scaling the deployment with PVC to 2 or more replicas. This state usually leads to a huge number of invalid CloudProvider API calls and is I think undesirable.

We have 2 choices to fix problem#b:

  1. Extend current solution that @codablock implemented to other volume types, such as - EBS, NFS etc. It could work. But I think a problem with merged solution is - it relies on ActualStateOfWorld to verify if volume is attached somewhere. I think checking ASOW is not a strong guarantee and check can return false negatives, in cases like controller restart.
  2. We can check if PVC being requested is used elsehwhere via some sort of scheduler predicate and make such pods unschedulable. I don't know, if people actually rely on current behaviour which allows attaching same PVC to 2 or more pods, as long as, all pods are scheduled on same node.

@saad-ali @kubernetes/sig-storage-pr-reviews

@xingzhou
Copy link
Contributor

@gnufied, if we detect the multi-pod usage from scheduler side, is there any way for the scheduler to know whether or not a PVC is already bound to a pod?

@pkutishch
Copy link
Author

@xingzhou as per my understanding the way is check pod spec where binding pvc defined in volume block.
Anyway but i think in future would be nice to have such info in PVC/PV status that i has bound to POD and pod name for example, this will help check whether it was assigned to some resources.
But it only my view

@xingzhou
Copy link
Contributor

yes, that's my concern, as the PVC status does not include the bound pod info, so it might be not easy to stop the pod scheduling at schedule phase at present, if check from pod spec, I don't know if there is any way to "lock" the resource efficiently, as in a cluster, I think we can run multiple schedulers simultaneously.

@pkutishch
Copy link
Author

@xingzhou as i know k8s storing information in etcd, not sure if it stores information regarding storage but you may setup lock flag in etcd, and during assigning PVC to POD it will check for lock flag in case you using RWO mode. and not to set lock flag for RWX and ROX, but not sure that this case is suitable.

@fejta-bot
Copy link

Issues go stale after 90d of inactivity.
Mark the issue as fresh with /remove-lifecycle stale.
Stale issues rot after an additional 30d of inactivity and eventually close.

Prevent issues from auto-closing with an /lifecycle frozen comment.

If this issue is safe to close now please do so with /close.

Send feedback to sig-testing, kubernetes/test-infra and/or @fejta.
/lifecycle stale

@k8s-ci-robot k8s-ci-robot added the lifecycle/stale Denotes an issue or PR has remained open with no activity and has become stale. label Dec 27, 2017
@fejta-bot
Copy link

Stale issues rot after 30d of inactivity.
Mark the issue as fresh with /remove-lifecycle rotten.
Rotten issues close after an additional 30d of inactivity.

If this issue is safe to close now please do so with /close.

Send feedback to sig-testing, kubernetes/test-infra and/or fejta.
/lifecycle rotten
/remove-lifecycle stale

@k8s-ci-robot k8s-ci-robot added lifecycle/rotten Denotes an issue or PR that has aged beyond stale and will be auto-closed. and removed lifecycle/stale Denotes an issue or PR has remained open with no activity and has become stale. labels Jan 26, 2018
@fejta-bot
Copy link

Rotten issues close after 30d of inactivity.
Reopen the issue with /reopen.
Mark the issue as fresh with /remove-lifecycle rotten.

Send feedback to sig-testing, kubernetes/test-infra and/or fejta.
/close

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
lifecycle/rotten Denotes an issue or PR that has aged beyond stale and will be auto-closed. sig/storage Categorizes an issue or PR as relevant to SIG Storage.
Projects
None yet
Development

No branches or pull requests

8 participants