[kubernetes/kubernetes] CSI incorrectly sets fsgroup for all volume types (#66323)

74 views
Skip to first unread message

Michelle Au

unread,
Jul 17, 2018, 9:58:44 PM7/17/18
to kubernetes/kubernetes, k8s-mirror-storage-bugs, Team mention

Is this a BUG REPORT or FEATURE REQUEST?:
@kubernetes/sig-storage-bugs

What happened:
fsgroup is only intended for RWO volumes because it recursively changes the permissions of all the directories in the volume. This can cause problems for nfs-type volumes because multiple pods could access the same volume and have the permissions changed out from underneath.

What you expected to happen:
Determine whether or not the plugin supports fsgroup either via:

  • access mode. This is still a bit ambiguous for nfs volume types, that can theoretically support rwo, especially since Kubernetes does not do any sort of access mode enforcement.
  • a new csi capability


You are receiving this because you are on a team that was mentioned.
Reply to this email directly, view it on GitHub, or mute the thread.

Saad Ali

unread,
Jul 18, 2018, 5:58:08 AM7/18/18
to kubernetes/kubernetes, k8s-mirror-storage-bugs, Team mention

Kubernetes Submit Queue

unread,
Jul 18, 2018, 5:59:49 AM7/18/18
to kubernetes/kubernetes, k8s-mirror-storage-bugs, Team mention

[MILESTONENOTIFIER] Milestone Issue Needs Approval

@msau42 @kubernetes/sig-storage-misc

Action required: This issue must have the status/approved-for-milestone label applied by a SIG maintainer.

Issue Labels
  • sig/storage: Issue will be escalated to these SIGs if needed.
  • priority/critical-urgent: Never automatically move issue out of a release milestone; continually escalate to contributor and SIG through all available channels.
  • kind/bug: Fixes a bug discovered during the current release.
Help

Kubernetes Submit Queue

unread,
Jul 18, 2018, 1:18:02 PM7/18/18
to kubernetes/kubernetes, k8s-mirror-storage-bugs, Team mention

[MILESTONENOTIFIER] Milestone Issue Needs Approval

@msau42 @vladimirvivien @kubernetes/sig-storage-misc

Action required: This issue must have the status/approved-for-milestone label applied by a SIG maintainer.

Issue Labels
  • sig/storage: Issue will be escalated to these SIGs if needed.
  • priority/critical-urgent: Never automatically move issue out of a release milestone; continually escalate to contributor and SIG through all available channels.
  • kind/bug: Fixes a bug discovered during the current release.
Help

Kubernetes Submit Queue

unread,
Jul 20, 2018, 4:52:20 AM7/20/18
to kubernetes/kubernetes, k8s-mirror-storage-bugs, Team mention

[MILESTONENOTIFIER] Milestone Issue Needs Approval

@msau42 @vladimirvivien @kubernetes/sig-storage-misc

Action required: This issue must have the status/approved-for-milestone label applied by a SIG maintainer.

Issue Labels
  • sig/storage: Issue will be escalated to these SIGs if needed.
  • priority/critical-urgent: Never automatically move issue out of a release milestone; continually escalate to contributor and SIG through all available channels.
  • kind/bug: Fixes a bug discovered during the current release.
Help

Kubernetes Submit Queue

unread,
Jul 22, 2018, 4:17:47 AM7/22/18
to kubernetes/kubernetes, k8s-mirror-storage-bugs, Team mention

[MILESTONENOTIFIER] Milestone Issue Needs Approval

@msau42 @vladimirvivien @kubernetes/sig-storage-misc

Action required: This issue must have the status/approved-for-milestone label applied by a SIG maintainer.

Issue Labels
  • sig/storage: Issue will be escalated to these SIGs if needed.
  • priority/critical-urgent: Never automatically move issue out of a release milestone; continually escalate to contributor and SIG through all available channels.
  • kind/bug: Fixes a bug discovered during the current release.
Help

Kubernetes Submit Queue

unread,
Jul 23, 2018, 4:54:55 AM7/23/18
to kubernetes/kubernetes, k8s-mirror-storage-bugs, Team mention

[MILESTONENOTIFIER] Milestone Issue Needs Approval

@msau42 @vladimirvivien @kubernetes/sig-storage-misc

Action required: This issue must have the status/approved-for-milestone label applied by a SIG maintainer.

Issue Labels
  • sig/storage: Issue will be escalated to these SIGs if needed.
  • priority/critical-urgent: Never automatically move issue out of a release milestone; continually escalate to contributor and SIG through all available channels.
  • kind/bug: Fixes a bug discovered during the current release.
Help

Kubernetes Submit Queue

unread,
Jul 24, 2018, 4:58:20 AM7/24/18
to kubernetes/kubernetes, k8s-mirror-storage-bugs, Team mention

[MILESTONENOTIFIER] Milestone Issue Needs Approval

@msau42 @vladimirvivien @kubernetes/sig-storage-misc

Action required: This issue must have the status/approved-for-milestone label applied by a SIG maintainer.

Issue Labels
  • sig/storage: Issue will be escalated to these SIGs if needed.
  • priority/critical-urgent: Never automatically move issue out of a release milestone; continually escalate to contributor and SIG through all available channels.
  • kind/bug: Fixes a bug discovered during the current release.
Help

Vladimir Vivien

unread,
Jul 24, 2018, 4:19:51 PM7/24/18
to kubernetes/kubernetes, k8s-mirror-storage-bugs, Team mention

@msau42

  • Are you saying that CSI internal driver should check driver capability for RWO, if supported, only then apply fsgroup value ?
  • What would the new csi capability be ?

Michelle Au

unread,
Jul 24, 2018, 5:00:00 PM7/24/18
to kubernetes/kubernetes, k8s-mirror-storage-bugs, Team mention

Yes one possible way is to infer fsgroup is supported for all rwo volumes, which may not be true? Like a nfs volume technically supports rwo but not fsgroup.

So the other option is to make it a new CSI capability. I'm not sure exactly sure how best to describe it though, maybe something about volume ownership management.

Hemant Kumar

unread,
Jul 24, 2018, 5:29:23 PM7/24/18
to kubernetes/kubernetes, k8s-mirror-storage-bugs, Team mention

Will it work if fsType is not set then don't chown the ownership? I would think that for shared file system types(nfs, glusterfs) - fsType won't be set. For block storage too - I think we shouldn't have to do this.

Vladimir Vivien

unread,
Jul 24, 2018, 6:10:00 PM7/24/18
to kubernetes/kubernetes, k8s-mirror-storage-bugs, Team mention

@gnufied what do you mean by I think we shouldn't have to do this? Shouldnt have to solve this issue ?

Hemant Kumar

unread,
Jul 24, 2018, 6:22:20 PM7/24/18
to kubernetes/kubernetes, k8s-mirror-storage-bugs, Team mention

I meant For raw block storage too - I think we shouldn't have to do this. - which is obvious. I just meant that the entire mechanism of changing ownership of files should apply only to volume types with block storage filesystems. I am just wondering if we can get away with detecting fsType and not have to introduce new capability in CSI.

Vladimir Vivien

unread,
Jul 24, 2018, 6:57:57 PM7/24/18
to kubernetes/kubernetes, k8s-mirror-storage-bugs, Team mention

@msau42 @gnufied agreed, PVC.spec.AccessModes do not map well to current csi.Capabilities enums which makes it hard to determine RWO when mounting. Perhaps, instead of a new capability, we revisit the existing capabilities to see if there are any way RWO can be reliably inferred from returned capabilities. Currently, this is what the code is doing which we knew needed to be revisited:

func asCSIAccessMode(am api.PersistentVolumeAccessMode) csipb.VolumeCapability_AccessMode_Mode {
	switch am {
	case api.ReadWriteOnce:
		return csipb.VolumeCapability_AccessMode_SINGLE_NODE_WRITER
	case api.ReadOnlyMany:
		return csipb.VolumeCapability_AccessMode_MULTI_NODE_READER_ONLY
	case api.ReadWriteMany:
		return csipb.VolumeCapability_AccessMode_MULTI_NODE_MULTI_WRITER
	}
	return csipb.VolumeCapability_AccessMode_UNKNOWN
}

Michelle Au

unread,
Jul 24, 2018, 8:01:22 PM7/24/18
to kubernetes/kubernetes, k8s-mirror-storage-bugs, Team mention

Users may not fully understand what fsgroup is and set it anyway, or a default psp with some fsgroup may be defined in which it will automatically be set on all pods. The first case we can attribute to user error, but the second case may not have a good workaround and could cause permission issues on rwx volumes. So I think we do need to solve this.

Vladimir Vivien

unread,
Jul 25, 2018, 6:02:48 PM7/25/18
to kubernetes/kubernetes, k8s-mirror-storage-bugs, Team mention

@msau42 Yes, agreed this has to be solved. As you pointed out user error or improperly configured PSP can set fsgroup value that does not match the correct attribute, causing permission issues.

Here is what I think can be done without new CSI capabilities:

  • if PV.AccessModes == nil, then do not apply fsgroup
  • if contains(PV.AccessModes, RWM) || contains(PV.AccessModes, ROM) then:
    • If mount reference count <= 1, apply fsgroup
    • If mount reference count > 1, do not apply fsgroup to void stated issue
  • if contains(PV.AccessModes, RWO) then:
    • if mount reference == 1, apply fsgroup

I think that may help deduce when to apply fsgroup.

Kubernetes Submit Queue

unread,
Jul 25, 2018, 6:03:14 PM7/25/18
to kubernetes/kubernetes, k8s-mirror-storage-bugs, Team mention

[MILESTONENOTIFIER] Milestone Issue Needs Approval

@msau42 @vladimirvivien @kubernetes/sig-storage-misc

Action required: This issue must have the status/approved-for-milestone label applied by a SIG maintainer.

Issue Labels
  • sig/storage: Issue will be escalated to these SIGs if needed.
  • priority/critical-urgent: Never automatically move issue out of a release milestone; continually escalate to contributor and SIG through all available channels.
  • kind/bug: Fixes a bug discovered during the current release.
Help

Jan Šafránek

unread,
Jul 26, 2018, 3:53:40 AM7/26/18
to kubernetes/kubernetes, k8s-mirror-storage-bugs, Team mention
  • if contains(PV.AccessModes, RWM) || contains(PV.AccessModes, ROM) then:
  • * If mount reference count <= 1, apply fsgroup
    * If mount reference count > 1, do not apply fsgroup to void stated issue

A RWM volume (say NFS) can be mounted on multiple nodes. Do you have reliable count of mounts across all nodes?

Michelle Au

unread,
Jul 26, 2018, 12:21:24 PM7/26/18
to kubernetes/kubernetes, k8s-mirror-storage-bugs, Team mention

In addition, that would be a change in semantics to how we support rwx volumes today. If we don't have a new CSI capability, then I think the best course of action is to only apply fsgroup for RWO volumes. Some questions remain:

  • Do all RWO volumes support fsgroup?
  • RWX is a superset of RWO. So if a user requests a RWO volume, it could still be satisfied by a RWX volume type. Can we detect this and still not apply the fsgroup even though the volume capability will say RWO?

Vladimir Vivien

unread,
Jul 26, 2018, 4:09:35 PM7/26/18
to kubernetes/kubernetes, k8s-mirror-storage-bugs, Team mention

If there's not a reliable way to enumerate node mounts (thinking about it, for CSI external drivers, the answer is NO). Theres is no reliable way to have k8s autocorrect a bad fsgroup/PV.AccessMode combo. So we would have to rely on the config provided by user/admin.

I have come to similar conclusion as @msau42 -- mainly, apply fsgroup only to volumes with RWO access modes. The other k8s specified access modes, Read{Only|Write}Many, cannot be reliably applied.

Even if we were to introduce additional plugin capabilities that the CO can query (from driver) to find out what modes can be applied, there would still be the possibility of user/admin mis-configuration.

  • Do all RWO volumes support fsgroup?

Probably not, Is this where you think an additional capability would help (@msau42 )

  • RWX is a superset of RWO. So if a user requests a RWO volume, it could still be satisfied by a RWX volume type. Can we detect this and still not apply the fsgroup even though the volume capability will say RWO?

That is a good point. Can't think of a way to detect/guess RWX when RWO is specified, this without the driver providing that info.

Can we adopt the only RWO gets fsgroup rule until we decide what capabilities would look like ?

Hemant Kumar

unread,
Jul 26, 2018, 4:37:34 PM7/26/18
to kubernetes/kubernetes, k8s-mirror-storage-bugs, Team mention

I will just try to summarize the conversation from Slack.

We can safely assume that fsgroup only applies to block storage type with file system on top of it. So for all - volumes that need to have SetVolumeOwnership called MUST have a file system(fsType) on them. Is that assumption correct?

If it is - can we not use presence of fsType field or we can query the local volume for fs type (like how we query selinux relabelling capability) and call SetVolumeOwnership only when - volume is RWM and has a valid block storage file system type.

Will this not solve our use case?

Kubernetes Submit Queue

unread,
Jul 27, 2018, 4:23:42 AM7/27/18
to kubernetes/kubernetes, k8s-mirror-storage-bugs, Team mention

[MILESTONENOTIFIER] Milestone Issue Needs Approval

@msau42 @vladimirvivien @kubernetes/sig-storage-misc

Action required: This issue must have the status/approved-for-milestone label applied by a SIG maintainer.

Issue Labels
  • sig/storage: Issue will be escalated to these SIGs if needed.
  • priority/critical-urgent: Never automatically move issue out of a release milestone; continually escalate to contributor and SIG through all available channels.
  • kind/bug: Fixes a bug discovered during the current release.
Help

Michelle Au

unread,
Jul 27, 2018, 4:02:16 PM7/27/18
to kubernetes/kubernetes, k8s-mirror-storage-bugs, Team mention

We'll need to make it clear that fsType is only for block-based storage systems, and the field cannot be reused for some multi-protocol file server (ie, nfsv3, nfsv4, smb, etc). For that case, then the plugin will need to expose its own new storageclass parameter + volume attribute to specify protocol.

Hemant Kumar

unread,
Jul 27, 2018, 5:53:01 PM7/27/18
to kubernetes/kubernetes, k8s-mirror-storage-bugs, Team mention

Can we not use blkid to get fsType - #59050 and use that information for calling SetVolumeOwnership ? It may be problematic to rely entirely on fsType present inside csi source.

Kubernetes Submit Queue

unread,
Jul 28, 2018, 4:57:24 AM7/28/18
to kubernetes/kubernetes, k8s-mirror-storage-bugs, Team mention

[MILESTONENOTIFIER] Milestone Issue Needs Approval

@msau42 @vladimirvivien @kubernetes/sig-storage-misc

Action required: This issue must have the status/approved-for-milestone label applied by a SIG maintainer.

Issue Labels
  • sig/storage: Issue will be escalated to these SIGs if needed.
  • priority/critical-urgent: Never automatically move issue out of a release milestone; continually escalate to contributor and SIG through all available channels.
  • kind/bug: Fixes a bug discovered during the current release.
Help

Kubernetes Submit Queue

unread,
Jul 30, 2018, 4:27:25 AM7/30/18
to kubernetes/kubernetes, k8s-mirror-storage-bugs, Team mention

[MILESTONENOTIFIER] Milestone Issue Needs Approval

@msau42 @vladimirvivien @kubernetes/sig-storage-misc

Action required: This issue must have the status/approved-for-milestone label applied by a SIG maintainer.

Issue Labels
  • sig/storage: Issue will be escalated to these SIGs if needed.
  • priority/critical-urgent: Never automatically move issue out of a release milestone; continually escalate to contributor and SIG through all available channels.
  • kind/bug: Fixes a bug discovered during the current release.
Help

Vladimir Vivien

unread,
Jul 30, 2018, 9:49:31 AM7/30/18
to kubernetes/kubernetes, k8s-mirror-storage-bugs, Team mention

@gnufied the only problem with #59050 is that in CSI volume info is intentionally opaque to the CSI code inside k8s. All mount logic is delegated to the driver.

Vladimir Vivien

unread,
Jul 30, 2018, 9:53:38 AM7/30/18
to kubernetes/kubernetes, k8s-mirror-storage-bugs, Team mention

@msau42 @gnufied @saad-ali Instead of a new capability or trying to deduce how best to apply fsgroup, why not pass the fsgroup to the driver and let it decide how to apply it (either as a attribute for the mount or top level request param)? Right now, all mount logic has been delegated to the external CSI driver except for applying permission.

Thoughts ?

Hemant Kumar

unread,
Jul 30, 2018, 10:28:59 AM7/30/18
to kubernetes/kubernetes, k8s-mirror-storage-bugs, Team mention

@vladimirvivien that is true but we can still inspect file system on the mounted path because by the time SetVolumeOwnership gets called volume is already mounted. This should be no different than how selinux support is determined. @jsafrane what you think?

guineveresaenger

unread,
Jul 30, 2018, 11:20:39 PM7/30/18
to kubernetes/kubernetes, k8s-mirror-storage-bugs, Team mention

@saad-ali is this approved for 1.12 milestone? Thank you for working on this, @vladimirvivien!

Vladimir Vivien

unread,
Jul 31, 2018, 4:35:18 PM7/31/18
to kubernetes/kubernetes, k8s-mirror-storage-bugs, Team mention

@guineveresaenger still discussing how best to approach this. It would be a 1.12.

Kubernetes Submit Queue

unread,
Jul 31, 2018, 4:36:49 PM7/31/18
to kubernetes/kubernetes, k8s-mirror-storage-bugs, Team mention

[MILESTONENOTIFIER] Milestone Issue Needs Approval

@msau42 @vladimirvivien @kubernetes/sig-storage-misc

Action required: This issue must have the status/approved-for-milestone label applied by a SIG maintainer.

Issue Labels
  • sig/storage: Issue will be escalated to these SIGs if needed.
  • priority/critical-urgent: Never automatically move issue out of a release milestone; continually escalate to contributor and SIG through all available channels.
  • kind/bug: Fixes a bug discovered during the current release.
Help

Saad Ali

unread,
Jul 31, 2018, 8:09:07 PM7/31/18
to kubernetes/kubernetes, k8s-mirror-storage-bugs, Team mention

Approved for 1.12

Kubernetes Submit Queue

unread,
Jul 31, 2018, 8:09:29 PM7/31/18
to kubernetes/kubernetes, k8s-mirror-storage-bugs, Team mention

[MILESTONENOTIFIER] Milestone Issue: Up-to-date for process

@msau42 @vladimirvivien

Issue Labels
  • sig/storage: Issue will be escalated to these SIGs if needed.
  • priority/critical-urgent: Never automatically move issue out of a release milestone; continually escalate to contributor and SIG through all available channels.
  • kind/bug: Fixes a bug discovered during the current release.
Help

Vladimir Vivien

unread,
Aug 1, 2018, 5:07:18 PM8/1/18
to kubernetes/kubernetes, k8s-mirror-storage-bugs, Team mention

@msau42 @gnufied
Based on previous post, this is a summary:

  • If fsType == ""
    • then fsGroup is not applied (because it could be an indication of a nonblock fs, or error)
    • Done
  • fsType is provided
    • if fstype is invalid
      • Done
    • if fstype is valid and pv.AccessMode == RWO then apply fstype logic
    • else
      • ignore fsGroup
      • Done

guineveresaenger

unread,
Aug 27, 2018, 8:38:42 AM8/27/18
to kubernetes/kubernetes, k8s-mirror-storage-bugs, Team mention

Vladimir Vivien

unread,
Aug 28, 2018, 11:38:09 AM8/28/18
to kubernetes/kubernetes, k8s-mirror-storage-bugs, Team mention

Waiting for a review and approval. @saad-ali

Hemant Kumar

unread,
Aug 28, 2018, 11:54:55 AM8/28/18
to kubernetes/kubernetes, k8s-mirror-storage-bugs, Team mention

@vladimirvivien you have a outstanding comment on the PR. Can you please answer that?

k8s-ci-robot

unread,
Sep 14, 2018, 5:22:25 PM9/14/18
to kubernetes/kubernetes, k8s-mirror-storage-bugs, Team mention

Closed #66323 via #67280.

Steven E. Harris

unread,
Dec 9, 2019, 2:17:03 PM12/9/19
to kubernetes/kubernetes, k8s-mirror-storage-bugs, Team mention

How does this approach relate to inline CSI volumes? There's no PersistentVolume involved, and hence no way to specify an access mode. I can specify a filesystem type, but my driver ignores it (always using tmpfs).

I considered having my CSI driver read the mounting pod's spec to see if it has a security context with "fsGroup" set, since that detail is not supplied to the driver, as @vladimirvivien noted.

My goal is to have the volume mounted with the files on it readable by the container's user, but there's no way for my driver to know who that user will be. Am I supposed to just use 0444 for the ownership bits, to allow everyone to read the files?


You are receiving this because you are on a team that was mentioned.

Reply to this email directly, view it on GitHub, or unsubscribe.

Reply all
Reply to author
Forward
0 new messages